a tool for shared writing and social publishing

filter draft and post lists in pub dashboard to contributor

+48 -27
+4 -2
app/lish/[did]/[publication]/dashboard/Actions.tsx
··· 12 12 import { useIsMobile } from "src/hooks/isMobile"; 13 13 import { SpeedyLink } from "components/SpeedyLink"; 14 14 15 - export const Actions = (props: { publication: string }) => { 15 + export const Actions = (props: { publication: string; isOwner: boolean }) => { 16 16 return ( 17 17 <> 18 18 <NewDraftActionButton publication={props.publication} /> 19 19 <PublicationShareButton /> 20 - <PublicationSettingsButton publication={props.publication} /> 20 + {props.isOwner && ( 21 + <PublicationSettingsButton publication={props.publication} /> 22 + )} 21 23 </> 22 24 ); 23 25 };
+15 -1
app/lish/[did]/[publication]/dashboard/DraftList.tsx
··· 4 4 import React from "react"; 5 5 import { usePublicationData } from "./PublicationSWRProvider"; 6 6 import { LeafletList } from "app/(home-pages)/home/HomeLayout"; 7 + import { useIdentityData } from "components/IdentityProvider"; 7 8 8 9 export function DraftList(props: { 9 10 searchValue: string; 10 11 showPageBackground: boolean; 12 + isOwner: boolean; 11 13 }) { 14 + let identity = useIdentityData(); 15 + let userLeaflets = identity.identity?.permission_token_on_homepage 16 + .flatMap((leaflet) => leaflet.permission_tokens.leaflets_in_publications) 17 + .map((leaflet) => leaflet.doc); 18 + 12 19 let { data: pub_data } = usePublicationData(); 13 20 if (!pub_data?.publication) return null; 14 21 let { leaflets_in_publications, ...publication } = pub_data.publication; 22 + 15 23 return ( 16 24 <div className="flex flex-col gap-4"> 17 25 <NewDraftSecondaryButton ··· 25 33 defaultDisplay="list" 26 34 cardBorderHidden={!props.showPageBackground} 27 35 leaflets={leaflets_in_publications 28 - .filter((l) => !l.documents) 36 + .filter((l) => { 37 + if (l.documents) return false; 38 + if (!props.isOwner) { 39 + return !!userLeaflets?.includes(l.doc); 40 + } 41 + return true; 42 + }) 29 43 .map((l) => { 30 44 return { 31 45 token: {
+18 -9
app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx
··· 14 14 PublicationDashboardControls, 15 15 } from "components/PageLayouts/DashboardLayout"; 16 16 import { useDebouncedEffect } from "src/hooks/useDebouncedEffect"; 17 + import { getIdentityData } from "actions/getIdentityData"; 17 18 18 19 export default function PublicationDashboard({ 19 20 publication, ··· 36 37 [searchValue], 37 38 ); 38 39 40 + let isOwner = false; 41 + 39 42 return ( 40 43 <DashboardLayout 41 44 id={publication.uri} ··· 47 50 <DraftList 48 51 searchValue={debouncedSearchValue} 49 52 showPageBackground={!!record.theme?.showPageBackground} 53 + isOwner={isOwner} 50 54 /> 51 55 ), 52 56 controls: ( ··· 63 67 <PublishedPostsList 64 68 searchValue={debouncedSearchValue} 65 69 showPageBackground={!!record.theme?.showPageBackground} 70 + isOwner={isOwner} 66 71 /> 67 72 ), 68 73 controls: null, 69 74 }, 70 - Subscribers: { 71 - content: ( 72 - <PublicationSubscribers 73 - showPageBackground={!!record.theme?.showPageBackground} 74 - /> 75 - ), 76 - controls: null, 77 - }, 75 + ...(isOwner 76 + ? { 77 + Subscribers: { 78 + content: ( 79 + <PublicationSubscribers 80 + showPageBackground={!!record.theme?.showPageBackground} 81 + /> 82 + ), 83 + controls: null, 84 + }, 85 + } 86 + : {}), 78 87 }} 79 - actions={<Actions publication={publication.uri} />} 88 + actions={<Actions publication={publication.uri} isOwner={isOwner} />} 80 89 currentPage="pub" 81 90 publication={publication.uri} 82 91 />
+11 -12
app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx
··· 18 18 import { QuoteTiny } from "components/Icons/QuoteTiny"; 19 19 import { CommentTiny } from "components/Icons/CommentTiny"; 20 20 import { useLocalizedDate } from "src/hooks/useLocalizedDate"; 21 + import { useIdentityData } from "components/IdentityProvider"; 21 22 22 23 export function PublishedPostsList(props: { 23 24 searchValue: string; 24 25 showPageBackground: boolean; 26 + isOwner: boolean; 25 27 }) { 26 28 let { data } = usePublicationData(); 27 - let params = useParams(); 29 + let identity = useIdentityData(); 28 30 let { publication } = data!; 29 31 if (!publication) return null; 30 32 if (publication.documents_in_publications.length === 0) ··· 56 58 let record = doc.documents.data as PubLeafletDocument.Record; 57 59 let quotes = doc.documents.document_mentions_in_bsky[0]?.count || 0; 58 60 let comments = doc.documents.comments_on_documents[0]?.count || 0; 59 - 61 + let isAuthor = record.author === identity.identity?.atp_did; 60 62 return ( 61 63 <Fragment key={doc.documents?.uri}> 62 64 <div className="flex gap-2 w-full "> ··· 78 80 {record.title} 79 81 </h3> 80 82 </a> 81 - <div className="flex justify-start align-top flex-row gap-1"> 82 - {leaflet && ( 83 + {leaflet && (isAuthor || props.isOwner) && ( 84 + <div className="flex justify-start align-top flex-row gap-1"> 83 85 <SpeedyLink 84 86 className="pt-[6px]" 85 87 href={`/${leaflet.leaflet}`} 86 88 > 87 89 <EditTiny /> 88 90 </SpeedyLink> 89 - )} 90 - <Options document_uri={doc.documents.uri} /> 91 - </div> 91 + 92 + <Options document_uri={doc.documents.uri} /> 93 + </div> 94 + )} 92 95 </div> 93 96 94 97 {record.description ? ( ··· 237 240 day: "2-digit", 238 241 }); 239 242 240 - return ( 241 - <p className="text-sm text-tertiary"> 242 - Published {formattedDate} 243 - </p> 244 - ); 243 + return <p className="text-sm text-tertiary">Published {formattedDate}</p>; 245 244 }
-3
app/lish/[did]/[publication]/invite-contributor/page.tsx
··· 1 - import { BskyAgent } from "@atproto/api"; 2 1 import { AtUri } from "@atproto/syntax"; 3 2 import { 4 3 PublicationThemeProvider, ··· 7 6 import { PubLeafletPublication } from "lexicons/api"; 8 7 import { supabaseServerClient } from "supabase/serverClient"; 9 8 import { ButtonPrimary } from "components/Buttons"; 10 - import { PubContributorEmptyIllo } from "../dashboard/publicationSettings/PublicationContributors"; 11 9 import { PubNotFound } from "../PubNotFound"; 12 10 import { PubIcon } from "components/ActionBar/Publications"; 13 - import { PubListing } from "app/(home-pages)/discover/PubListing"; 14 11 import { SpeedyLink } from "components/SpeedyLink"; 15 12 import { BlueskyLogin } from "app/login/LoginForm"; 16 13 import { getIdentityData } from "actions/getIdentityData";