enh: file upload permission indicator

This commit is contained in:
Timothy Jaeryang Baek 2025-01-26 23:30:46 -08:00
parent 6f3c92f6d5
commit 6eb51ab62e

View File

@ -48,6 +48,9 @@
init(); init();
} }
let fileUploadEnabled = true;
$: fileUploadEnabled = $user.role === 'admin' || $user?.permissions?.chat?.file_upload;
const init = async () => { const init = async () => {
if ($_tools === null) { if ($_tools === null) {
await _tools.set(await getTools(localStorage.token)); await _tools.set(await getTools(localStorage.token));
@ -166,26 +169,44 @@
{/if} {/if}
{#if !$mobile} {#if !$mobile}
<DropdownMenu.Item <Tooltip
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" content={!fileUploadEnabled ? $i18n.t('You do not have permission to upload files') : ''}
on:click={() => { className="w-full"
screenCaptureHandler();
}}
> >
<CameraSolid /> <DropdownMenu.Item
<div class=" line-clamp-1">{$i18n.t('Capture')}</div> class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl {!fileUploadEnabled
</DropdownMenu.Item> ? 'opacity-50'
: ''}"
on:click={() => {
if (fileUploadEnabled) {
screenCaptureHandler();
}
}}
>
<CameraSolid />
<div class=" line-clamp-1">{$i18n.t('Capture')}</div>
</DropdownMenu.Item>
</Tooltip>
{/if} {/if}
<DropdownMenu.Item <Tooltip
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl" content={!fileUploadEnabled ? $i18n.t('You do not have permission to upload files') : ''}
on:click={() => { className="w-full"
uploadFilesHandler();
}}
> >
<DocumentArrowUpSolid /> <DropdownMenu.Item
<div class="line-clamp-1">{$i18n.t('Upload Files')}</div> class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl {!fileUploadEnabled
</DropdownMenu.Item> ? 'opacity-50'
: ''}"
on:click={() => {
if (fileUploadEnabled) {
uploadFilesHandler();
}
}}
>
<DocumentArrowUpSolid />
<div class="line-clamp-1">{$i18n.t('Upload Files')}</div>
</DropdownMenu.Item>
</Tooltip>
{#if $config?.features?.enable_google_drive_integration} {#if $config?.features?.enable_google_drive_integration}
<DropdownMenu.Item <DropdownMenu.Item