refac
This commit is contained in:
@@ -894,6 +894,28 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col w-full">
|
||||
<Tooltip
|
||||
className="flex w-full justify-between my-1"
|
||||
content={$i18n.t(
|
||||
'Warning: Enabling this will allow users to run scheduled prompts automatically.'
|
||||
)}
|
||||
placement="top-start"
|
||||
>
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Automations')}
|
||||
</div>
|
||||
<Switch bind:state={permissions.features.automations} />
|
||||
</Tooltip>
|
||||
{#if defaultPermissions?.features?.automations && !permissions.features.automations}
|
||||
<div>
|
||||
<div class="text-xs text-gray-500">
|
||||
{$i18n.t('This is a default user permission and will remain enabled.')}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class=" border-gray-100/30 dark:border-gray-850/30" />
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
import { showSettings, mobile, showSidebar, showShortcuts, user, config } from '$lib/stores';
|
||||
|
||||
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
@@ -214,6 +215,7 @@
|
||||
<div class=" self-center truncate">{$i18n.t('Settings')}</div>
|
||||
</button>
|
||||
|
||||
{#if $user?.role === 'admin' || $user?.permissions?.features?.automations}
|
||||
<a
|
||||
href="/automations"
|
||||
draggable="false"
|
||||
@@ -247,6 +249,7 @@
|
||||
</div>
|
||||
<div class="self-center truncate">{$i18n.t('Automations')}</div>
|
||||
</a>
|
||||
{/if}
|
||||
|
||||
<button
|
||||
class="flex rounded-xl py-1.5 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition cursor-pointer select-none"
|
||||
|
||||
@@ -60,7 +60,8 @@ export const DEFAULT_PERMISSIONS = {
|
||||
web_search: true,
|
||||
image_generation: true,
|
||||
code_interpreter: true,
|
||||
memories: true
|
||||
memories: true,
|
||||
automations: false
|
||||
},
|
||||
settings: {
|
||||
interface: true
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import { onMount, onDestroy, getContext } from 'svelte';
|
||||
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { WEBUI_NAME, mobile, showSidebar } from '$lib/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { WEBUI_NAME, mobile, showSidebar, user, config } from '$lib/stores';
|
||||
|
||||
import {
|
||||
getAutomationItems,
|
||||
@@ -165,6 +166,14 @@
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
if (
|
||||
$user?.role !== 'admin' &&
|
||||
!($user?.permissions?.features?.automations ?? false)
|
||||
) {
|
||||
goto('/');
|
||||
return;
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user