mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
refac
This commit is contained in:
1 parent
d15ba19e98
commit
89b2c9d919
2 files changed
+53
-7
No files matched your search
@@ -80,6 +80,7 @@
|
||||
import DropdownSub from '$lib/components/common/DropdownSub.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte';
|
||||
import Plus from '$lib/components/icons/Plus.svelte';
|
||||
import ChevronRight from '$lib/components/icons/ChevronRight.svelte';
|
||||
import FolderAutomations from './FolderAutomations.svelte';
|
||||
@@ -233,14 +234,31 @@
|
||||
knowledge: $i18n.t('Knowledge')
|
||||
} satisfies Record<FolderSection, string>;
|
||||
let sectionTabs: [FolderSection, string][];
|
||||
$: sectionTabs = tabOrder
|
||||
.filter(
|
||||
(id) =>
|
||||
(id !== 'files' || filesTarget) &&
|
||||
(id !== 'notes' || canUseNotes) &&
|
||||
(id !== 'automations' || canUseAutomations)
|
||||
)
|
||||
// Every tab this folder offers, shown or hidden, for the menu.
|
||||
$: availableTabs = tabOrder.filter(
|
||||
(id) =>
|
||||
(id !== 'files' || filesTarget) &&
|
||||
(id !== 'notes' || canUseNotes) &&
|
||||
(id !== 'automations' || canUseAutomations)
|
||||
);
|
||||
// Overview is always shown.
|
||||
let hiddenTabs: FolderSection[];
|
||||
$: hiddenTabs = (($settings?.folderTabHidden ?? []) as FolderSection[]).filter(
|
||||
(id) => id !== 'overview'
|
||||
);
|
||||
$: sectionTabs = availableTabs
|
||||
.filter((id) => !hiddenTabs.includes(id))
|
||||
.map((id) => [id, tabLabels[id]]);
|
||||
// Hiding the open tab moves to the Overview.
|
||||
$: if (hiddenTabs.includes(folderSection)) showSection('overview', false);
|
||||
|
||||
const toggleTab = async (id: FolderSection) => {
|
||||
const next = hiddenTabs.includes(id)
|
||||
? hiddenTabs.filter((hidden) => hidden !== id)
|
||||
: [...hiddenTabs, id];
|
||||
settings.set({ ...$settings, folderTabHidden: next });
|
||||
await updateUserSettings(localStorage.token, { ui: { folderTabHidden: next } });
|
||||
};
|
||||
|
||||
const sortableTabs = (node: HTMLElement) => {
|
||||
if ($mobile) return;
|
||||
@@ -1383,6 +1401,32 @@
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<Dropdown>
|
||||
<button
|
||||
type="button"
|
||||
class="flex size-5 shrink-0 items-center justify-center text-base-300 transition hover:text-base-700 aria-expanded:text-base-700 dark:text-base-600 dark:hover:text-base-0 dark:aria-expanded:text-base-0"
|
||||
aria-label={$i18n.t('Tabs')}
|
||||
title={$i18n.t('Tabs')}
|
||||
>
|
||||
<EllipsisHorizontal className="size-3.5" strokeWidth="1.5" />
|
||||
</button>
|
||||
|
||||
<DropdownMenu slot="content" className="w-44">
|
||||
{#each availableTabs.filter((id) => id !== 'overview') as id (id)}
|
||||
{@const shown = !hiddenTabs.includes(id)}
|
||||
<button
|
||||
type="button"
|
||||
role="menuitemcheckbox"
|
||||
aria-checked={shown}
|
||||
on:click={() => toggleTab(id)}
|
||||
>
|
||||
<span class="flex-1 text-left">{tabLabels[id]}</span>
|
||||
{#if shown}<Check className="size-3! shrink-0" />{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
|
||||
<div class="ml-auto flex items-center gap-1">
|
||||
{#if folderSection === 'overview'}
|
||||
<!-- The Overview has no toolbar. -->
|
||||
|
||||
@@ -401,6 +401,8 @@ type Settings = {
|
||||
sidebarSectionOrder?: string[];
|
||||
/** Folder page tab ids ('overview', 'files', 'chats', ...) in display order. */
|
||||
folderTabOrder?: string[];
|
||||
/** Folder page tab ids the user has hidden. */
|
||||
folderTabHidden?: string[];
|
||||
/** Folder ids in display order, by parent folder id ('root' for top-level folders and folderSections). */
|
||||
folderOrder?: Record<string, string[]>;
|
||||
/** Whose top-level folders the sidebar lists. */
|
||||
|
||||
Reference in new issue
Block a user