From b6bba1ccbe70675d35919a7cee4dad8a6e226b0f Mon Sep 17 00:00:00 2001 From: Rapidement Date: Sat, 16 Nov 2024 15:33:29 +0100 Subject: [PATCH] feat(GIST-105): change mygist url to username (#47) --- .../{mygist => [username]}/[gistId]/page-ui.tsx | 3 +++ .../(gistLayout)/{mygist => [username]}/[gistId]/page.tsx | 5 +++-- src/app/(gistLayout)/{mygist => [username]}/page-ui.tsx | 0 src/app/(gistLayout)/{mygist => [username]}/page.tsx | 0 src/app/(gistLayout)/layout-ui.tsx | 4 +--- .../(gistLayout)/org/[orgId]/gist/[gistId]/page-ui.tsx | 3 +++ src/app/(gistLayout)/org/[orgId]/gist/[gistId]/page.tsx | 3 +++ src/app/login/page.tsx | 4 +++- src/components/logic/mygist-list-logic.tsx | 4 +++- src/components/ui/gist-details.tsx | 8 ++++++-- src/components/ui/mygist-list.tsx | 5 +++-- 11 files changed, 28 insertions(+), 11 deletions(-) rename src/app/(gistLayout)/{mygist => [username]}/[gistId]/page-ui.tsx (90%) rename src/app/(gistLayout)/{mygist => [username]}/[gistId]/page.tsx (96%) rename src/app/(gistLayout)/{mygist => [username]}/page-ui.tsx (100%) rename src/app/(gistLayout)/{mygist => [username]}/page.tsx (100%) diff --git a/src/app/(gistLayout)/mygist/[gistId]/page-ui.tsx b/src/app/(gistLayout)/[username]/[gistId]/page-ui.tsx similarity index 90% rename from src/app/(gistLayout)/mygist/[gistId]/page-ui.tsx rename to src/app/(gistLayout)/[username]/[gistId]/page-ui.tsx index cffcb49..28005bd 100644 --- a/src/app/(gistLayout)/mygist/[gistId]/page-ui.tsx +++ b/src/app/(gistLayout)/[username]/[gistId]/page-ui.tsx @@ -3,6 +3,7 @@ import { Gist } from "@/types" interface MyGistIdPageProps { gist: Gist + username?: string onDownload: () => void onSave: (name: string, code: string) => void onDelete: (id: string) => void @@ -13,6 +14,7 @@ interface MyGistIdPageProps { export default function MyGistIdPage({ gist, + username, onDownload, onSave, onDelete, @@ -22,6 +24,7 @@ export default function MyGistIdPage({ }: MyGistIdPageProps) { return ( { @@ -55,7 +55,7 @@ export default function MyGistIdFeaturePage({ params }: MyGistIdFeaturePageProps visibility: "public", org_id: null, language: "plaintext", - owner_id: me?.id || "", + owner_id: user?.id || "", }) } @@ -96,6 +96,7 @@ export default function MyGistIdFeaturePage({ params }: MyGistIdFeaturePageProps } return ( My Gists diff --git a/src/app/(gistLayout)/org/[orgId]/gist/[gistId]/page-ui.tsx b/src/app/(gistLayout)/org/[orgId]/gist/[gistId]/page-ui.tsx index 3c0c156..410ad80 100644 --- a/src/app/(gistLayout)/org/[orgId]/gist/[gistId]/page-ui.tsx +++ b/src/app/(gistLayout)/org/[orgId]/gist/[gistId]/page-ui.tsx @@ -3,6 +3,7 @@ import { Gist } from "@/types" interface MyOrgGistIdPageProps { gist: Gist + username: string orgName: string onDownload: () => void onSave: () => void @@ -14,6 +15,7 @@ interface MyOrgGistIdPageProps { export default function MyOrgGistIdPage({ orgName, + username, gist, onDownload, onSave, @@ -24,6 +26,7 @@ export default function MyOrgGistIdPage({ }: MyOrgGistIdPageProps) { return ( + return } diff --git a/src/components/ui/gist-details.tsx b/src/components/ui/gist-details.tsx index bf35d26..d529c05 100644 --- a/src/components/ui/gist-details.tsx +++ b/src/components/ui/gist-details.tsx @@ -22,6 +22,7 @@ import { Button } from "../shadcn/button" interface GistDetailsProps { gist: Gist + username: string orgName: string redirect?: boolean onDownload: (name: string, code: string) => void @@ -34,6 +35,7 @@ interface GistDetailsProps { export default function GistDetails({ gist, + username, orgName, redirect, onDownload, @@ -71,6 +73,7 @@ export default function GistDetails({
onDownload(gistName, gistCode)} @@ -138,6 +141,7 @@ export default function GistDetails({ interface HeaderProps { gist: Gist + username?: string orgName: string redirect?: boolean onDownload: (name: string, code: string) => void @@ -146,7 +150,7 @@ interface HeaderProps { onOpenPlainText?: (gistID: string) => void } -function Header({ gist, orgName, redirect, onDownload, onCopy, onCopyCurl, onOpenPlainText }: HeaderProps) { +function Header({ gist, username, orgName, redirect, onDownload, onCopy, onCopyCurl, onOpenPlainText }: HeaderProps) { return (
@@ -154,7 +158,7 @@ function Header({ gist, orgName, redirect, onDownload, onCopy, onCopyCurl, onOpe
{redirect ? ( - + {orgName} ) : ( diff --git a/src/components/ui/mygist-list.tsx b/src/components/ui/mygist-list.tsx index cd81b4d..486d2d8 100644 --- a/src/components/ui/mygist-list.tsx +++ b/src/components/ui/mygist-list.tsx @@ -4,9 +4,10 @@ import Card from "./card" interface MyGistListProps { gists: Gist[] onDeleteGist: (id: string) => void + username?: string } -export default function MyGistList({ gists, onDeleteGist }: MyGistListProps) { +export default function MyGistList({ gists, onDeleteGist, username }: MyGistListProps) { if (gists.length === 0) { return (
@@ -18,7 +19,7 @@ export default function MyGistList({ gists, onDeleteGist }: MyGistListProps) { return (
{gists.map((gist) => ( - onDeleteGist(gist.id)} /> + onDeleteGist(gist.id)} /> ))}
)