From 7ffb7bf0ae2be8a5c8d8a500a3cf439fd7a8565b Mon Sep 17 00:00:00 2001 From: Edouard Vanbelle Date: Mon, 20 Jul 2026 01:21:48 +0200 Subject: [PATCH] feat(ui): add 'open parent directory' in recent and favorite section --- .../src/lib/components/ResourceList.svelte | 15 ++- frontend/src/lib/utils/folderAccess.ts | 96 +++++++++++++++++++ frontend/src/routes/favorites/+page.svelte | 35 +++++++ frontend/src/routes/recent/+page.svelte | 37 +++++++ 4 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 frontend/src/lib/utils/folderAccess.ts diff --git a/frontend/src/lib/components/ResourceList.svelte b/frontend/src/lib/components/ResourceList.svelte index cea00a9a..1b38da25 100644 --- a/frontend/src/lib/components/ResourceList.svelte +++ b/frontend/src/lib/components/ResourceList.svelte @@ -50,6 +50,16 @@ label: string; icon: string; danger?: boolean; + /** + * Optional per-item visibility gate. Called at menu-open time + * with the target item + context; return `false` to hide the + * entry for that row. Synchronous by contract — pages that need + * an async check (e.g. "does the caller have Read on the parent + * folder?") should pre-warm a cache when items load so the + * answer is already resolved by the time this runs. See + * `$lib/utils/folderAccess.ts` for the reference pattern. + */ + visible?: (item: FileItem | FolderItem, ctx?: ItemContext) => boolean; run: (item: FileItem | FolderItem, ctx?: ItemContext) => void; } @@ -1261,6 +1271,9 @@ {/snippet} {#if ctxOpen && ctxItem && contextActions} + {@const visibleActions = contextActions.filter( + (a) => a.visible?.(ctxItem!, ctxOf(ctxItem!.id)) !== false + )}