This commit is contained in:
Timothy Jaeryang Baek
2026-02-11 17:26:25 -06:00
parent 96c07f44a8
commit 97331bf11d
2 changed files with 96 additions and 85 deletions
+3 -4
View File
@@ -462,7 +462,7 @@
<div <div
class="flex transition rounded-2xl w-full p-2.5 {model.write_access class="flex transition rounded-2xl w-full p-2.5 {model.write_access
? 'cursor-pointer dark:hover:bg-gray-850/50 hover:bg-gray-50' ? 'cursor-pointer dark:hover:bg-gray-850/50 hover:bg-gray-50'
: 'cursor-not-allowed opacity-60'}" : 'dark:hover:bg-gray-850/50 hover:bg-gray-50'}"
id="model-item-{model.id}" id="model-item-{model.id}"
on:click={() => { on:click={() => {
if (model.write_access) { if (model.write_access) {
@@ -507,10 +507,9 @@
</div> </div>
{/if} {/if}
{#if model.write_access || $user?.role === 'admin'}
<div class="flex {model.is_active ? '' : 'text-gray-500'}"> <div class="flex {model.is_active ? '' : 'text-gray-500'}">
<div class="flex items-center gap-0.5"> <div class="flex items-center gap-0.5">
{#if shiftKey} {#if shiftKey && model.write_access}
<Tooltip <Tooltip
content={model?.meta?.hidden content={model?.meta?.hidden
? $i18n.t('Show') ? $i18n.t('Show')
@@ -548,6 +547,7 @@
<ModelMenu <ModelMenu
user={$user} user={$user}
{model} {model}
writeAccess={model.write_access}
editHandler={() => { editHandler={() => {
goto( goto(
`/workspace/models/edit?id=${encodeURIComponent(model.id)}` `/workspace/models/edit?id=${encodeURIComponent(model.id)}`
@@ -586,7 +586,6 @@
{/if} {/if}
</div> </div>
</div> </div>
{/if}
{#if model.write_access} {#if model.write_access}
<button <button
@@ -35,6 +35,8 @@
export let deleteHandler: Function; export let deleteHandler: Function;
export let onClose: Function; export let onClose: Function;
export let writeAccess: boolean = true;
let show = false; let show = false;
</script> </script>
@@ -65,6 +67,7 @@
align="start" align="start"
transition={flyAndScale} transition={flyAndScale}
> >
{#if writeAccess}
<DropdownMenu.Item <DropdownMenu.Item
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
on:click={() => { on:click={() => {
@@ -74,7 +77,9 @@
<Pencil /> <Pencil />
<div class="flex items-center">{$i18n.t('Edit')}</div> <div class="flex items-center">{$i18n.t('Edit')}</div>
</DropdownMenu.Item> </DropdownMenu.Item>
{/if}
{#if writeAccess}
<DropdownMenu.Item <DropdownMenu.Item
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
on:click={() => { on:click={() => {
@@ -126,6 +131,7 @@
{/if} {/if}
</div> </div>
</DropdownMenu.Item> </DropdownMenu.Item>
{/if}
<DropdownMenu.Item <DropdownMenu.Item
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
@@ -148,6 +154,7 @@
</div> </div>
</DropdownMenu.Item> </DropdownMenu.Item>
{#if writeAccess}
<DropdownMenu.Item <DropdownMenu.Item
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
on:click={() => { on:click={() => {
@@ -158,8 +165,11 @@
<div class="flex items-center">{$i18n.t('Clone')}</div> <div class="flex items-center">{$i18n.t('Clone')}</div>
</DropdownMenu.Item> </DropdownMenu.Item>
{/if}
{#if writeAccess}
<hr class="border-gray-50/30 dark:border-gray-800/30 my-1" /> <hr class="border-gray-50/30 dark:border-gray-800/30 my-1" />
{/if}
<DropdownMenu.Item <DropdownMenu.Item
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
@@ -172,7 +182,7 @@
<div class="flex items-center">{$i18n.t('Copy Link')}</div> <div class="flex items-center">{$i18n.t('Copy Link')}</div>
</DropdownMenu.Item> </DropdownMenu.Item>
{#if $currentUser?.role === 'admin' || $currentUser?.permissions?.workspace?.models_export} {#if writeAccess && ($currentUser?.role === 'admin' || $currentUser?.permissions?.workspace?.models_export)}
<DropdownMenu.Item <DropdownMenu.Item
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
on:click={() => { on:click={() => {
@@ -185,7 +195,7 @@
</DropdownMenu.Item> </DropdownMenu.Item>
{/if} {/if}
{#if $config?.features.enable_community_sharing} {#if writeAccess && $config?.features.enable_community_sharing}
<DropdownMenu.Item <DropdownMenu.Item
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
on:click={() => { on:click={() => {
@@ -197,6 +207,7 @@
</DropdownMenu.Item> </DropdownMenu.Item>
{/if} {/if}
{#if writeAccess}
<hr class="border-gray-50/30 dark:border-gray-800/30 my-1" /> <hr class="border-gray-50/30 dark:border-gray-800/30 my-1" />
<DropdownMenu.Item <DropdownMenu.Item
@@ -208,6 +219,7 @@
<GarbageBin /> <GarbageBin />
<div class="flex items-center">{$i18n.t('Delete')}</div> <div class="flex items-center">{$i18n.t('Delete')}</div>
</DropdownMenu.Item> </DropdownMenu.Item>
{/if}
</DropdownMenu.Content> </DropdownMenu.Content>
</div> </div>
</Dropdown> </Dropdown>