mirror of
https://github.com/open-webui/open-webui
synced 2024-12-28 14:52:23 +00:00
refac
This commit is contained in:
parent
27d2fbbe33
commit
7083a61ddb
@ -15,7 +15,11 @@
|
||||
export let id = '';
|
||||
export let name = '';
|
||||
export let collapsible = true;
|
||||
export let onCreateFolder: null | Function = null;
|
||||
|
||||
export let onAddLabel: string = '';
|
||||
export let onAdd: null | Function = null;
|
||||
|
||||
export let dragAndDrop = true;
|
||||
|
||||
export let className = '';
|
||||
|
||||
@ -87,12 +91,18 @@
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
if (!dragAndDrop) {
|
||||
return;
|
||||
}
|
||||
folderElement.addEventListener('dragover', onDragOver);
|
||||
folderElement.addEventListener('drop', onDrop);
|
||||
folderElement.addEventListener('dragleave', onDragLeave);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (!dragAndDrop) {
|
||||
return;
|
||||
}
|
||||
folderElement.addEventListener('dragover', onDragOver);
|
||||
folderElement.removeEventListener('drop', onDrop);
|
||||
folderElement.removeEventListener('dragleave', onDragLeave);
|
||||
@ -133,15 +143,15 @@
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{#if onCreateFolder}
|
||||
{#if onAdd}
|
||||
<button
|
||||
class="absolute z-10 right-2 self-center flex items-center"
|
||||
on:pointerup={(e) => {
|
||||
e.stopPropagation();
|
||||
onCreateFolder();
|
||||
onAdd();
|
||||
}}
|
||||
>
|
||||
<Tooltip content={$i18n.t('New folder')}>
|
||||
<Tooltip content={onAddLabel}>
|
||||
<button
|
||||
class="p-0.5 dark:hover:bg-gray-850 rounded-lg touch-auto"
|
||||
on:click={(e) => {}}
|
||||
|
@ -67,6 +67,8 @@
|
||||
|
||||
let folders = {};
|
||||
|
||||
const createChannel = async () => {};
|
||||
|
||||
const initFolders = async () => {
|
||||
const folderList = await getFolders(localStorage.token).catch((error) => {
|
||||
toast.error(error);
|
||||
@ -521,6 +523,19 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="relative flex flex-col overflow-y-auto">
|
||||
<Folder
|
||||
collapsible={!search}
|
||||
className="px-2 mt-0.5"
|
||||
name={$i18n.t('Channels')}
|
||||
dragAndDrop={false}
|
||||
onAdd={createChannel}
|
||||
onAddLabel={$i18n.t('New Channel')}
|
||||
>
|
||||
channels
|
||||
</Folder>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="relative flex flex-col flex-1 overflow-y-auto {$temporaryChatEnabled
|
||||
? 'opacity-20'
|
||||
@ -530,7 +545,8 @@
|
||||
collapsible={!search}
|
||||
className="px-2 mt-0.5"
|
||||
name={$i18n.t('Chats')}
|
||||
onCreateFolder={createFolder}
|
||||
onAdd={createFolder}
|
||||
onAddLabel={$i18n.t('New Folder')}
|
||||
on:import={(e) => {
|
||||
importChatHandler(e.detail);
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user