mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
refac: sidebar styling
This commit is contained in:
parent
b2b56d14cb
commit
6b3be4bb5b
@ -578,6 +578,86 @@
|
|||||||
? 'opacity-20'
|
? 'opacity-20'
|
||||||
: ''}"
|
: ''}"
|
||||||
>
|
>
|
||||||
|
{#if $config?.features?.enable_channels && ($user.role === 'admin' || $channels.length > 0) && !search}
|
||||||
|
<Folder
|
||||||
|
className="px-2 mt-0.5"
|
||||||
|
name={$i18n.t('Channels')}
|
||||||
|
dragAndDrop={false}
|
||||||
|
onAdd={$user.role === 'admin'
|
||||||
|
? () => {
|
||||||
|
showCreateChannel = true;
|
||||||
|
}
|
||||||
|
: null}
|
||||||
|
onAddLabel={$i18n.t('Create Channel')}
|
||||||
|
>
|
||||||
|
{#each $channels as channel}
|
||||||
|
<ChannelItem
|
||||||
|
{channel}
|
||||||
|
onUpdate={async () => {
|
||||||
|
await initChannels();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</Folder>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Folder
|
||||||
|
collapsible={!search}
|
||||||
|
className="px-2 mt-0.5"
|
||||||
|
name={$i18n.t('Chats')}
|
||||||
|
on:import={(e) => {
|
||||||
|
importChatHandler(e.detail);
|
||||||
|
}}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
} else if (type === 'folder') {
|
||||||
|
if (folders[id].parent_id === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await updateFolderParentIdById(localStorage.token, id, null).catch(
|
||||||
|
(error) => {
|
||||||
|
toast.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
await initFolders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{#if $temporaryChatEnabled}
|
||||||
|
<div class="absolute z-40 w-full h-full flex justify-center"></div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if !search && $pinnedChats.length > 0}
|
{#if !search && $pinnedChats.length > 0}
|
||||||
<div class="flex flex-col space-y-1 rounded-xl">
|
<div class="flex flex-col space-y-1 rounded-xl">
|
||||||
<Folder
|
<Folder
|
||||||
@ -654,29 +734,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $config?.features?.enable_channels && ($user.role === 'admin' || $channels.length > 0) && !search}
|
|
||||||
<Folder
|
|
||||||
className="px-2 mt-0.5"
|
|
||||||
name={$i18n.t('Channels')}
|
|
||||||
dragAndDrop={false}
|
|
||||||
onAdd={$user.role === 'admin'
|
|
||||||
? () => {
|
|
||||||
showCreateChannel = true;
|
|
||||||
}
|
|
||||||
: null}
|
|
||||||
onAddLabel={$i18n.t('Create Channel')}
|
|
||||||
>
|
|
||||||
{#each $channels as channel}
|
|
||||||
<ChannelItem
|
|
||||||
{channel}
|
|
||||||
onUpdate={async () => {
|
|
||||||
await initChannels();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{/each}
|
|
||||||
</Folder>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if !search && folders}
|
{#if !search && folders}
|
||||||
<Folders
|
<Folders
|
||||||
{folders}
|
{folders}
|
||||||
@ -693,63 +750,6 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Folder
|
|
||||||
collapsible={!search}
|
|
||||||
className="px-2 mt-0.5"
|
|
||||||
name={$i18n.t('Chats')}
|
|
||||||
on:import={(e) => {
|
|
||||||
importChatHandler(e.detail);
|
|
||||||
}}
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
} else if (type === 'folder') {
|
|
||||||
if (folders[id].parent_id === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await updateFolderParentIdById(localStorage.token, id, null).catch(
|
|
||||||
(error) => {
|
|
||||||
toast.error(error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
await initFolders();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#if $temporaryChatEnabled}
|
|
||||||
<div class="absolute z-40 w-full h-full flex justify-center"></div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class=" flex-1 flex flex-col overflow-y-auto scrollbar-hidden">
|
<div class=" flex-1 flex flex-col overflow-y-auto scrollbar-hidden">
|
||||||
<div class="pt-1.5">
|
<div class="pt-1.5">
|
||||||
{#if $chats}
|
{#if $chats}
|
||||||
|
Loading…
Reference in New Issue
Block a user