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 + )}