refac
This commit is contained in:
1 parent
8dd862d338
commit
9f17c5960a
3 files changed
+48
-94
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
|
|
||||||
import { mobile, showSettings, showSidebar, user } from '$lib/stores';
|
import { mobile, showSidebar, user } from '$lib/stores';
|
||||||
|
|
||||||
import { slide } from 'svelte/transition';
|
import { slide } from 'svelte/transition';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
@@ -196,16 +196,7 @@
|
|||||||
|
|
||||||
{#if $user !== undefined}
|
{#if $user !== undefined}
|
||||||
<div>
|
<div>
|
||||||
<UserMenu
|
<UserMenu className="w-[240px]" role={$user?.role} help={true}>
|
||||||
className="w-[240px]"
|
|
||||||
role={$user?.role}
|
|
||||||
help={true}
|
|
||||||
on:show={(e) => {
|
|
||||||
if (e.detail === 'archived-chat') {
|
|
||||||
showSettings.set('archived_chats');
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button
|
<button
|
||||||
class="select-none flex rounded-xl p-1.5 w-full hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
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"
|
aria-label="User Menu"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
user,
|
user,
|
||||||
chats,
|
chats,
|
||||||
settings,
|
settings,
|
||||||
showSettings,
|
|
||||||
chatId,
|
chatId,
|
||||||
tags,
|
tags,
|
||||||
folders as _folders,
|
folders as _folders,
|
||||||
@@ -954,11 +953,6 @@
|
|||||||
role={$user?.role}
|
role={$user?.role}
|
||||||
profile={$config?.features?.enable_user_status ?? true}
|
profile={$config?.features?.enable_user_status ?? true}
|
||||||
showActiveUsers={false}
|
showActiveUsers={false}
|
||||||
on:show={(e) => {
|
|
||||||
if (e.detail === 'archived-chat') {
|
|
||||||
showSettings.set('archived_chats');
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -1577,11 +1571,6 @@
|
|||||||
profile={$config?.features?.enable_user_status ?? true}
|
profile={$config?.features?.enable_user_status ?? true}
|
||||||
showActiveUsers={false}
|
showActiveUsers={false}
|
||||||
className="w-[calc(var(--sidebar-width)-1rem)]"
|
className="w-[calc(var(--sidebar-width)-1rem)]"
|
||||||
on:show={(e) => {
|
|
||||||
if (e.detail === 'archived-chat') {
|
|
||||||
showSettings.set('archived_chats');
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher, getContext, onMount, tick } from 'svelte';
|
import { getContext, onMount, tick } from 'svelte';
|
||||||
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { fade, slide } from 'svelte/transition';
|
import { fade, slide } from 'svelte/transition';
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||||
import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
|
|
||||||
import QuestionMarkCircle from '$lib/components/icons/QuestionMarkCircle.svelte';
|
import QuestionMarkCircle from '$lib/components/icons/QuestionMarkCircle.svelte';
|
||||||
import Map from '$lib/components/icons/Map.svelte';
|
import Map from '$lib/components/icons/Map.svelte';
|
||||||
import Keyboard from '$lib/components/icons/Keyboard.svelte';
|
import Keyboard from '$lib/components/icons/Keyboard.svelte';
|
||||||
@@ -57,8 +56,6 @@
|
|||||||
let showUserStatusModal = false;
|
let showUserStatusModal = false;
|
||||||
let shiftKey = false;
|
let shiftKey = false;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
|
|
||||||
const DEFAULT_PINNED_ITEMS = ['notes', 'workspace'];
|
const DEFAULT_PINNED_ITEMS = ['notes', 'workspace'];
|
||||||
|
|
||||||
$: pinnedItems = $settings?.pinnedMenuItems ?? DEFAULT_PINNED_ITEMS;
|
$: pinnedItems = $settings?.pinnedMenuItems ?? DEFAULT_PINNED_ITEMS;
|
||||||
@@ -224,74 +221,6 @@
|
|||||||
<hr class="border-gray-50/30 dark:border-gray-800/30 my-0.5 mx-1 p-0" />
|
<hr class="border-gray-50/30 dark:border-gray-800/30 my-0.5 mx-1 p-0" />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<button
|
|
||||||
class="flex h-[1.6875rem] items-center gap-2 rounded-xl px-2 text-[13px] w-full hover:bg-gray-50/40 dark:hover:bg-gray-800/40 transition cursor-pointer select-none"
|
|
||||||
type="button"
|
|
||||||
on:click={async () => {
|
|
||||||
show = false;
|
|
||||||
|
|
||||||
await showSettings.set(true);
|
|
||||||
|
|
||||||
if ($mobile) {
|
|
||||||
await tick();
|
|
||||||
showSidebar.set(false);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="self-center">
|
|
||||||
<Settings className="size-3.5" strokeWidth="1.5" />
|
|
||||||
</div>
|
|
||||||
<div class=" self-center truncate">{$i18n.t('Settings')}</div>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{#if role === 'admin'}
|
|
||||||
<a
|
|
||||||
href="/admin"
|
|
||||||
draggable="false"
|
|
||||||
class="flex h-[1.6875rem] items-center gap-2 rounded-xl px-2 text-[13px] w-full hover:bg-gray-50/40 dark:hover:bg-gray-800/40 transition cursor-pointer select-none"
|
|
||||||
on:click={async (e) => {
|
|
||||||
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.preventDefault();
|
|
||||||
show = false;
|
|
||||||
goto('/admin');
|
|
||||||
if ($mobile) {
|
|
||||||
await tick();
|
|
||||||
showSidebar.set(false);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="self-center">
|
|
||||||
<UserGroup className="size-3.5" strokeWidth="1.5" />
|
|
||||||
</div>
|
|
||||||
<div class=" self-center truncate">{$i18n.t('Admin Panel')}</div>
|
|
||||||
</a>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<button
|
|
||||||
class="flex h-[1.6875rem] items-center gap-2 rounded-xl px-2 text-[13px] w-full hover:bg-gray-50/40 dark:hover:bg-gray-800/40 transition cursor-pointer select-none"
|
|
||||||
type="button"
|
|
||||||
on:click={async () => {
|
|
||||||
show = false;
|
|
||||||
|
|
||||||
dispatch('show', 'archived-chat');
|
|
||||||
|
|
||||||
if ($mobile) {
|
|
||||||
await tick();
|
|
||||||
|
|
||||||
showSidebar.set(false);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="self-center">
|
|
||||||
<ArchiveBox className="size-3.5" strokeWidth="1.5" />
|
|
||||||
</div>
|
|
||||||
<div class=" self-center truncate">{$i18n.t('Archived Chats')}</div>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<hr class="border-gray-50/30 dark:border-gray-800/30 my-0.5 mx-1 p-0" />
|
|
||||||
|
|
||||||
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.models || $user?.permissions?.workspace?.knowledge || $user?.permissions?.workspace?.prompts || $user?.permissions?.workspace?.tools || $user?.permissions?.workspace?.skills}
|
{#if $user?.role === 'admin' || $user?.permissions?.workspace?.models || $user?.permissions?.workspace?.knowledge || $user?.permissions?.workspace?.prompts || $user?.permissions?.workspace?.tools || $user?.permissions?.workspace?.skills}
|
||||||
<div class="flex items-center w-full">
|
<div class="flex items-center w-full">
|
||||||
<a
|
<a
|
||||||
@@ -610,6 +539,51 @@
|
|||||||
|
|
||||||
<hr class="border-gray-50/30 dark:border-gray-800/30 my-0.5 mx-1 p-0" />
|
<hr class="border-gray-50/30 dark:border-gray-800/30 my-0.5 mx-1 p-0" />
|
||||||
|
|
||||||
|
{#if role === 'admin'}
|
||||||
|
<a
|
||||||
|
href="/admin"
|
||||||
|
draggable="false"
|
||||||
|
class="flex h-[1.6875rem] items-center gap-2 rounded-xl px-2 text-[13px] w-full hover:bg-gray-50/40 dark:hover:bg-gray-800/40 transition cursor-pointer select-none"
|
||||||
|
on:click={async (e) => {
|
||||||
|
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
show = false;
|
||||||
|
goto('/admin');
|
||||||
|
if ($mobile) {
|
||||||
|
await tick();
|
||||||
|
showSidebar.set(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="self-center">
|
||||||
|
<UserGroup className="size-3.5" strokeWidth="1.5" />
|
||||||
|
</div>
|
||||||
|
<div class=" self-center truncate">{$i18n.t('Admin Panel')}</div>
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="flex h-[1.6875rem] items-center gap-2 rounded-xl px-2 text-[13px] w-full hover:bg-gray-50/40 dark:hover:bg-gray-800/40 transition cursor-pointer select-none"
|
||||||
|
type="button"
|
||||||
|
on:click={async () => {
|
||||||
|
show = false;
|
||||||
|
|
||||||
|
await showSettings.set(true);
|
||||||
|
|
||||||
|
if ($mobile) {
|
||||||
|
await tick();
|
||||||
|
showSidebar.set(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="self-center">
|
||||||
|
<Settings className="size-3.5" strokeWidth="1.5" />
|
||||||
|
</div>
|
||||||
|
<div class=" self-center truncate">{$i18n.t('Settings')}</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="flex h-[1.6875rem] items-center gap-2 rounded-xl px-2 text-[13px] w-full hover:bg-gray-50/40 dark:hover:bg-gray-800/40 transition cursor-pointer select-none"
|
class="flex h-[1.6875rem] items-center gap-2 rounded-xl px-2 text-[13px] w-full hover:bg-gray-50/40 dark:hover:bg-gray-800/40 transition cursor-pointer select-none"
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in new issue
Block a user