library: source right panel by ownership and edit before a library exsts#141
Conversation
…ists Decide the Sidebar panel by whether the viewed library is mine: my own shows my account identity and is editable, anyone else's (or logged out) shows that library's public data only. Ownership now matches the loaded owner's account id/username, and stale owner data is dropped on navigation so my identity never bleeds onto someone else's page. Let a permitted owner edit their About panel before any library row exists — the row is bootstrapped lazily on first save (like adding the first shelf), and the page reloads by direct id instead of the restricted owner relation-filter. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner-only flow to mint a share link for a curated set of public-shelf objects: a context-backed selection (one link spans the whole library, capped at 21 objects), a Select chip on the cards, a ShareSelectionPanel to reorder/remove/clear, and a SharedWithYou modal for the recipient. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the single `[username].tsx` page with an optional catch-all so `/library/[username]` and `/library/[username]/[slug]` share one module. The opened object is addressed by the URL (slugified title + id), and open/close are shallow `router.push` transitions so the overview modal appears over the already-loaded library with no refetch or remount. The shelf that actually holds the object resolves it from the slug's trailing id, keeping its real shelf context. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
`/library/[username]/share/[token]` is a literal sibling of the object catch-all (and wins for that path). It resolves the token via getShareLink and renders the curated objects in the SharedWithYou view. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The dropdown sourced options from a global `/single-shelves` fetch, so it offered every user's public shelves (and the backend then 403s the move). Drive it from the viewed library's own shelves (currentShelves in GlobalState), filtered to the object's type, and exclude the object's current shelf — falling back to defaultShelfId since a PUT response doesn't populate the shelf relation. Disable the dropdown when no eligible shelf remains. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@claude, review this PR. |
|
Claude finished @MaryWylde's task in 3m 8s —— View job PR Review — library: source right panel by ownership and edit before a library existsTasks
SummarySolid, well-scoped PR. The ownership model is clearly reasoned, the lazy-bootstrap pattern is clean, and the share-link architecture (discriminated-union status, reused panel component for owner vs. recipient) is good design. One item must be removed before merge; a few things are worth addressing. Must FixDebug effect left in Sidebar — // TEMP DEBUG: verify whether the authenticated `filters[user][id]` relation
// query actually resolves the owner's library in the browser...
useEffect(() => {
if (!accountData?.id) {
console.log('[myLibrary debug] no accountData.id yet', { accountData });
return;
}
getMyLibrary(accountData.id).then(lib => {
console.log('[myLibrary debug] getMyLibrary result', { ... });
});
}, [accountData?.id, accountData?.username, accountData]);The comment says "Remove once the backend exposes ImportantNew utilities placed in
Stale selection when a shelf changes to private In Minor / SuggestionsTwo independent ownership checks that could diverge
const currentLibraryId = pathname?.split('/').pop() || '';On the share route currentLibraryId.toLowerCase() === viewerUsername…which compares the token against the username. The match will nearly always be "Select shelf" button is a no-op — <Button
label="Select shelf"
ariaLabel="Select shelf"
onClick={() => {}}
...
/>This button is visible to all users (owner and visitor alike) but does nothing. If the feature isn't ready, either hide it behind
The page handlers extract only URL params from
Both files carry What's Good
|
`currentLibraryId` was the last path segment of asPath, which on the new object (`/[slug]`) and share (`/share/[token]`) routes is the slug/token, not the username — breaking the sidebar's share-library URL and the ownership fallback. Read `[username]` from the router params instead. Also remove the temporary getMyLibrary debug effect that logged account data and fired an extra request on every authenticated page load. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Wire the previously no-op "Select shelf" button to bulk-toggle the whole shelf into the share selection (new selectMany/removeMany context helpers, capped at 21). It's owner- and public-only like the per-card chip, and disabled when the shelf is empty or at the cap. Switching a shelf to private now strips its objects from the selection, so a link is never minted with objects the backend would reject. Also relocate the new objectSlug/mapSharedObject utils from the legacy src/utils tree to src/lib per AGENTS.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Decide the Sidebar panel by whether the viewed library is mine: my own shows my account identity and is editable, anyone else's (or logged out) shows that library's public data only. Ownership now matches the loaded owner's account id/username, and stale owner data is dropped on navigation so my identity never bleeds onto someone else's page.
Let a permitted owner edit their About panel before any library row exists — the row is bootstrapped lazily on first save (like adding the first shelf), and the page reloads by direct id instead of the restricted owner relation-filter.