open-webui/src/lib/components/layout/Sidebar/ChatMenu.svelte

83 lines
2.2 KiB
Svelte
Raw Normal View History

2024-03-16 08:57:26 +00:00
<script lang="ts">
import { DropdownMenu } from 'bits-ui';
2024-03-24 22:43:03 +00:00
import { flyAndScale } from '$lib/utils/transitions';
2024-04-29 17:15:58 +00:00
import { getContext } from 'svelte';
2024-03-16 08:57:26 +00:00
import Dropdown from '$lib/components/common/Dropdown.svelte';
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
import Pencil from '$lib/components/icons/Pencil.svelte';
2024-03-16 09:35:40 +00:00
import Tooltip from '$lib/components/common/Tooltip.svelte';
2024-04-16 21:31:06 +00:00
import Tags from '$lib/components/chat/Tags.svelte';
2024-04-20 19:40:06 +00:00
import Share from '$lib/components/icons/Share.svelte';
2024-03-16 08:57:26 +00:00
const i18n = getContext('i18n');
2024-04-20 19:40:06 +00:00
export let shareHandler: Function;
2024-03-16 08:57:26 +00:00
export let renameHandler: Function;
export let deleteHandler: Function;
2024-03-16 09:43:51 +00:00
export let onClose: Function;
2024-04-16 21:31:06 +00:00
export let chatId = '';
let show = false;
2024-03-16 08:57:26 +00:00
</script>
2024-03-16 09:43:51 +00:00
<Dropdown
2024-04-16 21:31:06 +00:00
bind:show
2024-03-16 09:43:51 +00:00
on:change={(e) => {
if (e.detail === false) {
onClose();
}
}}
>
<Tooltip content={$i18n.t('More')}>
2024-03-16 09:35:40 +00:00
<slot />
</Tooltip>
2024-03-16 08:57:26 +00:00
<div slot="content">
<DropdownMenu.Content
2024-04-20 19:40:06 +00:00
class="w-full max-w-[180px] rounded-lg px-1 py-1.5 border border-gray-300/30 dark:border-gray-700/50 z-50 bg-white dark:bg-gray-900 dark:text-white shadow"
2024-03-18 17:49:39 +00:00
sideOffset={-2}
2024-03-16 08:57:26 +00:00
side="bottom"
align="start"
2024-03-24 22:43:03 +00:00
transition={flyAndScale}
2024-03-16 08:57:26 +00:00
>
2024-04-20 19:40:06 +00:00
<DropdownMenu.Item
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
on:click={() => {
shareHandler();
}}
>
<Share />
<div class="flex items-center">Share</div>
</DropdownMenu.Item>
2024-03-16 08:57:26 +00:00
<DropdownMenu.Item
2024-04-14 20:41:58 +00:00
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
2024-03-16 08:57:26 +00:00
on:click={() => {
renameHandler();
}}
>
<Pencil strokeWidth="2" />
<div class="flex items-center">Rename</div>
</DropdownMenu.Item>
<DropdownMenu.Item
2024-04-14 20:41:58 +00:00
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer dark:hover:bg-gray-850 rounded-md"
2024-03-16 08:57:26 +00:00
on:click={() => {
deleteHandler();
}}
>
<GarbageBin strokeWidth="2" />
<div class="flex items-center">Delete</div>
</DropdownMenu.Item>
2024-04-16 21:31:06 +00:00
<hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />
<div class="flex p-1">
<Tags {chatId} />
</div>
2024-03-16 08:57:26 +00:00
</DropdownMenu.Content>
</div>
</Dropdown>