diff --git a/actions/getIdentityData.ts b/actions/getIdentityData.ts index 7224413b..076bc760 100644 --- a/actions/getIdentityData.ts +++ b/actions/getIdentityData.ts @@ -24,6 +24,7 @@ export async function uncachedGetIdentityData() { entity_sets(entities(facts(*))) )), permission_token_on_homepage( + archived, created_at, permission_tokens!inner( id, diff --git a/app/(home-pages)/home/HomeLayout.tsx b/app/(home-pages)/home/HomeLayout.tsx index 07cf692c..498b1820 100644 --- a/app/(home-pages)/home/HomeLayout.tsx +++ b/app/(home-pages)/home/HomeLayout.tsx @@ -33,6 +33,7 @@ import { type Leaflet = { added_at: string; + archived?: boolean | null; token: PermissionToken & { leaflets_in_publications?: Exclude< GetLeafletDataReturnType["result"]["data"], @@ -147,6 +148,7 @@ export function HomeLeafletList(props: { ? identity.permission_token_on_homepage.map((ptoh) => ({ added_at: ptoh.created_at, token: ptoh.permission_tokens as PermissionToken, + archived: ptoh.archived, })) : localLeaflets .sort((a, b) => (a.added_at > b.added_at ? -1 : 1)) @@ -204,7 +206,7 @@ export function LeafletList(props: { w-full ${display === "grid" ? "grid auto-rows-max md:grid-cols-4 sm:grid-cols-3 grid-cols-2 gap-y-4 gap-x-4 sm:gap-x-6 sm:gap-y-5 grow" : "flex flex-col gap-2 pt-2"} `} > - {props.leaflets.map(({ token: leaflet, added_at }, index) => ( + {props.leaflets.map(({ token: leaflet, added_at, archived }, index) => ( l.doc)} diff --git a/app/(home-pages)/home/LeafletList/LeafletInfo.tsx b/app/(home-pages)/home/LeafletList/LeafletInfo.tsx index fcb0aafc..7d44d013 100644 --- a/app/(home-pages)/home/LeafletList/LeafletInfo.tsx +++ b/app/(home-pages)/home/LeafletList/LeafletInfo.tsx @@ -21,14 +21,13 @@ export const LeafletInfo = (props: { added_at: string; publishedAt?: string; document_uri?: string; + archived?: boolean | null; }) => { let [prefetch, setPrefetch] = useState(false); let prettyCreatedAt = props.added_at ? timeAgo(props.added_at) : ""; let prettyPublishedAt = props.publishedAt ? timeAgo(props.publishedAt) : ""; - let shareLink = usePublishLink(); - console.log(shareLink); return (
diff --git a/app/(home-pages)/home/LeafletList/LeafletListItem.tsx b/app/(home-pages)/home/LeafletList/LeafletListItem.tsx index b51f7080..4a08db08 100644 --- a/app/(home-pages)/home/LeafletList/LeafletListItem.tsx +++ b/app/(home-pages)/home/LeafletList/LeafletListItem.tsx @@ -7,6 +7,7 @@ import { useState, useRef, useEffect } from "react"; export const LeafletListItem = (props: { token: PermissionToken; + archived?: boolean | null; leaflet_id: string; loggedIn: boolean; display: "list" | "grid"; diff --git a/app/(home-pages)/home/LeafletList/LeafletOptions.tsx b/app/(home-pages)/home/LeafletList/LeafletOptions.tsx index 10abf061..63191ff8 100644 --- a/app/(home-pages)/home/LeafletList/LeafletOptions.tsx +++ b/app/(home-pages)/home/LeafletList/LeafletOptions.tsx @@ -31,15 +31,13 @@ export const LeafletOptions = (props: { isTemplate?: boolean; draft?: boolean; document_uri?: string; - shareLink: string | undefined | null; + shareLink: string; + archived?: boolean | null; }) => { - console.log("sharelink: " + props.shareLink); - let { mutate: mutateIdentity } = useIdentityData(); let [state, setState] = useState<"normal" | "template" | "areYouSure">( "normal", ); let [open, setOpen] = useState(false); - let smoker = useSmoker(); return ( <> {state === "normal" ? ( - <> - - - Copy {props.document_uri ? "Post" : "Edit"} Link - - } - subtext="" - smokerText="Link copied!" - id="get-link" - link={`/${props.leaflet.id}`} + props.document_uri ? ( + - - {!props.isTemplate ? ( - { - e.preventDefault(); - setState("template"); - }} - > - Use as Template - - ) : ( - { - useTemplateState.getState().removeTemplate(props.leaflet); - let newLeafletButton = - document.getElementById("new-leaflet-button"); - if (!newLeafletButton) return; - let rect = newLeafletButton.getBoundingClientRect(); - smoker({ - static: true, - text: Removed template!, - position: { - y: rect.top, - x: rect.right + 5, - }, - }); - }} - > - Remove from Templates - - )} -
- {props.document_uri ? ( - - ) : ( - - )} - + ) : ( + + ) ) : state === "template" ? ( setOpen(false)} /> ) : state === "areYouSure" ? ( - setState("normal")} leaflet={props.leaflet} document_uri={props.document_uri} @@ -136,14 +92,35 @@ export const LeafletOptions = (props: { }; const DefaultOptions = (props: { - setState: (s: "areYouSure") => void; + setState: (s: "areYouSure" | "template") => void; draft?: boolean; + leaflet: PermissionToken; + isTemplate: boolean | undefined; + shareLink: string; }) => { return ( <> + + + Copy Edit Link + + } + smokerText="Link copied!" + id="get-link" + link={`/${props.shareLink}`} + /> + + +
{}}> - Archive{props.draft && " Draft"} + Archive{props.draft ? " Draft" : " Leaflet"} { @@ -161,11 +138,25 @@ const DefaultOptions = (props: { const PublishedPostOptions = (props: { setState: (s: "areYouSure") => void; document_uri: string; + leaflet: PermissionToken; + shareLink: string; }) => { let toaster = useToaster(); - let { mutate, data } = usePublicationData(); return ( <> + + + Copy Post Link + + } + smokerText="Link copied!" + id="get-link" + link={`/${props.shareLink}}`} + /> + +
{ if (props.document_uri) { @@ -203,7 +194,7 @@ const PublishedPostOptions = (props: { ); }; -const DeleteAreYouSure = (props: { +const DeleteAreYouSureForm = (props: { backToMenu: () => void; document_uri?: string; leaflet: PermissionToken; @@ -297,3 +288,42 @@ const AddTemplateForm = (props: { ); }; + +const TemplateOptions = (props: { + leaflet: PermissionToken; + isTemplate: boolean | undefined; + setState: (s: "template") => void; +}) => { + let smoker = useSmoker(); + if (props.isTemplate) + return ( + { + useTemplateState.getState().removeTemplate(props.leaflet); + let newLeafletButton = document.getElementById("new-leaflet-button"); + if (!newLeafletButton) return; + let rect = newLeafletButton.getBoundingClientRect(); + smoker({ + static: true, + text: Removed template!, + position: { + y: rect.top, + x: rect.right + 5, + }, + }); + }} + > + Remove from Templates + + ); + return ( + { + e.preventDefault(); + props.setState("template"); + }} + > + Use as Template + + ); +}; diff --git a/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx b/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx index 3d6108a4..8aaa4b7a 100644 --- a/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx +++ b/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx @@ -60,7 +60,7 @@ export function PublishedPostsList(props: { let postLink = data?.publication ? `${getPublicationURL(data?.publication)}/${new AtUri(doc.documents.uri).rkey}` - : null; + : ""; return ( diff --git a/components/HomeButton.tsx b/components/HomeButton.tsx index ec73e044..43cf2d3e 100644 --- a/components/HomeButton.tsx +++ b/components/HomeButton.tsx @@ -52,6 +52,7 @@ const AddToHomeButton = (props: {}) => { permission_token_on_homepage: [ ...identity.permission_token_on_homepage, { + archived: null, created_at: new Date().toISOString(), permission_tokens: { ...permission_token, diff --git a/components/Pages/PageShareMenu.tsx b/components/Pages/PageShareMenu.tsx index e4b37e7a..1ae183da 100644 --- a/components/Pages/PageShareMenu.tsx +++ b/components/Pages/PageShareMenu.tsx @@ -14,16 +14,14 @@ export const PageShareMenu = (props: { entityID: string }) => {
-
-
- {props.text} -
-
- {props.subtext} -
- {/* optional help text */} - {props.helptext && ( -
- {props.helptext} +
+ {props.text} + + {props.subtext && ( +
+ {props.subtext}
)}