@@ -160,6 +168,12 @@
+
+
-
-
From 0da0d0f7a588469a3508a07b1071365fd4f1834b Mon Sep 17 00:00:00 2001
From: royendo <67675319+royendo@users.noreply.github.com>
Date: Tue, 16 Dec 2025 10:59:30 -0500
Subject: [PATCH 04/51] code qual
---
.../EditEnvDialog.svelte | 39 +++++--------------
1 file changed, 9 insertions(+), 30 deletions(-)
diff --git a/web-common/src/features/environment-variables/EditEnvDialog.svelte b/web-common/src/features/environment-variables/EditEnvDialog.svelte
index 0ffeb1c07e9..d6f7a48869f 100644
--- a/web-common/src/features/environment-variables/EditEnvDialog.svelte
+++ b/web-common/src/features/environment-variables/EditEnvDialog.svelte
@@ -26,11 +26,8 @@
}>();
let isKeyAlreadyExists = false;
-
- const initialValues = {
- key: keyName,
- value: value,
- };
+ let initialKey = keyName;
+ let initialValue = value;
const schema = yup(
object({
@@ -45,7 +42,7 @@
);
const { form, enhance, submit, submitting, errors } = superForm(
- defaults(initialValues, schema),
+ defaults({ key: "", value: "" }, schema),
{
SPA: true,
validators: schema,
@@ -57,19 +54,18 @@
if (isKeyAlreadyExists) return;
dispatch("save", {
- oldKey: keyName,
+ oldKey: initialKey,
key: $form.key,
value: $form.value,
});
open = false;
- handleReset();
},
},
);
$: hasNewChanges =
- $form.key !== initialValues.key || $form.value !== initialValues.value;
+ $form.key !== initialKey || $form.value !== initialValue;
function handleKeyChange(event: Event) {
const target = event.target as HTMLInputElement;
@@ -82,23 +78,14 @@
$form.value = target.value;
}
- function handleReset() {
- $form.key = initialValues.key;
- $form.value = initialValues.value;
- isKeyAlreadyExists = false;
- }
-
function checkForExistingKey() {
const existingKeys = existingVariables.map((v) => v.key);
- isKeyAlreadyExists = isDuplicateKey($form.key, existingKeys, keyName);
+ isKeyAlreadyExists = isDuplicateKey($form.key, existingKeys, initialKey);
}
- onMount(() => {
- $form.key = keyName;
- $form.value = value;
- });
-
$: if (open) {
+ initialKey = keyName;
+ initialValue = value;
$form.key = keyName;
$form.value = value;
isKeyAlreadyExists = false;
@@ -107,14 +94,7 @@
$: isSubmitDisabled = $submitting || !hasNewChanges || isKeyAlreadyExists;
-