From 2d82d260cc11cc4feadaa6fec3ef15b89401b892 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 27 Feb 2026 16:01:33 -0600 Subject: [PATCH] refac --- .../components/AddTerminalServerModal.svelte | 120 ++++++++++++------ 1 file changed, 82 insertions(+), 38 deletions(-) diff --git a/src/lib/components/AddTerminalServerModal.svelte b/src/lib/components/AddTerminalServerModal.svelte index 0e23e1631f..52dd342913 100644 --- a/src/lib/components/AddTerminalServerModal.svelte +++ b/src/lib/components/AddTerminalServerModal.svelte @@ -8,47 +8,47 @@ import Modal from '$lib/components/common/Modal.svelte'; import SensitiveInput from '$lib/components/common/SensitiveInput.svelte'; import XMark from '$lib/components/icons/XMark.svelte'; + import AccessControlModal from '$lib/components/workspace/common/AccessControlModal.svelte'; + import LockClosed from '$lib/components/icons/LockClosed.svelte'; export let show = false; export let edit = false; export let admin = false; - export let connection: { - url: string; - key: string; - name?: string; - path?: string; - enabled: boolean; - } | null = null; + export let connection = null; - export let onSubmit: (c: { - url: string; - key: string; - name?: string; - path?: string; - enabled: boolean; - }) => void = () => {}; + export let onSubmit: Function = () => {}; export let onDelete: () => void = () => {}; let url = ''; let key = ''; let name = ''; + let id = ''; let auth_type = 'bearer'; let path = '/openapi.json'; + let enabled = true; let showAdvanced = false; + let showAccessControlModal = false; + let accessGrants: any[] = []; const init = () => { if (connection) { + id = connection?.id ?? ''; url = connection.url; - key = connection.key; - name = connection.name ?? ''; - auth_type = connection.auth_type ?? 'bearer'; - path = connection.path ?? '/openapi.json'; + key = connection?.key ?? ''; + name = connection?.name ?? ''; + auth_type = connection?.auth_type ?? 'bearer'; + path = connection?.path ?? '/openapi.json'; + enabled = connection?.enabled ?? true; + accessGrants = connection?.config?.access_grants ?? []; } else { + id = ''; url = ''; key = ''; name = ''; auth_type = 'bearer'; path = '/openapi.json'; + enabled = true; + accessGrants = []; } }; @@ -66,12 +66,16 @@ url = url.replace(/\/$/, ''); const result = { + ...(admin && id.trim() ? { id: id.trim() } : {}), url, key, name, path, auth_type, - enabled: connection?.enabled ?? false + enabled: enabled, + config: { + ...(admin ? { access_grants: accessGrants } : {}) + } }; onSubmit(result); @@ -106,7 +110,7 @@
-
+
+ {#if admin} +
+
+ +
+
+ +
+
+ {/if}
@@ -152,25 +176,43 @@
- + + + + {$i18n.t('Advanced')} + + + {#if admin} + + {/if} +
{#if showAdvanced}
@@ -305,3 +347,5 @@
+ +