diff --git a/src/components/explore/CollectionExplorer.tsx b/src/components/explore/CollectionExplorer.tsx index 80ad498..1bcbec6 100644 --- a/src/components/explore/CollectionExplorer.tsx +++ b/src/components/explore/CollectionExplorer.tsx @@ -16,6 +16,7 @@ import { import AppearIn from './AppearIn'; import Breadcrumb from './Breadcrumb'; import NotFoundPanel from '@/components/NotFoundPanel'; +import SignInPanel from './SignInPanel'; import { useAtprotoSession } from '@/components/AtprotoSessionProvider'; type Props = { @@ -91,23 +92,30 @@ function CollectionList({ collection: string; }) { const router = useRouter(); - const { agent, did: signedInDid } = useAtprotoSession(); + const { agent, did: signedInDid, session, loading: sessionLoading } = useAtprotoSession(); const [records, setRecords] = useState([]); const [cursor, setCursor] = useState(undefined); const [done, setDone] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [live, setLive] = useState(false); - - // Selection / bulk-delete mode. Records can only be deleted from your own - // repository, so the whole affordance is gated on the signed-in user owning - // this repo — mirrors how the single-record view gates its "Edit record". - const canEdit = Boolean(agent && signedInDid && signedInDid === identity.did); const [editing, setEditing] = useState(false); const [selected, setSelected] = useState>(new Set()); const [confirmingDelete, setConfirmingDelete] = useState(false); const [deleting, setDeleting] = useState(false); const [deleteError, setDeleteError] = useState(null); + const [signInOpen, setSignInOpen] = useState(false); + + // Records can only be deleted from your own repository, so selection mode is + // gated on the signed-in user owning this repo. The Edit button itself is + // also offered to logged-out visitors though: pressing it reveals a sign-in + // prompt prefilled with this repo's handle (mirrors the record page) so the + // owner can sign in and start managing in two clicks. We hide it only from + // someone signed in as a *different* account — they can't edit here. + const canEdit = Boolean(agent && signedInDid && signedInDid === identity.did); + const loggedOut = !session && !sessionLoading; + const showEditButton = canEdit || loggedOut; + const editActive = editing || signInOpen; const loadPage = useCallback( async (after: string | undefined) => { @@ -271,23 +279,37 @@ function CollectionList({
- {canEdit && ( + {showEditButton && (
)} + {signInOpen && !session && ( +
+

+ Sign in as{' '} + {identity.handle ? `@${identity.handle}` : identity.did} to + select and delete your own records. +

+ +
+ )} {editing && deleteError && (

{deleteError}