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
@@ -26,6 +26,7 @@
|
||||
} from '$lib/apis/functions';
|
||||
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.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';
|
||||
@@ -41,8 +42,6 @@
|
||||
import Search from '../icons/Search.svelte';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
import ImportModal from '../ImportModal.svelte';
|
||||
import ViewSelector from '../workspace/common/ViewSelector.svelte';
|
||||
import TagSelector from '../workspace/common/TagSelector.svelte';
|
||||
import CommunityDiscover from '../workspace/common/CommunityDiscover.svelte';
|
||||
import { capitalizeFirstLetter } from '$lib/utils';
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
@@ -58,7 +57,6 @@
|
||||
let functionsImportInputElement: HTMLInputElement;
|
||||
let importFiles;
|
||||
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
let viewOption = '';
|
||||
let sortKey = 'updated_at';
|
||||
let sortDirection = 'desc';
|
||||
@@ -255,6 +253,33 @@
|
||||
}
|
||||
};
|
||||
|
||||
$: createActions = [
|
||||
{
|
||||
id: 'functions-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/admin/functions/create'
|
||||
},
|
||||
{
|
||||
id: 'functions-import-link',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportModal = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'functions-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => functionsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'functions-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: downloadFunctions,
|
||||
visible: $user?.role === 'admin' && (functions ?? []).length > 0
|
||||
}
|
||||
];
|
||||
|
||||
onMount(async () => {
|
||||
viewOption = localStorage?.workspaceViewOption || '';
|
||||
functions = await getFunctionList(localStorage.token).catch((error) => {
|
||||
@@ -346,37 +371,6 @@
|
||||
{filteredItems.length}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex w-full justify-end">
|
||||
<SplitCreateButton
|
||||
actions={[
|
||||
{
|
||||
id: 'functions-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/admin/functions/create'
|
||||
},
|
||||
{
|
||||
id: 'functions-import-link',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportModal = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'functions-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => functionsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'functions-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: downloadFunctions,
|
||||
visible: $user?.role === 'admin' && functions.length > 0
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -412,40 +406,35 @@
|
||||
{/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={selectedType}
|
||||
align="end"
|
||||
items={[
|
||||
{ value: 'pipe', label: $i18n.t('Pipe') },
|
||||
{ value: 'filter', label: $i18n.t('Filter') },
|
||||
{ value: 'action', label: $i18n.t('Action') },
|
||||
{ value: 'event', label: $i18n.t('Event') }
|
||||
]}
|
||||
/>
|
||||
</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('Type'),
|
||||
value: selectedType,
|
||||
items: [
|
||||
{ value: 'pipe', label: $i18n.t('Pipe') },
|
||||
{ value: 'filter', label: $i18n.t('Filter') },
|
||||
{ value: 'action', label: $i18n.t('Action') },
|
||||
{ value: 'event', label: $i18n.t('Event') }
|
||||
],
|
||||
onChange: (value) => (selectedType = value)
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<SplitCreateButton actions={createActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
import { getModelsConfig, setModelsConfig } from '$lib/apis/configs';
|
||||
import Search from '$lib/components/icons/Search.svelte';
|
||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import Switch from '$lib/components/common/Switch.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
@@ -51,7 +52,6 @@
|
||||
import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte';
|
||||
import EyeSlash from '$lib/components/icons/EyeSlash.svelte';
|
||||
import Eye from '$lib/components/icons/Eye.svelte';
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import CheckCircle from '$lib/components/icons/CheckCircle.svelte';
|
||||
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
|
||||
@@ -69,8 +69,6 @@
|
||||
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||
import AdminViewSelector from './Models/AdminViewSelector.svelte';
|
||||
import TagSelector from '$lib/components/workspace/common/TagSelector.svelte';
|
||||
import { isMachine } from '$lib/utils/machines';
|
||||
|
||||
type ModelListItem = { id: string; name?: string; owned_by?: string };
|
||||
@@ -82,7 +80,6 @@
|
||||
let modelsImportInProgress = false;
|
||||
let importFiles;
|
||||
let modelsImportInputElement: HTMLInputElement;
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
let modelListElement: HTMLDivElement;
|
||||
let sortable = null;
|
||||
|
||||
@@ -852,42 +849,52 @@
|
||||
{/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"
|
||||
>
|
||||
<AdminViewSelector bind:value={viewOption} align="end" />
|
||||
|
||||
{#if (tags ?? []).length > 0}
|
||||
<TagSelector
|
||||
bind:value={selectedTag}
|
||||
align="end"
|
||||
items={tags.map((tag) => {
|
||||
return { value: tag, label: tag };
|
||||
})}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('View'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'available', label: $i18n.t('Available') },
|
||||
{ value: 'unavailable', label: $i18n.t('Unavailable') },
|
||||
{ value: 'base', label: $i18n.t('Base Models') },
|
||||
{ value: 'workspace', label: $i18n.t('Workspace Models') },
|
||||
{ value: 'router', label: $i18n.t('settings.admin.models.routerModels.label') },
|
||||
{ value: 'enabled', label: $i18n.t('Enabled') },
|
||||
{ value: 'disabled', label: $i18n.t('Disabled') },
|
||||
{ value: 'visible', label: $i18n.t('Visible') },
|
||||
{ value: 'hidden', label: $i18n.t('Hidden') },
|
||||
{ value: 'public', label: $i18n.t('Public') },
|
||||
{ value: 'private', label: $i18n.t('Private') },
|
||||
{ value: 'selected', label: $i18n.t('Selected') },
|
||||
{ value: 'pinned', label: $i18n.t('Pinned') }
|
||||
],
|
||||
onChange: (value) => (viewOption = value)
|
||||
},
|
||||
...((tags ?? []).length > 0
|
||||
? [
|
||||
{
|
||||
label: $i18n.t('Tags'),
|
||||
value: selectedTag,
|
||||
items: tags.map((tag) => ({ value: tag, label: tag })),
|
||||
onChange: (value: string) => {
|
||||
selectedTag = value;
|
||||
}
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]}
|
||||
/>
|
||||
<Dropdown closeOnSelect align="end">
|
||||
<Tooltip content={$i18n.t('Actions')}>
|
||||
<button
|
||||
class="flex h-8 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>{$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">
|
||||
|
||||
@@ -1,57 +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: 'available', label: $i18n.t('Available') },
|
||||
{ value: 'unavailable', label: $i18n.t('Unavailable') },
|
||||
{ value: 'base', label: $i18n.t('Base Models') },
|
||||
{ value: 'workspace', label: $i18n.t('Workspace Models') },
|
||||
{ value: 'router', label: $i18n.t('settings.admin.models.routerModels.label') },
|
||||
{ value: 'enabled', label: $i18n.t('Enabled') },
|
||||
{ value: 'disabled', label: $i18n.t('Disabled') },
|
||||
{ value: 'visible', label: $i18n.t('Visible') },
|
||||
{ value: 'hidden', label: $i18n.t('Hidden') },
|
||||
{ value: 'public', label: $i18n.t('Public') },
|
||||
{ value: 'private', label: $i18n.t('Private') },
|
||||
{ value: 'selected', label: $i18n.t('Selected') },
|
||||
{ value: 'pinned', label: $i18n.t('Pinned') }
|
||||
];
|
||||
</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>
|
||||
@@ -14,10 +14,12 @@
|
||||
import EditGroupModal from './Groups/EditGroupModal.svelte';
|
||||
import GroupItem from './Groups/GroupItem.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import ChevronRight from '$lib/components/icons/ChevronRight.svelte';
|
||||
import Select from '$lib/components/common/Select.svelte';
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||
import AdjustmentsHorizontal from '$lib/components/icons/AdjustmentsHorizontal.svelte';
|
||||
import Plus from '$lib/components/icons/Plus.svelte';
|
||||
import { createNewGroup, getGroups, updateGroupById } from '$lib/apis/groups';
|
||||
import { getUserDefaultPermissions, updateUserDefaultPermissions } from '$lib/apis/users';
|
||||
|
||||
@@ -242,39 +244,47 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Select
|
||||
bind:value={sortBy}
|
||||
items={sortItems}
|
||||
placeholder={$i18n.t('Sort')}
|
||||
triggerClass="relative h-8 shrink-0 flex items-center gap-1 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 outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
align="end"
|
||||
>
|
||||
<svelte:fragment slot="trigger" let:selectedLabel>
|
||||
<span
|
||||
class="inline-flex h-input outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<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 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('Sort by')}
|
||||
title={$i18n.t('Sort by')}
|
||||
>
|
||||
{selectedLabel}
|
||||
</span>
|
||||
<ChevronDown className="size-3.5" strokeWidth="2.5" />
|
||||
</svelte:fragment>
|
||||
<AdjustmentsHorizontal className="size-3.75" />
|
||||
</button>
|
||||
|
||||
<svelte:fragment slot="item" let:item let:selected>
|
||||
{item.label}
|
||||
<div class="ml-auto {selected ? '' : 'invisible'}">
|
||||
<Check />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Select>
|
||||
<DropdownMenu slot="content" className="w-44">
|
||||
<div class="px-2 pt-1.5 pb-0.5 text-xs text-base-400 dark:text-base-500">
|
||||
{$i18n.t('Sort by')}
|
||||
</div>
|
||||
{#each sortItems as item (item.value)}
|
||||
<button
|
||||
type="button"
|
||||
role="menuitemradio"
|
||||
aria-checked={sortBy === item.value}
|
||||
on:click={() => (sortBy = item.value)}
|
||||
>
|
||||
<span class="flex-1 text-left">{item.label}</span>
|
||||
{#if sortBy === item.value}<Check className="size-3! shrink-0" />{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
|
||||
<button
|
||||
class="ml-1 shrink-0 rounded-lg bg-base-50 px-2.5 py-1 text-xs text-base-900 transition ring-1 ring-base-200 hover:bg-base-100 dark:bg-base-850 dark:text-base-100 dark:ring-base-800 dark:hover:bg-base-800"
|
||||
on:click={() => {
|
||||
showAddGroupModal = !showAddGroupModal;
|
||||
}}
|
||||
>
|
||||
{$i18n.t('New Group')}
|
||||
</button>
|
||||
<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('New Group')}
|
||||
title={$i18n.t('New Group')}
|
||||
on:click={() => {
|
||||
showAddGroupModal = !showAddGroupModal;
|
||||
}}
|
||||
>
|
||||
<Plus className="size-3.5" strokeWidth="2" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
import Search from '$lib/components/icons/Search.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
import Plus from '$lib/components/icons/Plus.svelte';
|
||||
import ChevronUp from '$lib/components/icons/ChevronUp.svelte';
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Banner from '$lib/components/common/Banner.svelte';
|
||||
@@ -220,12 +221,15 @@
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="ml-1 shrink-0 rounded-lg bg-base-50 px-2.5 py-1 text-xs text-base-900 transition ring-1 ring-base-200 hover:bg-base-100 dark:bg-base-850 dark:text-base-100 dark:ring-base-800 dark:hover:bg-base-800"
|
||||
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('Add User')}
|
||||
title={$i18n.t('Add User')}
|
||||
on:click={() => {
|
||||
showAddUserModal = !showAddUserModal;
|
||||
}}
|
||||
>
|
||||
{$i18n.t('Add User')}
|
||||
<Plus className="size-3.5" strokeWidth="2" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import DocumentArrowUp from '$lib/components/icons/DocumentArrowUp.svelte';
|
||||
import Link from '$lib/components/icons/Link.svelte';
|
||||
import Pencil from '$lib/components/icons/Pencil.svelte';
|
||||
import Plus from '$lib/components/icons/Plus.svelte';
|
||||
|
||||
type SplitCreateAction = {
|
||||
id: string;
|
||||
@@ -50,35 +51,43 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Same circle as the + buttons on the folder page; a split pill when there are more ways to create. -->
|
||||
{#if visibleActions.length === 1}
|
||||
<button
|
||||
class="focus-ring ml-1 rounded-lg bg-base-50 px-2.5 py-1 text-xs text-base-900 transition ring-1 ring-base-200 hover:bg-base-100 dark:bg-base-850 dark:text-base-100 dark:ring-base-800 dark:hover:bg-base-800"
|
||||
class="focus-ring 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 dark:border-base-850 dark:bg-base-850/50 dark:text-base-400 dark:hover:bg-base-850 dark:hover:text-base-0"
|
||||
type="button"
|
||||
aria-label={$i18n.t(label)}
|
||||
title={$i18n.t(label)}
|
||||
on:click={() => {
|
||||
runAction(primaryAction);
|
||||
}}
|
||||
>
|
||||
{$i18n.t(label)}
|
||||
<Plus className="size-3.5" strokeWidth="2" />
|
||||
</button>
|
||||
{:else if visibleActions.length > 1}
|
||||
<div
|
||||
class="ml-1 flex overflow-hidden rounded-lg bg-base-50 text-xs text-base-900 transition ring-1 ring-base-200 dark:bg-base-850 dark:text-base-100 dark:ring-base-800"
|
||||
class="flex h-6.5 shrink-0 items-center overflow-hidden rounded-full border border-base-100 bg-base-50/60 text-base-500 dark:border-base-850 dark:bg-base-850/50 dark:text-base-400"
|
||||
>
|
||||
<button
|
||||
class="focus-ring px-2.5 py-1 transition hover:bg-base-100 dark:hover:bg-base-800"
|
||||
class="focus-ring flex h-full w-6.5 items-center justify-center transition-colors hover:bg-base-100 hover:text-base-900 dark:hover:bg-base-850 dark:hover:text-base-0"
|
||||
type="button"
|
||||
aria-label={$i18n.t(label)}
|
||||
title={$i18n.t(label)}
|
||||
on:click={() => {
|
||||
runAction(primaryAction);
|
||||
}}
|
||||
>
|
||||
{$i18n.t(label)}
|
||||
<Plus className="size-3.5" strokeWidth="2" />
|
||||
</button>
|
||||
|
||||
<Dropdown bind:show={showMenu} align="end" sideOffset={6}>
|
||||
<button
|
||||
class="focus-ring flex items-center {($settings?.highContrastMode ?? false)
|
||||
? 'min-w-6 justify-center'
|
||||
: ''} border-l border-base-200 px-1.5 py-1 transition hover:bg-base-100 dark:border-base-800 dark:hover:bg-base-800"
|
||||
class="focus-ring flex h-full items-center justify-center border-l border-base-100 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:hover:bg-base-850 dark:hover:text-base-0 dark:aria-expanded:bg-base-850 dark:aria-expanded:text-base-0 {$settings?.highContrastMode
|
||||
? 'w-6'
|
||||
: 'w-5'}"
|
||||
type="button"
|
||||
aria-label={$i18n.t('Open create menu')}
|
||||
title={$i18n.t('Open create menu')}
|
||||
>
|
||||
<ChevronDown className="size-2.5" strokeWidth="2.5" />
|
||||
</button>
|
||||
|
||||
@@ -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