Ivan Galakhov 4 лет назад
Родитель
Сommit
a0574ad738

+ 1 - 1
dashboard/src/components/porter-form/field-components/ArrayInput.tsx

@@ -103,7 +103,7 @@ export const getFinalVariablesForArrayInput: GetFinalVariablesFunction = (
   return vars[props.variable]
     ? {}
     : {
-        [props.variable]: [],
+        [props.variable]: props.value ? props.value[0] : [],
       };
 };
 

+ 3 - 1
dashboard/src/components/porter-form/field-components/Checkbox.tsx

@@ -64,5 +64,7 @@ export const getFinalVariablesForCheckbox: GetFinalVariablesFunction = (
   } else if (vars[props.variable] === true) {
     return { [props.variable]: true };
   }
-  return { [props.variable]: !!props.settings?.default };
+  return {
+    [props.variable]: props.value ? props.value[0] : !!props.settings?.default,
+  };
 };

+ 8 - 2
dashboard/src/components/porter-form/field-components/KeyValueArray.tsx

@@ -348,10 +348,16 @@ export const getFinalVariablesForKeyValueArray: GetFinalVariablesFunction = (
   props: KeyValueArrayField,
   state: KeyValueArrayFieldState
 ) => {
-  if (!state)
+  if (!state) {
     return {
-      [props.variable]: {},
+      [props.variable]:
+        props.value && props.value[0]
+          ? (Object.entries(props.value[0])?.map(([k, v]) => {
+              return { key: k, value: v };
+            }) as any[])
+          : [],
     };
+  }
 
   let obj = {} as any;
   const rg = /(?:^|[^\\])(\\n)/g;

+ 4 - 2
dashboard/src/components/porter-form/field-components/Select.tsx

@@ -73,14 +73,16 @@ export const getFinalVariablesForSelect: GetFinalVariablesFunction = (
   return vars[props.variable]
     ? {}
     : {
-        [props.variable]: props.settings.default
+        [props.variable]: props.value
+          ? props.value[0]
+          : props.settings.default
           ? props.settings.default
           : props.settings.type == "provider"
           ? ({
               gke: "gcp",
               eks: "aws",
               doks: "do",
-            } as Record<string, string>)[context.currentCluster?.service] ||
+            } as Record<string, string>)[context.currentCluster.service] ||
             "aws"
           : props.settings.options[0].value,
       };