fix: access button shows while sharing is not allowed (#32979)

The Access button in the model, prompt, tool, knowledge, skill and note editors, the Access entry in their list menus and the Access button in folder settings showed to users without the matching sharing permission. The dialog then had nothing they could change. The button and the menu entry now only show to users who may share that kind of item, and admins see them as before.

Refs #32830
This commit is contained in:
Classic298 2026-10-23 03:58:17 +02:00 • committed by GitHub
parent 35ee76cebb
commit ac12b04aad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 55 additions and 28 deletions

View file

@ -137,7 +137,7 @@
{/if}
</div>
<div class="flex items-center gap-1">
{#if edit && folder && ($user?.role === 'admin' || folder.user_id === $user?.id)}
{#if edit && folder && ($user?.role === 'admin' || (folder.user_id === $user?.id && $user?.permissions?.sharing?.folders))}
<AccessButton disabled={loading} on:click={() => (showAccessModal = true)} />
{/if}
<button

View file

@ -1272,14 +1272,16 @@ ${content}
</NoteMenu>
{#if note?.write_access}
<div class="ml-1.5">
<AccessButton
on:click={() => {
showAccessControlModal = true;
}}
disabled={note?.user_id !== $user?.id && $user?.role !== 'admin'}
/>
</div>
{#if $user?.permissions?.sharing?.notes || $user?.role === 'admin'}
<div class="ml-1.5">
<AccessButton
on:click={() => {
showAccessControlModal = true;
}}
disabled={note?.user_id !== $user?.id && $user?.role !== 'admin'}
/>
</div>
{/if}
{:else}
<div class="shrink-0 text-xs text-gray-500 px-2 py-1">
{$i18n.t('Read-Only Access')}

View file

@ -681,7 +681,9 @@
</Tooltip>
{:else}
<NoteMenu
onAccess={note.user_id === $user?.id || $user?.role === 'admin'
onAccess={(note.user_id === $user?.id &&
$user?.permissions?.sharing?.notes) ||
$user?.role === 'admin'
? () => accessModal.open(note.id)
: null}
show={openNoteMenuId === note.id}
@ -772,7 +774,9 @@
</Tooltip>
{:else}
<NoteMenu
onAccess={note.user_id === $user?.id || $user?.role === 'admin'
onAccess={(note.user_id === $user?.id &&
$user?.permissions?.sharing?.notes) ||
$user?.role === 'admin'
? () => accessModal.open(note.id)
: null}
onDownload={(type) => {

View file

@ -536,7 +536,10 @@
{#if item?.write_access || $user?.role === 'admin'}
<div class="ml-2 flex shrink-0 flex-row items-center self-center">
<ItemMenu
accessHandler={() => accessModal.open(item.id)}
accessHandler={$user?.permissions?.sharing?.knowledge ||
$user?.role === 'admin'
? () => accessModal.open(item.id)
: null}
onExport={$user?.role === 'admin'
? () => {
exportHandler(item);

View file

@ -873,9 +873,9 @@
><ChevronLeft className="size-3" strokeWidth="2" />{$i18n.t('Back')}</button
>
<!-- Previous file count label: {$i18n.t('{{COUNT}} files')} -->
{#if knowledge.write_access}<AccessButton
on:click={() => (showAccessControlModal = true)}
/>{:else}<span class="text-xs text-gray-500">{$i18n.t('Read Only')}</span>{/if}
{#if knowledge.write_access}{#if $user?.permissions?.sharing?.knowledge || $user?.role === 'admin'}<AccessButton
on:click={() => (showAccessControlModal = true)}
/>{/if}{:else}<span class="text-xs text-gray-500">{$i18n.t('Read Only')}</span>{/if}
</div>
<div class="shrink-0 px-1 pb-2.5">
<input

View file

@ -940,7 +940,10 @@
{:else}
<div class="flex shrink-0 flex-row items-center gap-1 self-center">
<ModelMenu
accessHandler={() => accessModal.open(model.id)}
accessHandler={$user?.permissions?.sharing?.models ||
$user?.role === 'admin'
? () => accessModal.open(model.id)
: null}
user={$user}
{model}
writeAccess={model.write_access}

View file

@ -871,7 +871,9 @@
{translatedLocales}
className="w-fit"
/>
<AccessButton on:click={() => (showAccessControlModal = true)} />
{#if $user?.permissions?.sharing?.models || $user?.role === 'admin'}
<AccessButton on:click={() => (showAccessControlModal = true)} />
{/if}
</div>
{/if}
</div>

View file

@ -701,7 +701,9 @@
<div class="ml-0.5 flex shrink-0 flex-row items-center gap-1.5 self-center">
<PromptMenu
accessHandler={() => accessModal.open(prompt.id)}
accessHandler={$user?.permissions?.sharing?.prompts || $user?.role === 'admin'
? () => accessModal.open(prompt.id)
: null}
writeAccess={prompt.write_access}
show={openPromptMenuId === prompt.id}
editHandler={() => {

View file

@ -458,7 +458,9 @@
</button>
{/if}
<div class="flex shrink-0 items-center gap-1 pr-0.5">
{#if !disabled}<AccessButton on:click={() => (showAccessControlModal = true)} />
{#if !disabled}{#if $user?.permissions?.sharing?.prompts || $user?.role === 'admin'}<AccessButton
on:click={() => (showAccessControlModal = true)}
/>{/if}
{:else}<span class="px-2 py-1 text-xs text-gray-500">{$i18n.t('Read Only')}</span>{/if}
{#if modal}<button
type="button"

View file

@ -607,7 +607,10 @@
<div class="flex shrink-0 flex-row items-center gap-1.5 self-center">
<SkillMenu
shareHandler={() => shareHandler(skill)}
accessHandler={() => accessModal.open(skill.id)}
accessHandler={$user?.permissions?.sharing?.skills ||
$user?.role === 'admin'
? () => accessModal.open(skill.id)
: null}
show={openSkillMenuId === skill.id}
editHandler={() => {
goto(`/workspace/skills/edit?id=${encodeURIComponent(skill.id)}`);

View file

@ -358,7 +358,9 @@
<div class="flex shrink-0 items-center gap-1 pr-0.5">
<LanguageModeSelect bind:value={locale} translatedLocales={Object.keys(meta.i18n ?? {})} />
{#if !disabled}
<AccessButton on:click={() => (showAccessControlModal = true)} />
{#if $user?.permissions?.sharing?.skills || $user?.role === 'admin'}
<AccessButton on:click={() => (showAccessControlModal = true)} />
{/if}
{:else}
<span class="rounded-lg bg-gray-100 px-2 py-1 text-xs text-gray-500 dark:bg-gray-850">
{$i18n.t('Read Only')}

View file

@ -599,7 +599,9 @@
</Tooltip>
<ToolMenu
accessHandler={() => accessModal.open(tool.id)}
accessHandler={$user?.permissions?.sharing?.tools || $user?.role === 'admin'
? () => accessModal.open(tool.id)
: null}
show={openToolMenuId === tool.id}
editHandler={() => {
goto(`/workspace/tools/edit?id=${encodeURIComponent(tool.id)}`);

View file

@ -353,12 +353,14 @@ class Tools:
pruneEmptyLocaleEntries(selected ? selected.snapshot.meta.i18n : meta.i18n)
)}
/>
<AccessButton
disabled={!!selected || loading || selecting || promoting}
on:click={() => {
showAccessControlModal = true;
}}
/>
{#if $user?.permissions?.sharing?.tools || $user?.role === 'admin'}
<AccessButton
disabled={!!selected || loading || selecting || promoting}
on:click={() => {
showAccessControlModal = true;
}}
/>
{/if}
</div>
</div>