mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
This change introduces a visual warning in the group settings page. The warning appears when an admin attempts to disable a permission for a group that is already enabled in the default 'user' group. This is necessary because permissions are additive, and disabling a permission in a specific group will not revoke it if it's enabled in the default group. To achieve this, the following changes were made: - A new `PermissionSwitch.svelte` component was created to encapsulate the permission switch and its warning logic, avoiding redundant code. - The `Groups.svelte` component was updated to correctly fetch the default user group's permissions. - The `Permissions.svelte` component was refactored to use the new `PermissionSwitch.svelte` component, making the code cleaner and more maintainable.
38 lines
No EOL
1 KiB
Svelte
38 lines
No EOL
1 KiB
Svelte
<script lang="ts">
|
|
import { getContext } from 'svelte';
|
|
const i18n = getContext('i18n');
|
|
|
|
import Switch from '$lib/components/common/Switch.svelte';
|
|
import Warning from '$lib/components/common/Warning.svelte';
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
|
|
export let label = '';
|
|
export let state = false;
|
|
export let defaultState = undefined;
|
|
export let tooltip = '';
|
|
</script>
|
|
|
|
<div class="flex w-full flex-col">
|
|
{#if tooltip}
|
|
<Tooltip content={tooltip} placement="top-start" className="flex w-full justify-between pr-2">
|
|
<div class="self-center text-xs font-medium">
|
|
{label}
|
|
</div>
|
|
<Switch bind:state />
|
|
</Tooltip>
|
|
{:else}
|
|
<div class="flex w-full justify-between pr-2">
|
|
<div class="self-center text-xs font-medium">
|
|
{label}
|
|
</div>
|
|
<Switch bind:state />
|
|
</div>
|
|
{/if}
|
|
{#if defaultState && !state}
|
|
<div class="pb-1 pl-1 pr-2 pt-1">
|
|
<Warning
|
|
text={$i18n.t('This permission is enabled for the default "user" role and will remain active.')}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</div> |