fix: hide chat delete actions when the chat delete permission is disabled (#27714)
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
This commit is contained in:
6 files changed
+83
-71
No files matched your search
@@ -487,16 +487,18 @@
|
||||
<div class="flex items-center">{$i18n.t('Archive')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
draggable="false"
|
||||
class="flex h-[1.6875rem] w-full items-center gap-2 rounded-xl px-2 text-[0.8125rem] cursor-pointer select-none hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||
on:click={() => {
|
||||
deleteChatHandler();
|
||||
}}
|
||||
>
|
||||
<GarbageBin className="size-3.5" strokeWidth="1.5" />
|
||||
<div class="flex items-center">{$i18n.t('Delete')}</div>
|
||||
</button>
|
||||
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)}
|
||||
<button
|
||||
draggable="false"
|
||||
class="flex h-[1.6875rem] w-full items-center gap-2 rounded-xl px-2 text-[0.8125rem] cursor-pointer select-none hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||
on:click={() => {
|
||||
deleteChatHandler();
|
||||
}}
|
||||
>
|
||||
<GarbageBin className="size-3.5" strokeWidth="1.5" />
|
||||
<div class="flex items-center">{$i18n.t('Delete')}</div>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<hr class="border-gray-50/30 dark:border-gray-800/30 mx-1 my-0.5" />
|
||||
|
||||
|
||||
Reference in new issue
Block a user