Skip to content

Commit 157ff57

Browse files
committed
refac
1 parent d85b52b commit 157ff57

3 files changed

Lines changed: 80 additions & 47 deletions

File tree

src/lib/components/AddConnectionModal.svelte

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
1515
import Tooltip from '$lib/components/common/Tooltip.svelte';
1616
import Switch from '$lib/components/common/Switch.svelte';
17+
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
1718
import Tags from './common/Tags.svelte';
1819
import Spinner from '$lib/components/common/Spinner.svelte';
1920
import XMark from '$lib/components/icons/XMark.svelte';
@@ -52,6 +53,7 @@
5253
let modelIds = [];
5354
5455
let loading = false;
56+
let showDeleteConfirmDialog = false;
5557
5658
const verifyOllamaHandler = async () => {
5759
// remove trailing slash from url
@@ -684,19 +686,20 @@
684686
</div>
685687
</div>
686688

687-
<div class="flex justify-end pt-3 text-sm font-medium gap-1.5">
688-
{#if edit}
689-
<button
690-
class="px-3.5 py-1.5 text-sm font-medium dark:bg-black dark:hover:bg-gray-900 dark:text-white bg-white text-black hover:bg-gray-100 transition rounded-full flex flex-row space-x-1 items-center"
691-
type="button"
692-
on:click={() => {
693-
onDelete();
694-
show = false;
695-
}}
696-
>
697-
{$i18n.t('Delete')}
698-
</button>
699-
{/if}
689+
<div class="flex justify-between items-center pt-3 text-sm font-medium">
690+
<div>
691+
{#if edit}
692+
<button
693+
class="px-1 py-1.5 text-sm font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:underline transition"
694+
type="button"
695+
on:click={() => {
696+
showDeleteConfirmDialog = true;
697+
}}
698+
>
699+
{$i18n.t('Delete')}
700+
</button>
701+
{/if}
702+
</div>
700703

701704
<button
702705
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full flex items-center gap-2 whitespace-nowrap {loading
@@ -719,3 +722,13 @@
719722
</div>
720723
</div>
721724
</Modal>
725+
726+
<ConfirmDialog
727+
bind:show={showDeleteConfirmDialog}
728+
message={$i18n.t('Are you sure you want to delete this connection? This action cannot be undone.')}
729+
confirmLabel={$i18n.t('Delete')}
730+
on:confirm={() => {
731+
onDelete();
732+
show = false;
733+
}}
734+
/>

src/lib/components/AddTerminalServerModal.svelte

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import AccessControlModal from '$lib/components/workspace/common/AccessControlModal.svelte';
1212
import LockClosed from '$lib/components/icons/LockClosed.svelte';
1313
import Tooltip from '$lib/components/common/Tooltip.svelte';
14+
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
1415
import { detectTerminalServerType, putOrchestratorPolicy } from '$lib/apis/configs';
1516
import { getTerminalConfig } from '$lib/apis/terminal';
1617
@@ -31,6 +32,7 @@
3132
let enabled = false;
3233
let showAdvanced = false;
3334
let showAccessControlModal = false;
35+
let showDeleteConfirmDialog = false;
3436
let accessGrants: any[] = [];
3537
3638
// Policy / auto-detect state
@@ -698,29 +700,27 @@
698700
</div>
699701
</div>
700702

701-
<div class="flex justify-between pt-3 text-sm font-medium gap-1.5">
702-
<div></div>
703-
<div class="flex gap-1.5">
703+
<div class="flex justify-between items-center pt-3 text-sm font-medium">
704+
<div>
704705
{#if edit}
705706
<button
706-
class="px-3.5 py-1.5 text-sm font-medium dark:bg-black dark:hover:bg-gray-900 dark:text-white bg-white text-black hover:bg-gray-100 transition rounded-full flex flex-row space-x-1 items-center"
707+
class="px-1 py-1.5 text-sm font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:underline transition"
707708
type="button"
708709
on:click={() => {
709-
onDelete();
710-
show = false;
710+
showDeleteConfirmDialog = true;
711711
}}
712712
>
713713
{$i18n.t('Delete')}
714714
</button>
715715
{/if}
716-
717-
<button
718-
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full flex flex-row space-x-1 items-center"
719-
type="submit"
720-
>
721-
{$i18n.t('Save')}
722-
</button>
723716
</div>
717+
718+
<button
719+
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full flex flex-row space-x-1 items-center"
720+
type="submit"
721+
>
722+
{$i18n.t('Save')}
723+
</button>
724724
</div>
725725
</div>
726726
</form>
@@ -730,3 +730,13 @@
730730
</Modal>
731731

732732
<AccessControlModal bind:show={showAccessControlModal} bind:accessGrants />
733+
734+
<ConfirmDialog
735+
bind:show={showDeleteConfirmDialog}
736+
message={$i18n.t('Are you sure you want to delete this connection? This action cannot be undone.')}
737+
confirmLabel={$i18n.t('Delete')}
738+
on:confirm={() => {
739+
onDelete();
740+
show = false;
741+
}}
742+
/>

src/lib/components/AddToolServerModal.svelte

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import Spinner from '$lib/components/common/Spinner.svelte';
2525
import XMark from '$lib/components/icons/XMark.svelte';
2626
import Textarea from './common/Textarea.svelte';
27+
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
2728
2829
export let onSubmit: Function = () => {};
2930
export let onDelete: Function = () => {};
@@ -61,6 +62,7 @@
6162
let loading = false;
6263
let showAdvanced = false;
6364
let showAccessControlModal = false;
65+
let showDeleteConfirmDialog = false;
6466
6567
const registerOAuthClientHandler = async () => {
6668
if (url === '') {
@@ -881,38 +883,36 @@
881883
</div>
882884
{/if}
883885

884-
<div class="flex justify-between pt-3 text-sm font-medium gap-1.5">
885-
<div></div>
886-
<div class="flex gap-1.5">
886+
<div class="flex justify-between items-center pt-3 text-sm font-medium">
887+
<div>
887888
{#if edit}
888889
<button
889-
class="px-3.5 py-1.5 text-sm font-medium dark:bg-black dark:hover:bg-gray-900 dark:text-white bg-white text-black hover:bg-gray-100 transition rounded-full flex flex-row space-x-1 items-center"
890+
class="px-1 py-1.5 text-sm font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:underline transition"
890891
type="button"
891892
on:click={() => {
892-
onDelete();
893-
show = false;
893+
showDeleteConfirmDialog = true;
894894
}}
895895
>
896896
{$i18n.t('Delete')}
897897
</button>
898898
{/if}
899+
</div>
899900

900-
<button
901-
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full flex items-center gap-2 whitespace-nowrap {loading
902-
? ' cursor-not-allowed'
903-
: ''}"
904-
type="submit"
905-
disabled={loading}
906-
>
907-
{$i18n.t('Save')}
901+
<button
902+
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full flex items-center gap-2 whitespace-nowrap {loading
903+
? ' cursor-not-allowed'
904+
: ''}"
905+
type="submit"
906+
disabled={loading}
907+
>
908+
{$i18n.t('Save')}
908909

909-
{#if loading}
910-
<span class="shrink-0">
911-
<Spinner />
912-
</span>
913-
{/if}
914-
</button>
915-
</div>
910+
{#if loading}
911+
<span class="shrink-0">
912+
<Spinner />
913+
</span>
914+
{/if}
915+
</button>
916916
</div>
917917
</form>
918918
</div>
@@ -921,3 +921,13 @@
921921
</Modal>
922922

923923
<AccessControlModal bind:show={showAccessControlModal} bind:accessGrants />
924+
925+
<ConfirmDialog
926+
bind:show={showDeleteConfirmDialog}
927+
message={$i18n.t('Are you sure you want to delete this connection? This action cannot be undone.')}
928+
confirmLabel={$i18n.t('Delete')}
929+
on:confirm={() => {
930+
onDelete();
931+
show = false;
932+
}}
933+
/>

0 commit comments

Comments
 (0)