mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-28 06:22:33 +00:00
fix: temporary chat and delete chat shortcuts show while not allowed (#32978)
* fix: temporary chat and delete chat shortcuts show while not allowed The keyboard shortcuts list showed "New Temporary Chat" and "Delete Chat" to users who may not use temporary chats or delete chats, and pressing those shortcuts neither opened a temporary chat nor deleted anything for them. Both entries now only show to users with the matching permission, and the settings search skips them otherwise. Refs #32830 * fix: new temporary chat shortcut does nothing without the permission Users without the temporary chat permission were sent to a new chat by the New Temporary Chat shortcut; it now does nothing for them.
This commit is contained in:
parent
a39c50235e
commit
159a29ed06
3 changed files with 19 additions and 2 deletions
|
|
@ -14,7 +14,8 @@
|
|||
shortcuts
|
||||
} from '$lib/shortcuts';
|
||||
import type { KeybindingsMap, ShortcutDefinition } from '$lib/shortcuts';
|
||||
import { settings } from '$lib/stores';
|
||||
import { settings, user } from '$lib/stores';
|
||||
import { canManageChats, canUseTemporaryChats } from '$lib/utils/settings-access';
|
||||
import Switch from '$lib/components/common/Switch.svelte';
|
||||
import ShortcutItem from '../ShortcutItem.svelte';
|
||||
|
||||
|
|
@ -44,7 +45,16 @@
|
|||
});
|
||||
|
||||
$: {
|
||||
const allShortcuts = Object.entries(shortcuts).filter(([, shortcut]) => {
|
||||
const allShortcuts = Object.entries(shortcuts).filter(([id, shortcut]) => {
|
||||
if (
|
||||
id === Shortcut.NEW_TEMPORARY_CHAT &&
|
||||
!canUseTemporaryChats({ user: $user, config: null })
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (id === Shortcut.DELETE_CHAT && !canManageChats({ user: $user, config: null }, 'delete')) {
|
||||
return false;
|
||||
}
|
||||
if (!shortcut.setting) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,5 +81,8 @@ export function canSearchSetting(
|
|||
)
|
||||
return canUseCalls(context);
|
||||
if (stem === 'settings.personal.interface.webSearchInChat') return !!canUseWebSearch(context);
|
||||
if (stem === 'settings.personal.shortcuts.newTemporaryChat')
|
||||
return !!canUseTemporaryChats(context);
|
||||
if (stem === 'settings.personal.shortcuts.deleteChat') return canManageChats(context, 'delete');
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
import UpdateInfoToast from '$lib/components/layout/UpdateInfoToast.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { loadKeybindings, matchKeybinding, Shortcut } from '$lib/shortcuts';
|
||||
import { canUseTemporaryChats } from '$lib/utils/settings-access';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
|
|
@ -350,6 +351,9 @@
|
|||
} else if (shortcut === Shortcut.NEW_TEMPORARY_CHAT) {
|
||||
console.log('Shortcut triggered: NEW_TEMPORARY_CHAT');
|
||||
event.preventDefault();
|
||||
if (!canUseTemporaryChats({ user: $user, config: null })) {
|
||||
return;
|
||||
}
|
||||
if ($user?.role !== 'admin' && $user?.permissions?.chat?.temporary_enforced) {
|
||||
temporaryChatEnabled.set(true);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue