From a3d33b4cf37baee8077ce0406b85da70c860b862 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Tue, 11 Aug 2026 01:24:02 -0400 Subject: [PATCH] fix: hide chat delete actions when the chat delete permission is disabled (#27714) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The chat delete endpoints gate on chat.delete for non-admins, but none of the UI affordances that reach them were conditioned on it, so a user without the permission is offered controls that always fail with "Access prohibited". Gates every entry point on the same condition the backend enforces, matching the existing chat.share / chat.export / chat.import gates in the same components: - Sidebar chat menu (ChatMenu) Delete item — also covers the Search modal's menu, which reuses ChatMenu - Sidebar Shift+hover inline Delete button (ChatItem) - Sidebar hidden #delete-chat-button keyboard-shortcut target (ChatItem) - Chat navbar menu Delete item (Navbar/Menu) - Search modal Shift-held inline Delete button (SearchModal) - Settings -> Data Controls -> Delete All Chats - Settings -> Archived Chats per-row Delete --- .../chat/Settings/ArchivedChats.svelte | 30 ++++++++++--------- .../chat/Settings/DataControls.svelte | 28 +++++++++-------- src/lib/components/layout/Navbar/Menu.svelte | 22 +++++++------- src/lib/components/layout/SearchModal.svelte | 24 ++++++++------- .../components/layout/Sidebar/ChatItem.svelte | 28 +++++++++-------- .../components/layout/Sidebar/ChatMenu.svelte | 22 +++++++------- 6 files changed, 83 insertions(+), 71 deletions(-) diff --git a/src/lib/components/chat/Settings/ArchivedChats.svelte b/src/lib/components/chat/Settings/ArchivedChats.svelte index 677e53a046..0864e4623e 100644 --- a/src/lib/components/chat/Settings/ArchivedChats.svelte +++ b/src/lib/components/chat/Settings/ArchivedChats.svelte @@ -19,7 +19,7 @@ getArchivedChatList, unarchiveAllChats } from '$lib/apis/chats'; - import { chatId, showSettings } from '$lib/stores'; + import { chatId, showSettings, user } from '$lib/stores'; import { refreshChatList } from '$lib/stores/chatList'; import { formatNumber } from '$lib/utils'; import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; @@ -348,19 +348,21 @@ - - - + {#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)} + + + + {/if} {/each} diff --git a/src/lib/components/chat/Settings/DataControls.svelte b/src/lib/components/chat/Settings/DataControls.svelte index 5846f73e44..569c829ec3 100644 --- a/src/lib/components/chat/Settings/DataControls.svelte +++ b/src/lib/components/chat/Settings/DataControls.svelte @@ -216,20 +216,22 @@ - - - + + + {/if} diff --git a/src/lib/components/layout/Navbar/Menu.svelte b/src/lib/components/layout/Navbar/Menu.svelte index 351758d59a..f4f03052d2 100644 --- a/src/lib/components/layout/Navbar/Menu.svelte +++ b/src/lib/components/layout/Navbar/Menu.svelte @@ -487,16 +487,18 @@
{$i18n.t('Archive')}
- + {#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)} + + {/if}
diff --git a/src/lib/components/layout/SearchModal.svelte b/src/lib/components/layout/SearchModal.svelte index b5036b5032..9c1e48ca29 100644 --- a/src/lib/components/layout/SearchModal.svelte +++ b/src/lib/components/layout/SearchModal.svelte @@ -786,17 +786,19 @@ - - - + {#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)} + + + + {/if} {:else}
diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index db5bd995b9..9d3fc269e1 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -705,18 +705,20 @@ - - - + {#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)} + + + + {/if}
{:else}
@@ -756,7 +758,7 @@ - {#if id === $chatId} + {#if id === $chatId && ($user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true))}
- + {#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)} + + {/if}