diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 5b68e1efab..7142efed99 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -141,6 +141,7 @@ import XMarkIcon from '../icons/XMark.svelte'; import ConfirmDialog from '../common/ConfirmDialog.svelte'; import MoreHorizontalIcon from './Sidebar/icons/MoreHorizontal.svelte'; + import EyeSlashIcon from '../icons/EyeSlash.svelte'; import PlusIcon from './Sidebar/icons/Plus.svelte'; import MobileSwipePanel from '../common/MobileSwipePanel.svelte'; @@ -522,7 +523,28 @@ ($settings?.sidebarSectionOrder ?? []).filter((id) => SIDEBAR_SECTIONS.includes(id)) ); - $: visibleSections = sectionOrder.filter((id) => { + let sectionLabels: Record; + $: sectionLabels = { + teams: $i18n.t('Teams'), + models: $i18n.t('Models'), + notes: $i18n.t('Notes'), + channels: $i18n.t('Channels'), + folders: $i18n.t('Folders'), + chats: $i18n.t('Chats') + }; + + $: hiddenSections = $settings?.sidebarSectionHidden ?? []; + $: visibleSections = availableSections.filter((id) => !hiddenSections.includes(id)); + + const toggleSection = async (id: string) => { + const next = hiddenSections.includes(id) + ? hiddenSections.filter((hidden) => hidden !== id) + : [...hiddenSections, id]; + settings.set({ ...$settings, sidebarSectionHidden: next }); + await updateUserSettings(localStorage.token, { ui: { sidebarSectionHidden: next } }); + }; + + $: availableSections = sectionOrder.filter((id) => { switch (id) { case 'models': return $visiblePinnedModels.length > 0; @@ -1307,6 +1329,73 @@ const isWindows = /Windows/i.test(navigator.userAgent); + +{#snippet sectionChecklist()} + + + {#each availableSections as section (section)} + {@const shown = !hiddenSections.includes(section)} + + {/each} + +{/snippet} + + +{#snippet sectionVisibilityItems(id: string, close = () => {})} + + {@render sectionChecklist()} +{/snippet} + + +{#snippet sectionMoreMenu(id: string)} + + + + + +
+ + {@render sectionVisibilityItems(id)} + +
+
+{/snippet} +
{#if $user !== undefined && $user !== null} - + + {@render sectionChecklist()} +
+ {@render sectionVisibilityItems( + 'folders', + () => (showFoldersMenu = false) + )}
@@ -2261,6 +2369,8 @@
{$i18n.t('Mark all as read')}
+
+ {@render sectionVisibilityItems('chats', () => (showChatsMenu = false))} @@ -2538,6 +2648,7 @@ profile={$config?.features?.enable_user_status ?? true} className="w-[calc(var(--sidebar-width)-1rem)]" > + {@render sectionChecklist()}