mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-26 09:21:23 -04:00
refac
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import Tooltip from './Tooltip.svelte';
|
||||
export let state = true;
|
||||
export let disabled = false;
|
||||
export let id = '';
|
||||
export let ariaLabelledbyId = '';
|
||||
export let ariaLabel = '';
|
||||
@@ -33,10 +34,11 @@
|
||||
|
||||
<Switch.Root
|
||||
bind:checked={state}
|
||||
{disabled}
|
||||
{id}
|
||||
aria-labelledby={ariaLabelledbyId || undefined}
|
||||
aria-label={ariaLabel || undefined}
|
||||
class="focus-ring relative h-4 min-h-4 w-7 shrink-0 cursor-pointer rounded-full mx-[0.0625rem] transition-colors duration-150 disabled:cursor-not-allowed {($settings?.highContrastMode ??
|
||||
class="focus-ring relative h-4 min-h-4 w-7 shrink-0 cursor-pointer rounded-full mx-[0.0625rem] transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-50 {($settings?.highContrastMode ??
|
||||
false)
|
||||
? 'focus:outline focus:outline-2 focus:outline-gray-800! focus:dark:outline-gray-200!'
|
||||
: ''} {state ? 'bg-gray-900 dark:bg-white' : 'bg-gray-300 dark:bg-gray-700'}"
|
||||
|
||||
@@ -641,9 +641,10 @@
|
||||
{#if shiftKey}
|
||||
<Tooltip content={$i18n.t('Delete')}>
|
||||
<button
|
||||
class="flex size-6 items-center justify-center rounded-lg text-gray-400 transition dark:text-gray-500"
|
||||
class="flex size-6 items-center justify-center rounded-lg text-gray-400 transition dark:text-gray-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
type="button"
|
||||
aria-label={$i18n.t('Delete')}
|
||||
disabled={!prompt.write_access}
|
||||
on:click={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -675,6 +676,7 @@
|
||||
|
||||
<div class="ml-0.5 flex shrink-0 flex-row items-center gap-1.5 self-center">
|
||||
<PromptMenu
|
||||
writeAccess={prompt.write_access}
|
||||
show={openPromptMenuId === prompt.id}
|
||||
editHandler={() => {
|
||||
goto(`/workspace/prompts/${prompt.id}`);
|
||||
@@ -713,6 +715,7 @@
|
||||
<button
|
||||
class="flex h-6 items-center"
|
||||
type="button"
|
||||
disabled={!prompt.write_access}
|
||||
on:click={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
@@ -725,6 +728,8 @@
|
||||
>
|
||||
<Switch
|
||||
bind:state={prompt.is_active}
|
||||
disabled={!prompt.write_access}
|
||||
ariaLabel={$i18n.t('Enabled')}
|
||||
on:change={async () => {
|
||||
togglePromptById(localStorage.token, prompt.id);
|
||||
}}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let writeAccess = true;
|
||||
|
||||
export let editHandler: Function;
|
||||
export let shareHandler: Function;
|
||||
export let cloneHandler: Function;
|
||||
@@ -42,8 +44,9 @@
|
||||
<div slot="content">
|
||||
<DropdownMenu className="min-w-[10.625rem]">
|
||||
<button
|
||||
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[0.8125rem] hover:text-gray-900 dark:hover:text-gray-100"
|
||||
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[0.8125rem] enabled:hover:text-gray-900 dark:enabled:hover:text-gray-100 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
draggable="false"
|
||||
disabled={!writeAccess}
|
||||
on:click={() => {
|
||||
editHandler();
|
||||
closeMenu();
|
||||
@@ -69,8 +72,9 @@
|
||||
|
||||
{#if $config.features.enable_community_sharing}
|
||||
<button
|
||||
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[0.8125rem] hover:text-gray-900 dark:hover:text-gray-100"
|
||||
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[0.8125rem] enabled:hover:text-gray-900 dark:enabled:hover:text-gray-100 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
draggable="false"
|
||||
disabled={!writeAccess}
|
||||
on:click={() => {
|
||||
shareHandler();
|
||||
closeMenu();
|
||||
@@ -110,8 +114,9 @@
|
||||
<hr class="border-gray-50 dark:border-gray-850/30 mx-1 my-0.5" />
|
||||
|
||||
<button
|
||||
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[0.8125rem] hover:text-gray-900 dark:hover:text-gray-100"
|
||||
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[0.8125rem] enabled:hover:text-gray-900 dark:enabled:hover:text-gray-100 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
draggable="false"
|
||||
disabled={!writeAccess}
|
||||
on:click={() => {
|
||||
deleteHandler();
|
||||
closeMenu();
|
||||
|
||||
Reference in New Issue
Block a user