mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-03 18:17:56 -05:00
refac
This commit is contained in:
1 parent
b52bcff605
commit
e6a8dd052d
17 files changed
+3003
-3064
No files matched your search
@@ -20,7 +20,7 @@
|
||||
import type { i18n as i18nType } from 'i18next';
|
||||
|
||||
const i18n = getContext<Writable<i18nType>>('i18n');
|
||||
const { workspaceActions, workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
const { workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
|
||||
import { WEBUI_NAME, user } from '$lib/stores';
|
||||
import {
|
||||
@@ -41,11 +41,11 @@
|
||||
import Search from '../icons/Search.svelte';
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import SplitCreateButton from '$lib/components/common/SplitCreateButton.svelte';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import ProfileImage from '$lib/components/chat/Messages/ProfileImage.svelte';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
import ViewSelector from './common/ViewSelector.svelte';
|
||||
import TagSelector from './common/TagSelector.svelte';
|
||||
import Loader from '../common/Loader.svelte';
|
||||
|
||||
type KnowledgeListItem = {
|
||||
@@ -68,7 +68,6 @@
|
||||
let loaded = false;
|
||||
let showDeleteConfirm = false;
|
||||
let showCreateModal = false;
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
|
||||
let selectedItem: KnowledgeListItem | null = null;
|
||||
|
||||
@@ -89,17 +88,15 @@
|
||||
let allItemsLoaded = false;
|
||||
let itemsLoading = false;
|
||||
|
||||
$: if (loaded) {
|
||||
workspaceActions.set([
|
||||
{
|
||||
id: 'knowledge-new',
|
||||
label: $i18n.t('Create'),
|
||||
onClick: () => {
|
||||
showCreateModal = true;
|
||||
}
|
||||
$: createActions = [
|
||||
{
|
||||
id: 'knowledge-new',
|
||||
label: $i18n.t('Create'),
|
||||
onClick: () => {
|
||||
showCreateModal = true;
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const handleSearchInput = () => {
|
||||
searchController?.abort();
|
||||
@@ -364,43 +361,36 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex max-w-[55%] shrink-0 overflow-x-auto scrollbar-none"
|
||||
bind:this={tagsContainerElement}
|
||||
on:wheel={(e) => {
|
||||
if (e.deltaY !== 0) {
|
||||
e.preventDefault();
|
||||
e.currentTarget.scrollLeft += e.deltaY;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="flex w-fit gap-0.5 text-center text-sm rounded-full bg-transparent whitespace-nowrap"
|
||||
>
|
||||
<ViewSelector
|
||||
bind:value={viewOption}
|
||||
align="end"
|
||||
onChange={async (value) => {
|
||||
localStorage.workspaceViewOption = value;
|
||||
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
|
||||
<TagSelector
|
||||
bind:value={sourceOption}
|
||||
align="end"
|
||||
placeholder={$i18n.t('All Sources')}
|
||||
items={[
|
||||
{ value: 'local', label: $i18n.t('Local') },
|
||||
{ value: 'external', label: $i18n.t('Connected') }
|
||||
]}
|
||||
onChange={async () => {
|
||||
localStorage.workspaceKnowledgeSourceOption = sourceOption;
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('Owner'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'created', label: $i18n.t('Created by you') },
|
||||
{ value: 'shared', label: $i18n.t('Shared with you') }
|
||||
],
|
||||
onChange: (value) => {
|
||||
viewOption = value;
|
||||
localStorage.workspaceViewOption = value;
|
||||
}
|
||||
},
|
||||
{
|
||||
label: $i18n.t('Source'),
|
||||
value: sourceOption,
|
||||
items: [
|
||||
{ value: 'local', label: $i18n.t('Local') },
|
||||
{ value: 'external', label: $i18n.t('Connected') }
|
||||
],
|
||||
onChange: (value) => {
|
||||
sourceOption = value;
|
||||
localStorage.workspaceKnowledgeSourceOption = value;
|
||||
}
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<SplitCreateButton actions={createActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||
|
||||
const i18n = getContext<any>('i18n');
|
||||
const { workspaceActions, workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
const { workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
import {
|
||||
@@ -61,6 +61,8 @@
|
||||
import ModelMenu from './Models/ModelMenu.svelte';
|
||||
import ModelDeleteConfirmDialog from '../common/ConfirmDialog.svelte';
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import SplitCreateButton from '$lib/components/common/SplitCreateButton.svelte';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import ProfileImage from '$lib/components/chat/Messages/ProfileImage.svelte';
|
||||
import GarbageBin from '../icons/GarbageBin.svelte';
|
||||
@@ -75,8 +77,6 @@
|
||||
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||
import ViewSelector from './common/ViewSelector.svelte';
|
||||
import TagSelector from './common/TagSelector.svelte';
|
||||
import CommunityDiscover from './common/CommunityDiscover.svelte';
|
||||
import Pagination from '../common/Pagination.svelte';
|
||||
import Badge from '$lib/components/common/Badge.svelte';
|
||||
@@ -85,7 +85,6 @@
|
||||
|
||||
let importFiles;
|
||||
let modelsImportInputElement: HTMLInputElement;
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
|
||||
let loaded = false;
|
||||
|
||||
@@ -116,29 +115,27 @@
|
||||
searchController?.abort();
|
||||
});
|
||||
|
||||
$: if (loaded) {
|
||||
workspaceActions.set([
|
||||
{
|
||||
id: 'models-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/workspace/models/create'
|
||||
$: createActions = [
|
||||
{
|
||||
id: 'models-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/workspace/models/create'
|
||||
},
|
||||
{
|
||||
id: 'models-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => modelsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.models_import
|
||||
},
|
||||
{
|
||||
id: 'models-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
await downloadModels();
|
||||
},
|
||||
{
|
||||
id: 'models-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => modelsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.models_import
|
||||
},
|
||||
{
|
||||
id: 'models-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
await downloadModels();
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.models_export
|
||||
}
|
||||
]);
|
||||
}
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.models_export
|
||||
}
|
||||
];
|
||||
|
||||
$: if (
|
||||
loaded &&
|
||||
@@ -609,54 +606,46 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex max-w-[60%] shrink-0 items-center gap-1 overflow-x-auto scrollbar-none"
|
||||
bind:this={tagsContainerElement}
|
||||
on:wheel={(e) => {
|
||||
if (e.deltaY !== 0) {
|
||||
e.preventDefault();
|
||||
e.currentTarget.scrollLeft += e.deltaY;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="flex w-fit gap-0.5 text-center text-sm rounded-full bg-transparent whitespace-nowrap"
|
||||
>
|
||||
<ViewSelector
|
||||
bind:value={viewOption}
|
||||
align="end"
|
||||
onChange={async (value) => {
|
||||
localStorage.workspaceViewOption = value;
|
||||
page = 1;
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
|
||||
{#if (tags ?? []).length > 0}
|
||||
<TagSelector
|
||||
bind:value={selectedTag}
|
||||
align="end"
|
||||
items={tags.map((tag) => {
|
||||
return { value: tag, label: tag };
|
||||
})}
|
||||
onChange={async () => {
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('Owner'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'created', label: $i18n.t('Created by you') },
|
||||
{ value: 'shared', label: $i18n.t('Shared with you') }
|
||||
],
|
||||
onChange: (value) => {
|
||||
viewOption = value;
|
||||
localStorage.workspaceViewOption = value;
|
||||
page = 1;
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
}
|
||||
},
|
||||
...((tags ?? []).length > 0
|
||||
? [
|
||||
{
|
||||
label: $i18n.t('Tags'),
|
||||
value: selectedTag,
|
||||
items: tags.map((tag) => ({ value: tag, label: tag })),
|
||||
onChange: (value: string) => {
|
||||
selectedTag = value;
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]}
|
||||
/>
|
||||
<Dropdown align="end">
|
||||
<Tooltip content={$i18n.t('Actions')}>
|
||||
<button
|
||||
class="flex h-8 min-w-0 max-w-28 items-center gap-1.5 rounded-xl bg-transparent px-1.5 text-[0.8125rem] font-normal text-base-700 transition hover:text-base-900 dark:text-base-200 dark:hover:text-base-100"
|
||||
type="button"
|
||||
>
|
||||
<span class="min-w-0 truncate">{$i18n.t('Actions')}</span>
|
||||
<ChevronDown className="size-3" strokeWidth="2.5" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<button
|
||||
type="button"
|
||||
class="relative flex size-6.5 shrink-0 items-center justify-center rounded-full border border-base-100 bg-base-50/60 text-base-500 transition-colors hover:bg-base-100 hover:text-base-900 aria-expanded:bg-base-100 aria-expanded:text-base-900 dark:border-base-850 dark:bg-base-850/50 dark:text-base-400 dark:hover:bg-base-850 dark:hover:text-base-0 dark:aria-expanded:bg-base-850 dark:aria-expanded:text-base-0"
|
||||
aria-label={$i18n.t('Actions')}
|
||||
title={$i18n.t('Actions')}
|
||||
>
|
||||
<EllipsisHorizontal className="size-3.5" />
|
||||
</button>
|
||||
|
||||
<div slot="content">
|
||||
<DropdownMenu className="min-w-[10.625rem] shadow-sm">
|
||||
@@ -708,6 +697,7 @@
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</Dropdown>
|
||||
<SplitCreateButton actions={createActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||
import { onMount, getContext, onDestroy } from 'svelte';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import type { i18n as i18nType } from 'i18next';
|
||||
import { WEBUI_NAME, config, user } from '$lib/stores';
|
||||
@@ -44,12 +44,12 @@
|
||||
import Search from '../icons/Search.svelte';
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import SplitCreateButton from '$lib/components/common/SplitCreateButton.svelte';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import ProfileImage from '$lib/components/chat/Messages/ProfileImage.svelte';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
import GarbageBin from '../icons/GarbageBin.svelte';
|
||||
import ViewSelector from './common/ViewSelector.svelte';
|
||||
import TagSelector from './common/TagSelector.svelte';
|
||||
import CommunityDiscover from './common/CommunityDiscover.svelte';
|
||||
import Badge from '$lib/components/common/Badge.svelte';
|
||||
import Switch from '../common/Switch.svelte';
|
||||
@@ -74,7 +74,7 @@
|
||||
let shiftKey = false;
|
||||
|
||||
const i18n = getContext<Writable<i18nType>>('i18n');
|
||||
const { workspaceActions, workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
const { workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
let promptsImportInputElement: HTMLInputElement;
|
||||
let loaded = false;
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
let createPrompt: PromptDraft | null = null;
|
||||
let deletePrompt = null;
|
||||
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
let viewOption = '';
|
||||
let selectedTag = '';
|
||||
let copiedId: string | null = null;
|
||||
@@ -104,42 +103,40 @@
|
||||
|
||||
let page = 1;
|
||||
|
||||
$: if (loaded) {
|
||||
workspaceActions.set([
|
||||
{
|
||||
id: 'prompts-new',
|
||||
label: $i18n.t('Create'),
|
||||
onClick: () => {
|
||||
createPrompt = null;
|
||||
showCreateModal = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'prompts-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => promptsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.prompts_import
|
||||
},
|
||||
{
|
||||
id: 'prompts-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
const _prompts = await getPrompts(localStorage.token).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
});
|
||||
if (!_prompts) {
|
||||
return;
|
||||
}
|
||||
let blob = new Blob([JSON.stringify(_prompts)], {
|
||||
type: 'application/json'
|
||||
});
|
||||
saveAs(blob, `prompts-export-${Date.now()}.json`);
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.prompts_export
|
||||
$: createActions = [
|
||||
{
|
||||
id: 'prompts-new',
|
||||
label: $i18n.t('Create'),
|
||||
onClick: () => {
|
||||
createPrompt = null;
|
||||
showCreateModal = true;
|
||||
}
|
||||
]);
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'prompts-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => promptsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.prompts_import
|
||||
},
|
||||
{
|
||||
id: 'prompts-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
const _prompts = await getPrompts(localStorage.token).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
});
|
||||
if (!_prompts) {
|
||||
return;
|
||||
}
|
||||
let blob = new Blob([JSON.stringify(_prompts)], {
|
||||
type: 'application/json'
|
||||
});
|
||||
saveAs(blob, `prompts-export-${Date.now()}.json`);
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.prompts_export
|
||||
}
|
||||
];
|
||||
|
||||
const handleSearchInput = () => {
|
||||
searchController?.abort();
|
||||
@@ -511,41 +508,38 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex max-w-[55%] shrink-0 overflow-x-auto scrollbar-none"
|
||||
bind:this={tagsContainerElement}
|
||||
on:wheel={(e) => {
|
||||
if (e.deltaY !== 0) {
|
||||
e.preventDefault();
|
||||
e.currentTarget.scrollLeft += e.deltaY;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="flex w-fit gap-0.5 text-center text-sm rounded-full bg-transparent whitespace-nowrap"
|
||||
>
|
||||
<ViewSelector
|
||||
bind:value={viewOption}
|
||||
align="end"
|
||||
onChange={async (value) => {
|
||||
localStorage.workspaceViewOption = value;
|
||||
page = 1;
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
|
||||
{#if (tags ?? []).length > 0}
|
||||
<TagSelector
|
||||
bind:value={selectedTag}
|
||||
align="end"
|
||||
items={tags.map((tag) => ({ value: tag, label: tag }))}
|
||||
onChange={async () => {
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('Owner'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'created', label: $i18n.t('Created by you') },
|
||||
{ value: 'shared', label: $i18n.t('Shared with you') }
|
||||
],
|
||||
onChange: (value) => {
|
||||
viewOption = value;
|
||||
localStorage.workspaceViewOption = value;
|
||||
page = 1;
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
}
|
||||
},
|
||||
...((tags ?? []).length > 0
|
||||
? [
|
||||
{
|
||||
label: $i18n.t('Tags'),
|
||||
value: selectedTag,
|
||||
items: tags.map((tag) => ({ value: tag, label: tag })),
|
||||
onChange: (value: string) => {
|
||||
selectedTag = value;
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]}
|
||||
/>
|
||||
<SplitCreateButton actions={createActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||
import { onMount, getContext, onDestroy } from 'svelte';
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
const { workspaceActions, workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
const { workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
|
||||
import { WEBUI_NAME, user, skills as _skills } from '$lib/stores';
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
import TagInput from '$lib/components/common/Tags/TagInput.svelte';
|
||||
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import SplitCreateButton from '$lib/components/common/SplitCreateButton.svelte';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import ProfileImage from '$lib/components/chat/Messages/ProfileImage.svelte';
|
||||
import ConfirmDialog from '../common/ConfirmDialog.svelte';
|
||||
@@ -46,7 +48,6 @@
|
||||
import Search from '../icons/Search.svelte';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
import ViewSelector from './common/ViewSelector.svelte';
|
||||
import Badge from '$lib/components/common/Badge.svelte';
|
||||
import Switch from '../common/Switch.svelte';
|
||||
import SkillMenu from './Skills/SkillMenu.svelte';
|
||||
@@ -110,7 +111,6 @@
|
||||
let filteredItems = null;
|
||||
let total = null;
|
||||
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
let viewOption = '';
|
||||
$: hasFilters = Boolean(query || viewOption);
|
||||
|
||||
@@ -119,65 +119,63 @@
|
||||
let openSkillMenuId: string | null = null;
|
||||
let page = 1;
|
||||
|
||||
$: if (loaded) {
|
||||
workspaceActions.set([
|
||||
{
|
||||
id: 'skills-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/workspace/skills/create',
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills
|
||||
$: createActions = [
|
||||
{
|
||||
id: 'skills-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/workspace/skills/create',
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills
|
||||
},
|
||||
{
|
||||
id: 'skills-import',
|
||||
label: $i18n.t('Import'),
|
||||
onClick: () => importInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_import
|
||||
},
|
||||
{
|
||||
id: 'skills-import-url',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportFromLink = true;
|
||||
},
|
||||
{
|
||||
id: 'skills-import',
|
||||
label: $i18n.t('Import'),
|
||||
onClick: () => importInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_import
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'skills-import-folder',
|
||||
label: $i18n.t('Import folder'),
|
||||
onClick: () => folderImportInput?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_import
|
||||
},
|
||||
{
|
||||
id: 'skills-export-zip',
|
||||
label: $i18n.t('Export ZIP'),
|
||||
onClick: async () => {
|
||||
try {
|
||||
saveAs(await exportSkillBundle(localStorage.token, 'zip'), 'skills.zip');
|
||||
} catch (error) {
|
||||
toast.error(skillError(error));
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'skills-import-url',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportFromLink = true;
|
||||
},
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'skills-import-folder',
|
||||
label: $i18n.t('Import folder'),
|
||||
onClick: () => folderImportInput?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_import
|
||||
},
|
||||
{
|
||||
id: 'skills-export-zip',
|
||||
label: $i18n.t('Export ZIP'),
|
||||
onClick: async () => {
|
||||
try {
|
||||
saveAs(await exportSkillBundle(localStorage.token, 'zip'), 'skills.zip');
|
||||
} catch (error) {
|
||||
toast.error(skillError(error));
|
||||
}
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_export
|
||||
},
|
||||
{
|
||||
id: 'skills-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
const _skills = await exportSkills(localStorage.token).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_export
|
||||
},
|
||||
{
|
||||
id: 'skills-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
const _skills = await exportSkills(localStorage.token).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
});
|
||||
if (_skills) {
|
||||
let blob = new Blob([JSON.stringify(_skills)], {
|
||||
type: 'application/json'
|
||||
});
|
||||
if (_skills) {
|
||||
let blob = new Blob([JSON.stringify(_skills)], {
|
||||
type: 'application/json'
|
||||
});
|
||||
saveAs(blob, `skills-export-${Date.now()}.json`);
|
||||
}
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_export
|
||||
}
|
||||
]);
|
||||
}
|
||||
saveAs(blob, `skills-export-${Date.now()}.json`);
|
||||
}
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.skills_export
|
||||
}
|
||||
];
|
||||
|
||||
const loadSkillItems = async () => {
|
||||
if (!loaded) return;
|
||||
@@ -434,29 +432,25 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex max-w-[55%] shrink-0 overflow-x-auto scrollbar-none"
|
||||
bind:this={tagsContainerElement}
|
||||
on:wheel={(e) => {
|
||||
if (e.deltaY !== 0) {
|
||||
e.preventDefault();
|
||||
e.currentTarget.scrollLeft += e.deltaY;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="flex w-fit gap-0.5 text-center text-sm rounded-full bg-transparent whitespace-nowrap"
|
||||
>
|
||||
<ViewSelector
|
||||
bind:value={viewOption}
|
||||
align="end"
|
||||
onChange={async (value) => {
|
||||
localStorage.workspaceViewOption = value;
|
||||
page = 1;
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('Owner'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'created', label: $i18n.t('Created by you') },
|
||||
{ value: 'shared', label: $i18n.t('Shared with you') }
|
||||
],
|
||||
onChange: (value) => {
|
||||
viewOption = value;
|
||||
localStorage.workspaceViewOption = value;
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<SplitCreateButton actions={createActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||
import { onMount, getContext, onDestroy } from 'svelte';
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
const { workspaceActions, workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
const { workspaceCounts } = getContext<WorkspaceContext>('workspace');
|
||||
|
||||
import { WEBUI_NAME, config, tools as _tools, user } from '$lib/stores';
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
import { capitalizeFirstLetter } from '$lib/utils';
|
||||
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import SplitCreateButton from '$lib/components/common/SplitCreateButton.svelte';
|
||||
import Switch from '../common/Switch.svelte';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import ProfileImage from '$lib/components/chat/Messages/ProfileImage.svelte';
|
||||
@@ -53,7 +55,6 @@
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
import ImportModal from '../ImportModal.svelte';
|
||||
import ViewSelector from './common/ViewSelector.svelte';
|
||||
import CommunityDiscover from './common/CommunityDiscover.svelte';
|
||||
import Badge from '$lib/components/common/Badge.svelte';
|
||||
import ChevronDown from '../icons/ChevronDown.svelte';
|
||||
@@ -79,7 +80,6 @@
|
||||
let updatingTools: Record<string, boolean> = {};
|
||||
let filteredItems = [];
|
||||
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
let viewOption = '';
|
||||
$: hasFilters = Boolean(query || viewOption);
|
||||
|
||||
@@ -114,47 +114,45 @@
|
||||
}
|
||||
};
|
||||
|
||||
$: if (loaded) {
|
||||
workspaceActions.set([
|
||||
{
|
||||
id: 'tools-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/workspace/tools/create'
|
||||
$: createActions = [
|
||||
{
|
||||
id: 'tools-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/workspace/tools/create'
|
||||
},
|
||||
{
|
||||
id: 'tools-import-link',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportModal = true;
|
||||
},
|
||||
{
|
||||
id: 'tools-import-link',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportModal = true;
|
||||
},
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'tools-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => toolsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.tools_import
|
||||
},
|
||||
{
|
||||
id: 'tools-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
const _tools = await exportTools(localStorage.token).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
});
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'tools-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => toolsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.tools_import
|
||||
},
|
||||
{
|
||||
id: 'tools-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: async () => {
|
||||
const _tools = await exportTools(localStorage.token).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (_tools) {
|
||||
let blob = new Blob([JSON.stringify(_tools)], {
|
||||
type: 'application/json'
|
||||
});
|
||||
saveAs(blob, `tools-export-${Date.now()}.json`);
|
||||
}
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.tools_export
|
||||
}
|
||||
]);
|
||||
}
|
||||
if (_tools) {
|
||||
let blob = new Blob([JSON.stringify(_tools)], {
|
||||
type: 'application/json'
|
||||
});
|
||||
saveAs(blob, `tools-export-${Date.now()}.json`);
|
||||
}
|
||||
},
|
||||
visible: $user?.role === 'admin' || $user?.permissions?.workspace?.tools_export
|
||||
}
|
||||
];
|
||||
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
@@ -408,29 +406,24 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex max-w-[55%] shrink-0 overflow-x-auto scrollbar-none"
|
||||
bind:this={tagsContainerElement}
|
||||
on:wheel={(e) => {
|
||||
if (e.deltaY !== 0) {
|
||||
e.preventDefault();
|
||||
e.currentTarget.scrollLeft += e.deltaY;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="flex w-fit gap-0.5 text-center text-sm rounded-full bg-transparent whitespace-nowrap"
|
||||
>
|
||||
<ViewSelector
|
||||
bind:value={viewOption}
|
||||
align="end"
|
||||
onChange={async (value) => {
|
||||
localStorage.workspaceViewOption = value;
|
||||
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('Owner'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'created', label: $i18n.t('Created by you') },
|
||||
{ value: 'shared', label: $i18n.t('Shared with you') }
|
||||
],
|
||||
onChange: (value) => {
|
||||
viewOption = value;
|
||||
localStorage.workspaceViewOption = value;
|
||||
}
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<SplitCreateButton actions={createActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
showSidebar,
|
||||
user,
|
||||
mobile,
|
||||
type WorkspaceAction,
|
||||
type WorkspaceSection
|
||||
} from '$lib/stores';
|
||||
|
||||
@@ -23,13 +22,11 @@
|
||||
import { getToolList } from '$lib/apis/tools';
|
||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||
import Sidebar from '$lib/components/icons/Sidebar.svelte';
|
||||
import SplitCreateButton from '$lib/components/common/SplitCreateButton.svelte';
|
||||
import { formatNumber } from '$lib/utils';
|
||||
|
||||
const i18n = getContext<Writable<i18nType>>('i18n');
|
||||
|
||||
import { writable } from 'svelte/store';
|
||||
const workspaceActions = writable<WorkspaceAction[]>([]);
|
||||
const workspaceCounts = writable<Record<WorkspaceSection, number | null>>({
|
||||
models: null,
|
||||
knowledge: null,
|
||||
@@ -37,24 +34,16 @@
|
||||
skills: null,
|
||||
tools: null
|
||||
});
|
||||
setContext<WorkspaceContext>('workspace', { workspaceActions, workspaceCounts });
|
||||
setContext<WorkspaceContext>('workspace', { workspaceCounts });
|
||||
|
||||
let loaded = false;
|
||||
let lastPath = '';
|
||||
let activeWorkspaceSection = '';
|
||||
let visibleActions = [];
|
||||
|
||||
$: if ($pageUrl.pathname !== lastPath) {
|
||||
lastPath = $pageUrl.pathname;
|
||||
workspaceActions.set([]);
|
||||
}
|
||||
|
||||
$: if (loaded && $pageUrl.pathname.startsWith('/workspace')) {
|
||||
loadWorkspaceCounts();
|
||||
}
|
||||
|
||||
$: activeWorkspaceSection = $pageUrl.pathname.split('/')[2] ?? '';
|
||||
$: visibleActions = $workspaceActions.filter((action) => action.visible ?? true);
|
||||
|
||||
const getCount = (res: any) => res?.total ?? (Array.isArray(res) ? res.length : null);
|
||||
const formatCount = (count: number | null) => formatNumber(count ?? 0);
|
||||
@@ -258,10 +247,6 @@
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="ml-auto flex shrink-0 items-center gap-1">
|
||||
<SplitCreateButton actions={visibleActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="flex items-center text-xl font-normal">{$i18n.t('Workspace')}</div> -->
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||
import DropdownSub from '$lib/components/common/DropdownSub.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import ChevronRight from '$lib/components/icons/ChevronRight.svelte';
|
||||
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
|
||||
type Section = {
|
||||
label: string;
|
||||
value: string;
|
||||
items: { value: string; label: string }[];
|
||||
onChange: (value: string) => void;
|
||||
};
|
||||
|
||||
// Each section is a submenu of radio items that starts with "All" (value '').
|
||||
export let sections: Section[] = [];
|
||||
|
||||
$: active = sections.some((section) => section.value);
|
||||
</script>
|
||||
|
||||
<!-- Same circle trigger and menu as the filter in Automations and the folder page. -->
|
||||
<Dropdown align="end">
|
||||
<button
|
||||
type="button"
|
||||
class="relative flex size-6.5 shrink-0 items-center justify-center rounded-full border border-base-100 bg-base-50/60 transition-colors hover:bg-base-100 hover:text-base-900 aria-expanded:bg-base-100 aria-expanded:text-base-900 dark:border-base-850 dark:bg-base-850/50 dark:hover:bg-base-850 dark:hover:text-base-0 dark:aria-expanded:bg-base-850 dark:aria-expanded:text-base-0 {active
|
||||
? 'text-base-800 dark:text-base-100'
|
||||
: 'text-base-500 dark:text-base-400'}"
|
||||
aria-label={$i18n.t('Filter')}
|
||||
title={$i18n.t('Filter')}
|
||||
>
|
||||
<svg
|
||||
class="size-3.75"
|
||||
viewBox="0 0 16 16"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
aria-hidden="true"><path d="M2.5 4h11M4.5 8h7M6.5 12h3" /></svg
|
||||
>
|
||||
{#if active}
|
||||
<span class="absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-base-800 dark:bg-base-100"
|
||||
></span>
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<DropdownMenu slot="content" className="w-48">
|
||||
{#each sections as section}
|
||||
{@const items = [{ value: '', label: $i18n.t('All') }, ...section.items]}
|
||||
<DropdownSub
|
||||
contentClass="select-none z-50 max-h-80 overflow-y-auto"
|
||||
maxWidth={320}
|
||||
sideOffset={6}
|
||||
>
|
||||
<button
|
||||
slot="trigger"
|
||||
type="button"
|
||||
class="flex h-[1.6875rem] w-full cursor-pointer select-none items-center gap-2 rounded-xl px-2 text-left text-[0.8125rem] outline-hidden"
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate text-left">{section.label}</span>
|
||||
<span class="max-w-24 truncate text-base-500 dark:text-base-400"
|
||||
>{items.find((item) => item.value === section.value)?.label ?? ''}</span
|
||||
>
|
||||
<ChevronRight className="size-3.5 shrink-0 text-base-400 rtl:rotate-180" />
|
||||
</button>
|
||||
{#each items as item (item.value)}
|
||||
<button
|
||||
type="button"
|
||||
role="menuitemradio"
|
||||
aria-checked={section.value === item.value}
|
||||
on:click={() => section.onChange(item.value)}
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate text-left">{item.label}</span>
|
||||
{#if section.value === item.value}<Check className="size-3! shrink-0" />{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</DropdownSub>
|
||||
{/each}
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
@@ -1,79 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import Select from '$lib/components/common/Select.svelte';
|
||||
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
|
||||
export let value = '';
|
||||
export let placeholder: string | undefined = undefined;
|
||||
export let align = 'start';
|
||||
export let onChange: (value: string) => void = () => {};
|
||||
|
||||
$: items = [
|
||||
{ value: '', label: $i18n.t('All') },
|
||||
{ value: 'created', label: $i18n.t('Created by you') },
|
||||
{ value: 'shared', label: $i18n.t('Shared with you') }
|
||||
];
|
||||
</script>
|
||||
|
||||
<Select
|
||||
bind:value
|
||||
{items}
|
||||
placeholder={placeholder ?? $i18n.t('Select view')}
|
||||
{align}
|
||||
triggerClass="relative h-8 w-full flex items-center gap-0.5 px-1.5 py-1.5 bg-transparent rounded-xl text-[0.8125rem] font-normal text-base-700 transition hover:text-base-900 dark:text-base-200 dark:hover:text-base-100"
|
||||
labelClass="inline-flex h-input w-full outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
onChange={() => onChange(value)}
|
||||
>
|
||||
<svelte:fragment slot="trigger" let:selectedLabel>
|
||||
<span
|
||||
class="inline-flex h-input w-full outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
>
|
||||
{selectedLabel}
|
||||
</span>
|
||||
<ChevronDown className=" size-3.5" strokeWidth="2.5" />
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="item" let:item let:selected>
|
||||
{item.label}
|
||||
<div class="ml-auto {selected ? '' : 'invisible'}">
|
||||
<Check />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Select>
|
||||
|
||||
<!-- <button
|
||||
class="min-w-fit outline-none p-1.5 {selectedTag === ''
|
||||
? ''
|
||||
: 'text-base-300 dark:text-base-600 hover:text-base-700 dark:hover:text-base-0'} transition capitalize"
|
||||
on:click={() => {
|
||||
selectedTag = '';
|
||||
}}
|
||||
>
|
||||
{$i18n.t('All')}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="min-w-fit outline-none p-1.5 {selectedTag === ''
|
||||
? ''
|
||||
: 'text-base-300 dark:text-base-600 hover:text-base-700 dark:hover:text-base-0'} transition capitalize"
|
||||
on:click={() => {
|
||||
selectedTag = '';
|
||||
}}
|
||||
>
|
||||
{$i18n.t('Created by you')}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="min-w-fit outline-none p-1.5 {selectedTag === ''
|
||||
? ''
|
||||
: 'text-base-300 dark:text-base-600 hover:text-base-700 dark:hover:text-base-0'} transition capitalize"
|
||||
on:click={() => {
|
||||
selectedTag = '';
|
||||
}}
|
||||
>
|
||||
{$i18n.t('Shared with you')}
|
||||
</button> -->
|
||||
Reference in new issue
Block a user