mirror of
https://github.com/open-webui/open-webui
synced 2025-03-16 10:28:28 +00:00
enh: shiftkey quick delete for tools and functions
This commit is contained in:
parent
5a6ece9513
commit
0554cc6128
@ -29,9 +29,12 @@
|
|||||||
import ManifestModal from './common/ManifestModal.svelte';
|
import ManifestModal from './common/ManifestModal.svelte';
|
||||||
import Heart from '../icons/Heart.svelte';
|
import Heart from '../icons/Heart.svelte';
|
||||||
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
||||||
|
import GarbageBin from '../icons/GarbageBin.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
let shiftKey = false;
|
||||||
|
|
||||||
let functionsImportInputElement: HTMLInputElement;
|
let functionsImportInputElement: HTMLInputElement;
|
||||||
let importFiles;
|
let importFiles;
|
||||||
|
|
||||||
@ -135,6 +138,34 @@
|
|||||||
models.set(await getModels(localStorage.token));
|
models.set(await getModels(localStorage.token));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const onKeyDown = (event) => {
|
||||||
|
if (event.key === 'Shift') {
|
||||||
|
shiftKey = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onKeyUp = (event) => {
|
||||||
|
if (event.key === 'Shift') {
|
||||||
|
shiftKey = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onBlur = () => {
|
||||||
|
shiftKey = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('keydown', onKeyDown);
|
||||||
|
window.addEventListener('keyup', onKeyUp);
|
||||||
|
window.addEventListener('blur', onBlur);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('keydown', onKeyDown);
|
||||||
|
window.removeEventListener('keyup', onKeyUp);
|
||||||
|
window.removeEventListener('blur', onBlur);
|
||||||
|
};
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@ -234,6 +265,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="flex flex-row gap-0.5 self-center">
|
<div class="flex flex-row gap-0.5 self-center">
|
||||||
|
{#if shiftKey}
|
||||||
|
<Tooltip content={$i18n.t('Delete')}>
|
||||||
|
<button
|
||||||
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
on:click={() => {
|
||||||
|
deleteHandler(func);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GarbageBin />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
{:else}
|
||||||
{#if func?.meta?.manifest?.funding_url ?? false}
|
{#if func?.meta?.manifest?.funding_url ?? false}
|
||||||
<Tooltip content={$i18n.t('Support')}>
|
<Tooltip content={$i18n.t('Support')}>
|
||||||
<button
|
<button
|
||||||
@ -312,6 +356,7 @@
|
|||||||
<EllipsisHorizontal className="size-5" />
|
<EllipsisHorizontal className="size-5" />
|
||||||
</button>
|
</button>
|
||||||
</FunctionMenu>
|
</FunctionMenu>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class=" self-center mx-1">
|
<div class=" self-center mx-1">
|
||||||
<Tooltip content={func.is_active ? $i18n.t('Enabled') : $i18n.t('Disabled')}>
|
<Tooltip content={func.is_active ? $i18n.t('Enabled') : $i18n.t('Disabled')}>
|
||||||
|
@ -24,9 +24,12 @@
|
|||||||
import ManifestModal from './common/ManifestModal.svelte';
|
import ManifestModal from './common/ManifestModal.svelte';
|
||||||
import Heart from '../icons/Heart.svelte';
|
import Heart from '../icons/Heart.svelte';
|
||||||
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
||||||
|
import GarbageBin from '../icons/GarbageBin.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
let shiftKey = false;
|
||||||
|
|
||||||
let toolsImportInputElement: HTMLInputElement;
|
let toolsImportInputElement: HTMLInputElement;
|
||||||
let importFiles;
|
let importFiles;
|
||||||
|
|
||||||
@ -107,6 +110,34 @@
|
|||||||
tools.set(await getTools(localStorage.token));
|
tools.set(await getTools(localStorage.token));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const onKeyDown = (event) => {
|
||||||
|
if (event.key === 'Shift') {
|
||||||
|
shiftKey = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onKeyUp = (event) => {
|
||||||
|
if (event.key === 'Shift') {
|
||||||
|
shiftKey = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onBlur = () => {
|
||||||
|
shiftKey = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('keydown', onKeyDown);
|
||||||
|
window.addEventListener('keyup', onKeyUp);
|
||||||
|
window.addEventListener('blur', onBlur);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('keydown', onKeyDown);
|
||||||
|
window.removeEventListener('keyup', onKeyUp);
|
||||||
|
window.removeEventListener('blur', onBlur);
|
||||||
|
};
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@ -206,6 +237,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="flex flex-row gap-0.5 self-center">
|
<div class="flex flex-row gap-0.5 self-center">
|
||||||
|
{#if shiftKey}
|
||||||
|
<Tooltip content={$i18n.t('Delete')}>
|
||||||
|
<button
|
||||||
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
|
type="button"
|
||||||
|
on:click={() => {
|
||||||
|
deleteHandler(tool);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GarbageBin />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
{:else}
|
||||||
{#if tool?.meta?.manifest?.funding_url ?? false}
|
{#if tool?.meta?.manifest?.funding_url ?? false}
|
||||||
<Tooltip content="Support">
|
<Tooltip content="Support">
|
||||||
<button
|
<button
|
||||||
@ -278,6 +322,7 @@
|
|||||||
<EllipsisHorizontal className="size-5" />
|
<EllipsisHorizontal className="size-5" />
|
||||||
</button>
|
</button>
|
||||||
</ToolMenu>
|
</ToolMenu>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
Loading…
Reference in New Issue
Block a user