Przeglądaj źródła

init changes, some helper function

Ivan Galakhov 4 lat temu
rodzic
commit
c0c2449bcd

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

@@ -26,7 +26,7 @@ const Checkbox: React.FC<Props> = ({
       validated: !required,
     },
     initVars: {
-      [variable]: value ? value[0] : !!settings?.default,
+      [variable]: value ? value[0] : false,
     },
   });
 
@@ -75,6 +75,6 @@ export const getFinalVariablesForCheckbox: GetFinalVariablesFunction = (
   }
 
   return {
-    [props.variable]: props.value ? props.value[0] : !!props.settings?.default,
+    [props.variable]: props.value ? props.value[0] : false,
   };
 };

+ 1 - 2
dashboard/src/components/porter-form/types.ts

@@ -18,7 +18,7 @@ export interface GenericInputField extends GenericField {
   settings?: any;
 
   // Read in value from Helm for existing revisions
-  value?: any[];
+  value?: [any]|[];
 }
 
 export interface HeadingField extends GenericField {
@@ -62,7 +62,6 @@ export interface CheckboxField extends GenericInputField {
   type: "checkbox";
   label?: string;
   settings?: {
-    default: boolean;
   };
 }
 

+ 6 - 0
dashboard/src/components/porter-form/utils.ts

@@ -0,0 +1,6 @@
+import { GenericInputField } from "./types";
+
+
+export const hasSetValue = (field: GenericInputField) => {
+    return field.value && field.value.length != 0 && field.value[0] != null
+}