diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index cfa9e713d..779933749 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -53,6 +53,7 @@ import { getChannels, createNewChannel } from '$lib/apis/channels'; import CreateChannelModal from './Sidebar/CreateChannelModal.svelte'; import ChannelItem from './Sidebar/ChannelItem.svelte'; + import PencilSquare from '../icons/PencilSquare.svelte'; const BREAKPOINT = 768; @@ -433,36 +434,6 @@ : 'invisible'}" >
- { - selectedChatId = null; - await goto('/'); - const newChatButton = document.getElementById('new-chat-button'); - setTimeout(() => { - newChatButton?.click(); - if ($mobile) { - showSidebar.set(false); - } - }, 0); - }} - > -
- logo -
-
- {$i18n.t('New Chat')} -
-
-
+ + { + selectedChatId = null; + await goto('/'); + const newChatButton = document.getElementById('new-chat-button'); + setTimeout(() => { + newChatButton?.click(); + if ($mobile) { + showSidebar.set(false); + } + }, 0); + }} + > +
+
+ logo +
+
+ {$i18n.t('New Chat')} +
+
+ +
+ +
+
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.models || $user?.permissions?.workspace?.knowledge || $user?.permissions?.workspace?.prompts || $user?.permissions?.workspace?.tools} @@ -544,6 +551,82 @@ ? 'opacity-20' : ''}" > + {#if !search && $pinnedChats.length > 0} +
+ { + localStorage.setItem('showPinnedChat', e.detail); + console.log(e.detail); + }} + on:import={(e) => { + importChatHandler(e.detail, true); + }} + on:drop={async (e) => { + const { type, id, item } = e.detail; + + if (type === 'chat') { + let chat = await getChatById(localStorage.token, id).catch((error) => { + return null; + }); + if (!chat && item) { + chat = await importChat(localStorage.token, item.chat, item?.meta ?? {}); + } + + if (chat) { + console.log(chat); + if (chat.folder_id) { + const res = await updateChatFolderIdById( + localStorage.token, + chat.id, + null + ).catch((error) => { + toast.error(error); + return null; + }); + } + + if (!chat.pinned) { + const res = await toggleChatPinnedStatusById(localStorage.token, chat.id); + } + + initChatList(); + } + } + }} + name={$i18n.t('Pinned')} + > +
+ {#each $pinnedChats as chat, idx} + { + selectedChatId = chat.id; + }} + on:unselect={() => { + selectedChatId = null; + }} + on:change={async () => { + initChatList(); + }} + on:tag={(e) => { + const { type, name } = e.detail; + tagEventHandler(type, name, chat.id); + }} + /> + {/each} +
+
+
+ {/if} + {#if ($user.role === 'admin' || $channels.length > 0) && !search} {/if} + {#if !search && folders} + { + const { folderId, items } = e.detail; + importChatHandler(items, false, folderId); + }} + on:update={async (e) => { + initChatList(); + }} + on:change={async () => { + initChatList(); + }} + /> + {/if} + { importChatHandler(e.detail); }} @@ -621,99 +718,7 @@
{/if} - {#if !search && $pinnedChats.length > 0} -
- { - localStorage.setItem('showPinnedChat', e.detail); - console.log(e.detail); - }} - on:import={(e) => { - importChatHandler(e.detail, true); - }} - on:drop={async (e) => { - const { type, id, item } = e.detail; - - if (type === 'chat') { - let chat = await getChatById(localStorage.token, id).catch((error) => { - return null; - }); - if (!chat && item) { - chat = await importChat(localStorage.token, item.chat, item?.meta ?? {}); - } - - if (chat) { - console.log(chat); - if (chat.folder_id) { - const res = await updateChatFolderIdById( - localStorage.token, - chat.id, - null - ).catch((error) => { - toast.error(error); - return null; - }); - } - - if (!chat.pinned) { - const res = await toggleChatPinnedStatusById(localStorage.token, chat.id); - } - - initChatList(); - } - } - }} - name={$i18n.t('Pinned')} - > -
- {#each $pinnedChats as chat, idx} - { - selectedChatId = chat.id; - }} - on:unselect={() => { - selectedChatId = null; - }} - on:change={async () => { - initChatList(); - }} - on:tag={(e) => { - const { type, name } = e.detail; - tagEventHandler(type, name, chat.id); - }} - /> - {/each} -
-
-
- {/if} -
- {#if !search && folders} - { - const { folderId, items } = e.detail; - importChatHandler(items, false, folderId); - }} - on:update={async (e) => { - initChatList(); - }} - on:change={async () => { - initChatList(); - }} - /> - {/if} -
{#if $chats} {#each $chats as chat, idx} diff --git a/src/lib/components/layout/Sidebar/Folders.svelte b/src/lib/components/layout/Sidebar/Folders.svelte index f3d468589..fb0c955c5 100644 --- a/src/lib/components/layout/Sidebar/Folders.svelte +++ b/src/lib/components/layout/Sidebar/Folders.svelte @@ -19,6 +19,7 @@ {#each folderList as folderId (folderId)} {