瀏覽代碼

refac: move functions (plugin) to admin panel

Timothy Jaeryang Baek 5 月之前
父節點
當前提交
947444949a

+ 6 - 7
src/lib/components/workspace/Functions.svelte → src/lib/components/admin/Functions.svelte

@@ -5,7 +5,6 @@
 
 	import { WEBUI_NAME, config, functions, models } from '$lib/stores';
 	import { onMount, getContext, tick } from 'svelte';
-	import { createNewPrompt, deletePromptByCommand, getPrompts } from '$lib/apis/prompts';
 
 	import { goto } from '$app/navigation';
 	import {
@@ -25,8 +24,8 @@
 	import FunctionMenu from './Functions/FunctionMenu.svelte';
 	import EllipsisHorizontal from '../icons/EllipsisHorizontal.svelte';
 	import Switch from '../common/Switch.svelte';
-	import ValvesModal from './common/ValvesModal.svelte';
-	import ManifestModal from './common/ManifestModal.svelte';
+	import ValvesModal from '../workspace/common/ValvesModal.svelte';
+	import ManifestModal from '../workspace/common/ManifestModal.svelte';
 	import Heart from '../icons/Heart.svelte';
 	import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
 	import GarbageBin from '../icons/GarbageBin.svelte';
@@ -98,7 +97,7 @@
 				id: `${_function.id}_clone`,
 				name: `${_function.name} (Clone)`
 			});
-			goto('/workspace/functions/create');
+			goto('/admin/functions/create');
 		}
 	};
 
@@ -210,7 +209,7 @@
 		<div>
 			<a
 				class=" px-2 py-2 rounded-xl hover:bg-gray-700/10 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition font-medium text-sm flex items-center space-x-1"
-				href="/workspace/functions/create"
+				href="/admin/functions/create"
 			>
 				<Plus className="size-3.5" />
 			</a>
@@ -225,7 +224,7 @@
 		>
 			<a
 				class=" flex flex-1 space-x-3.5 cursor-pointer w-full"
-				href={`/workspace/functions/edit?id=${encodeURIComponent(func.id)}`}
+				href={`/admin/functions/edit?id=${encodeURIComponent(func.id)}`}
 			>
 				<div class="flex items-center text-left">
 					<div class=" flex-1 self-center pl-1">
@@ -322,7 +321,7 @@
 					<FunctionMenu
 						{func}
 						editHandler={() => {
-							goto(`/workspace/functions/edit?id=${encodeURIComponent(func.id)}`);
+							goto(`/admin/functions/edit?id=${encodeURIComponent(func.id)}`);
 						}}
 						shareHandler={() => {
 							shareHandler(func);

+ 1 - 1
src/lib/components/workspace/Functions/FunctionEditor.svelte → src/lib/components/admin/Functions/FunctionEditor.svelte

@@ -305,7 +305,7 @@ class Pipe:
 								<button
 									class="w-full text-left text-sm py-1.5 px-1 rounded-lg dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-gray-850"
 									on:click={() => {
-										goto('/workspace/functions');
+										goto('/admin/functions');
 									}}
 									type="button"
 								>

+ 0 - 0
src/lib/components/workspace/Functions/FunctionMenu.svelte → src/lib/components/admin/Functions/FunctionMenu.svelte


+ 0 - 6
src/lib/components/workspace/Tools.svelte

@@ -323,12 +323,6 @@
 	{/each}
 </div>
 
-<div class=" text-gray-500 text-xs mt-1 mb-2">
-	ⓘ {$i18n.t(
-		'Admins have access to all tools at all times; users need tools assigned per model in the workspace.'
-	)}
-</div>
-
 <div class=" flex justify-end w-full mb-2">
 	<div class="flex space-x-2">
 		<input

+ 7 - 0
src/routes/(app)/admin/+layout.svelte

@@ -65,6 +65,13 @@
 							href="/admin/evaluations">{$i18n.t('Evaluations')}</a
 						>
 
+						<a
+							class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/admin/functions')
+								? ''
+								: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
+							href="/admin/functions">{$i18n.t('Functions')}</a
+						>
+
 						<a
 							class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/admin/settings')
 								? ''

+ 1 - 1
src/routes/(app)/workspace/functions/+page.svelte → src/routes/(app)/admin/functions/+page.svelte

@@ -3,7 +3,7 @@
 	import { functions } from '$lib/stores';
 
 	import { getFunctions } from '$lib/apis/functions';
-	import Functions from '$lib/components/workspace/Functions.svelte';
+	import Functions from '$lib/components/admin/Functions.svelte';
 
 	onMount(async () => {
 		await Promise.all([

+ 1 - 1
src/routes/(app)/workspace/functions/create/+page.svelte → src/routes/(app)/admin/functions/create/+page.svelte

@@ -5,7 +5,7 @@
 
 	import { functions, models } from '$lib/stores';
 	import { createNewFunction, getFunctions } from '$lib/apis/functions';
-	import FunctionEditor from '$lib/components/workspace/Functions/FunctionEditor.svelte';
+	import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
 	import { getModels } from '$lib/apis';
 	import { compareVersion, extractFrontmatter } from '$lib/utils';
 	import { WEBUI_VERSION } from '$lib/constants';

+ 1 - 1
src/routes/(app)/workspace/functions/edit/+page.svelte → src/routes/(app)/admin/functions/edit/+page.svelte

@@ -7,7 +7,7 @@
 	import { functions, models } from '$lib/stores';
 	import { updateFunctionById, getFunctions, getFunctionById } from '$lib/apis/functions';
 
-	import FunctionEditor from '$lib/components/workspace/Functions/FunctionEditor.svelte';
+	import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
 	import Spinner from '$lib/components/common/Spinner.svelte';
 	import { getModels } from '$lib/apis';
 	import { compareVersion, extractFrontmatter } from '$lib/utils';

+ 8 - 21
src/routes/(app)/workspace/+layout.svelte

@@ -82,27 +82,14 @@
 							href="/workspace/prompts">{$i18n.t('Prompts')}</a
 						>
 
-						{#if $user?.role === 'admin'}
-							<a
-								class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/workspace/tools')
-									? ''
-									: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
-								href="/workspace/tools"
-							>
-								{$i18n.t('Tools')}
-							</a>
-
-							<a
-								class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes(
-									'/workspace/functions'
-								)
-									? ''
-									: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
-								href="/workspace/functions"
-							>
-								{$i18n.t('Functions')}
-							</a>
-						{/if}
+						<a
+							class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/workspace/tools')
+								? ''
+								: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
+							href="/workspace/tools"
+						>
+							{$i18n.t('Tools')}
+						</a>
 					</div>
 				</div>