2024-12-23 05:33:13 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { getContext } from 'svelte';
|
|
|
|
|
import { toast } from 'svelte-sonner';
|
|
|
|
|
|
2025-08-07 23:53:09 +00:00
|
|
|
import { mobile, showArchivedChats, showSidebar, user } from '$lib/stores';
|
2024-12-23 05:33:13 +00:00
|
|
|
|
|
|
|
|
import { slide } from 'svelte/transition';
|
|
|
|
|
import { page } from '$app/stores';
|
|
|
|
|
|
2025-11-25 08:46:30 +00:00
|
|
|
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
|
|
|
|
|
2024-12-23 05:33:13 +00:00
|
|
|
import UserMenu from '$lib/components/layout/Sidebar/UserMenu.svelte';
|
|
|
|
|
import PencilSquare from '../icons/PencilSquare.svelte';
|
2025-08-06 23:35:12 +00:00
|
|
|
import Tooltip from '../common/Tooltip.svelte';
|
|
|
|
|
import Sidebar from '../icons/Sidebar.svelte';
|
2025-11-25 08:46:30 +00:00
|
|
|
import Hashtag from '../icons/Hashtag.svelte';
|
|
|
|
|
import Lock from '../icons/Lock.svelte';
|
|
|
|
|
import UserAlt from '../icons/UserAlt.svelte';
|
2025-11-25 09:38:07 +00:00
|
|
|
import ChannelInfoModal from './ChannelInfoModal.svelte';
|
2025-11-27 12:27:32 +00:00
|
|
|
import Users from '../icons/Users.svelte';
|
2025-11-28 14:58:44 +00:00
|
|
|
import Pin from '../icons/Pin.svelte';
|
|
|
|
|
import PinnedMessagesModal from './PinnedMessagesModal.svelte';
|
2024-12-23 05:33:13 +00:00
|
|
|
|
|
|
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
2025-11-28 14:58:44 +00:00
|
|
|
let showChannelPinnedMessagesModal = false;
|
2025-11-25 09:38:07 +00:00
|
|
|
let showChannelInfoModal = false;
|
|
|
|
|
|
2024-12-23 05:33:13 +00:00
|
|
|
export let channel;
|
2025-11-28 15:04:06 +00:00
|
|
|
|
|
|
|
|
export let onPin = (messageId, pinned) => {};
|
2024-12-23 05:33:13 +00:00
|
|
|
</script>
|
|
|
|
|
|
2025-11-28 15:04:06 +00:00
|
|
|
<PinnedMessagesModal bind:show={showChannelPinnedMessagesModal} {channel} {onPin} />
|
2025-11-25 09:38:07 +00:00
|
|
|
<ChannelInfoModal bind:show={showChannelInfoModal} {channel} />
|
2025-11-28 14:58:44 +00:00
|
|
|
<nav class="sticky top-0 z-30 w-full px-1.5 py-1 -mb-8 flex items-center drag-region flex flex-col">
|
2024-12-23 05:33:13 +00:00
|
|
|
<div
|
2025-11-02 15:22:22 +00:00
|
|
|
id="navbar-bg-gradient-to-b"
|
2025-02-16 04:35:10 +00:00
|
|
|
class=" bg-linear-to-b via-50% from-white via-white to-transparent dark:from-gray-900 dark:via-gray-900 dark:to-transparent pointer-events-none absolute inset-0 -bottom-7 z-[-1]"
|
2024-12-23 05:33:13 +00:00
|
|
|
></div>
|
|
|
|
|
|
|
|
|
|
<div class=" flex max-w-full w-full mx-auto px-1 pt-0.5 bg-transparent">
|
|
|
|
|
<div class="flex items-center w-full max-w-full">
|
2025-08-07 23:53:09 +00:00
|
|
|
{#if $mobile}
|
|
|
|
|
<div
|
|
|
|
|
class="{$showSidebar
|
|
|
|
|
? 'md:hidden'
|
|
|
|
|
: ''} mr-1.5 mt-0.5 self-start flex flex-none items-center text-gray-600 dark:text-gray-400"
|
|
|
|
|
>
|
2025-08-08 10:04:44 +00:00
|
|
|
<Tooltip
|
|
|
|
|
content={$showSidebar ? $i18n.t('Close Sidebar') : $i18n.t('Open Sidebar')}
|
|
|
|
|
interactive={true}
|
|
|
|
|
>
|
2025-08-07 23:53:09 +00:00
|
|
|
<button
|
|
|
|
|
id="sidebar-toggle-button"
|
|
|
|
|
class=" cursor-pointer flex rounded-lg hover:bg-gray-100 dark:hover:bg-gray-850 transition cursor-"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
showSidebar.set(!$showSidebar);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" self-center p-1.5">
|
|
|
|
|
<Sidebar />
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-12-23 05:33:13 +00:00
|
|
|
|
|
|
|
|
<div
|
2025-11-27 12:27:32 +00:00
|
|
|
class="flex-1 overflow-hidden max-w-full py-0.5 flex items-center
|
2024-12-23 05:33:13 +00:00
|
|
|
{$showSidebar ? 'ml-1' : ''}
|
|
|
|
|
"
|
|
|
|
|
>
|
2024-12-23 08:35:03 +00:00
|
|
|
{#if channel}
|
2025-11-25 08:46:30 +00:00
|
|
|
<div class="flex items-center gap-0.5 shrink-0">
|
2025-11-27 12:27:32 +00:00
|
|
|
{#if channel?.type === 'dm'}
|
|
|
|
|
{#if channel?.users}
|
|
|
|
|
<div class="flex mr-1.5">
|
|
|
|
|
{#each channel.users.filter((u) => u.id !== $user?.id).slice(0, 2) as u, index}
|
|
|
|
|
<img
|
|
|
|
|
src={`${WEBUI_API_BASE_URL}/users/${u.id}/profile/image`}
|
|
|
|
|
alt={u.name}
|
|
|
|
|
class=" size-6.5 rounded-full border-2 border-white dark:border-gray-900 {index ===
|
|
|
|
|
1
|
|
|
|
|
? '-ml-3'
|
|
|
|
|
: ''}"
|
|
|
|
|
/>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
2025-11-25 08:46:30 +00:00
|
|
|
{:else}
|
2025-11-27 12:27:32 +00:00
|
|
|
<Users className="size-4 ml-1 mr-0.5" strokeWidth="2" />
|
2025-11-25 08:46:30 +00:00
|
|
|
{/if}
|
2025-11-27 12:27:32 +00:00
|
|
|
{:else}
|
|
|
|
|
<div class=" size-4.5 justify-center flex items-center">
|
|
|
|
|
{#if channel?.access_control === null}
|
|
|
|
|
<Hashtag className="size-3.5" strokeWidth="2.5" />
|
|
|
|
|
{:else}
|
|
|
|
|
<Lock className="size-5" strokeWidth="2" />
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2025-11-25 08:46:30 +00:00
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class=" text-left self-center overflow-hidden w-full line-clamp-1 capitalize flex-1"
|
|
|
|
|
>
|
2025-11-27 12:27:32 +00:00
|
|
|
{#if channel?.name}
|
|
|
|
|
{channel.name}
|
|
|
|
|
{:else}
|
|
|
|
|
{channel?.users
|
|
|
|
|
?.filter((u) => u.id !== $user?.id)
|
|
|
|
|
.map((u) => u.name)
|
|
|
|
|
.join(', ')}
|
|
|
|
|
{/if}
|
2025-11-25 08:46:30 +00:00
|
|
|
</div>
|
2024-12-23 08:35:03 +00:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-12-23 05:33:13 +00:00
|
|
|
</div>
|
|
|
|
|
|
2025-11-25 08:46:30 +00:00
|
|
|
<div class="self-start flex flex-none items-center text-gray-600 dark:text-gray-400 gap-1">
|
2025-11-28 14:58:44 +00:00
|
|
|
<Tooltip content={$i18n.t('Pinned Messages')}>
|
|
|
|
|
<button
|
|
|
|
|
class=" flex cursor-pointer py-1.5 px-1.5 border dark:border-gray-850 border-gray-50 rounded-xl text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
|
|
|
|
aria-label="Pinned Messages"
|
|
|
|
|
type="button"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
showChannelPinnedMessagesModal = true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" flex items-center gap-0.5 m-auto self-center">
|
|
|
|
|
<Pin className=" size-4" strokeWidth="1.5" />
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
2025-11-25 08:46:30 +00:00
|
|
|
{#if channel?.user_count !== undefined}
|
|
|
|
|
<Tooltip content={$i18n.t('Users')}>
|
|
|
|
|
<button
|
|
|
|
|
class=" flex cursor-pointer py-1 px-1.5 border dark:border-gray-850 border-gray-50 rounded-xl text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
|
|
|
|
aria-label="User Count"
|
2025-11-25 09:38:07 +00:00
|
|
|
type="button"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
showChannelInfoModal = true;
|
|
|
|
|
}}
|
2025-11-25 08:46:30 +00:00
|
|
|
>
|
|
|
|
|
<div class=" flex items-center gap-0.5 m-auto self-center">
|
|
|
|
|
<UserAlt className=" size-4" strokeWidth="1.5" />
|
|
|
|
|
|
|
|
|
|
<div class="text-sm">
|
|
|
|
|
{channel.user_count}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2024-12-23 05:33:13 +00:00
|
|
|
{#if $user !== undefined}
|
|
|
|
|
<UserMenu
|
2025-05-23 12:49:11 +00:00
|
|
|
className="max-w-[240px]"
|
2025-04-01 03:32:12 +00:00
|
|
|
role={$user?.role}
|
2025-05-23 12:49:11 +00:00
|
|
|
help={true}
|
2024-12-23 05:33:13 +00:00
|
|
|
on:show={(e) => {
|
|
|
|
|
if (e.detail === 'archived-chat') {
|
|
|
|
|
showArchivedChats.set(true);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
class="select-none flex rounded-xl p-1.5 w-full hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
|
|
|
|
aria-label="User Menu"
|
|
|
|
|
>
|
|
|
|
|
<div class=" self-center">
|
|
|
|
|
<img
|
2025-11-21 01:43:59 +00:00
|
|
|
src={`${WEBUI_API_BASE_URL}/users/${$user?.id}/profile/image`}
|
2024-12-23 05:33:13 +00:00
|
|
|
class="size-6 object-cover rounded-full"
|
|
|
|
|
alt="User profile"
|
|
|
|
|
draggable="false"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</UserMenu>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-01-14 02:19:46 +00:00
|
|
|
</nav>
|