open-webui/src/lib/components/chat/Settings/Tools/Connection.svelte

84 lines
2.1 KiB
Svelte
Raw Normal View History

<script lang="ts">
import { getContext, tick } from 'svelte';
const i18n = getContext('i18n');
import Tooltip from '$lib/components/common/Tooltip.svelte';
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
import Cog6 from '$lib/components/icons/Cog6.svelte';
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
2025-09-23 06:03:26 +00:00
import AddToolServerModal from '$lib/components/AddToolServerModal.svelte';
2025-10-06 04:35:04 +00:00
import WrenchAlt from '$lib/components/icons/WrenchAlt.svelte';
export let onDelete = () => {};
export let onSubmit = () => {};
2025-04-03 03:42:23 +00:00
export let connection = null;
2025-04-05 10:05:52 +00:00
export let direct = false;
let showConfigModal = false;
let showDeleteConfirmDialog = false;
</script>
2025-09-23 06:03:26 +00:00
<AddToolServerModal
edit
2025-04-05 10:40:01 +00:00
{direct}
bind:show={showConfigModal}
2025-04-03 03:42:23 +00:00
{connection}
onDelete={() => {
showDeleteConfirmDialog = true;
}}
2025-04-03 03:42:23 +00:00
onSubmit={(c) => {
connection = c;
onSubmit(c);
}}
/>
<ConfirmDialog
bind:show={showDeleteConfirmDialog}
on:confirm={() => {
onDelete();
showConfigModal = false;
}}
/>
<div class="flex w-full gap-2 items-center">
2025-10-06 04:35:04 +00:00
<Tooltip className="w-full relative" content={''} placement="top-start">
<div class="flex w-full">
2025-10-06 04:35:04 +00:00
<div
class="flex-1 relative flex gap-1.5 items-center {!(connection?.config?.enable ?? true)
? 'opacity-50'
: ''}"
>
2025-10-06 04:36:26 +00:00
<Tooltip content={connection?.type === 'mcp' ? $i18n.t('MCP') : $i18n.t('OpenAPI')}>
<WrenchAlt />
</Tooltip>
2025-10-14 23:32:50 +00:00
{#if connection?.info?.name}
<div class=" capitalize outline-hidden w-full bg-transparent">
{connection?.info?.name ?? connection?.url}
<span class="text-gray-500">{connection?.info?.id ?? ''}</span>
</div>
{:else}
<div>
{connection?.url}
</div>
{/if}
</div>
</div>
</Tooltip>
<div class="flex gap-1">
<Tooltip content={$i18n.t('Configure')} className="self-start">
<button
class="self-center p-1 bg-transparent hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-850 rounded-lg transition"
on:click={() => {
showConfigModal = true;
}}
type="button"
>
<Cog6 />
</button>
</Tooltip>
</div>
</div>