jusrhee %!s(int64=4) %!d(string=hai) anos
pai
achega
9768e8952f

+ 33 - 25
dashboard/src/components/form-refactor/PorterForm.tsx

@@ -43,14 +43,20 @@ interface Props {
 }
 
 const PorterForm: React.FC<Props> = (props) => {
-  const { formData, isReadOnly, validationInfo, onSubmit, formState } = useContext(
-    PorterFormContext
-  );
+  const {
+    formData,
+    isReadOnly,
+    validationInfo,
+    onSubmit,
+    formState,
+  } = useContext(PorterFormContext);
 
   const [currentTab, setCurrentTab] = useState(
-    props.leftTabOptions?.length > 0 ? props.leftTabOptions[0].value : (
-      formData.tabs.length > 0 ? formData.tabs[0].name : ""
-    )
+    props.leftTabOptions?.length > 0
+      ? props.leftTabOptions[0].value
+      : formData.tabs.length > 0
+      ? formData.tabs[0].name
+      : ""
   );
 
   const renderSectionField = (field: FormField): JSX.Element => {
@@ -132,7 +138,11 @@ const PorterForm: React.FC<Props> = (props) => {
 
     // Handle external tab
     if (!tab) {
-      return props.renderTabContents ? props.renderTabContents(currentTab) : <></>;
+      return props.renderTabContents ? (
+        props.renderTabContents(currentTab)
+      ) : (
+        <></>
+      );
     }
 
     return (
@@ -161,7 +171,7 @@ const PorterForm: React.FC<Props> = (props) => {
       return "Missing required fields";
     }
     return props.saveValuesStatus;
-  }
+  };
 
   return (
     <>
@@ -175,22 +185,20 @@ const PorterForm: React.FC<Props> = (props) => {
         {renderTab()}
       </TabRegion>
       <br />
-      {
-        showSaveButton() && (
-          <SaveButton
-            text={props.saveButtonText || "Deploy"}
-            onClick={onSubmit}
-            makeFlush={!props.isInModal}
-            status={validationInfo.validated ? renderSaveStatus() : validationInfo.error}
-            disabled={isDisabled()}
-          /> 
-        )
-      }
-      { 
-        props.showStateDebugger && (
-          <Pre>{JSON.stringify(formState, undefined, 2)}</Pre>
-        )
-      }
+      {showSaveButton() && (
+        <SaveButton
+          text={props.saveButtonText || "Deploy"}
+          onClick={onSubmit}
+          makeFlush={!props.isInModal}
+          status={
+            validationInfo.validated ? renderSaveStatus() : validationInfo.error
+          }
+          disabled={isDisabled()}
+        />
+      )}
+      {props.showStateDebugger && (
+        <Pre>{JSON.stringify(formState, undefined, 2)}</Pre>
+      )}
       <Spacer />
     </>
   );
@@ -209,7 +217,7 @@ const Spacer = styled.div`
 
 const StyledPorterForm = styled.div<{ showSave?: boolean }>`
   width: 100%;
-  height: ${props => props.showSave ? 'calc(100% - 50px)' : '100%'};
+  height: ${(props) => (props.showSave ? "calc(100% - 50px)" : "100%")};
   background: #ffffff11;
   color: #ffffff;
   padding: 0px 35px 25px;

+ 13 - 13
dashboard/src/components/form-refactor/PorterFormWrapper.tsx

@@ -5,19 +5,19 @@ import { PorterFormData } from "./types";
 import { PorterFormContextProvider } from "./PorterFormContextProvider";
 
 type PropsType = {
-  formData: any,
-  valuesToOverride?: any,
-  isReadOnly?: boolean,
-  onSubmit?: (values: any) => void, 
-  renderTabContents?: (currentTab: string, submitValues?: any) => any,
-  leftTabOptions?: { value: string, label: string }[],
-  rightTabOptions?: { value: string, label: string }[],
-  saveButtonText?: string,
-  isInModal?: boolean,
-  color?: string,
-  addendum?: any,
-  saveValuesStatus?: string,
-  externalValues?: any,
+  formData: any;
+  valuesToOverride?: any;
+  isReadOnly?: boolean;
+  onSubmit?: (values: any) => void;
+  renderTabContents?: (currentTab: string, submitValues?: any) => any;
+  leftTabOptions?: { value: string; label: string }[];
+  rightTabOptions?: { value: string; label: string }[];
+  saveButtonText?: string;
+  isInModal?: boolean;
+  color?: string;
+  addendum?: any;
+  saveValuesStatus?: string;
+  externalValues?: any;
   showStateDebugger?: boolean;
 };
 

+ 5 - 4
dashboard/src/components/form-refactor/field-components/Checkbox.tsx

@@ -61,8 +61,9 @@ export const getFinalVariablesForCheckbox: GetFinalVariablesFunction = (
 ) => {
   return vars[props.variable] === false
     ? {
-      [props.variable]: false,
-    } : {
-      [props.variable]: !!props.settings?.default,
-    };
+        [props.variable]: false,
+      }
+    : {
+        [props.variable]: !!props.settings?.default,
+      };
 };

+ 1 - 1
dashboard/src/components/form-refactor/field-components/Input.tsx

@@ -29,7 +29,7 @@ const Input: React.FC<InputField> = ({
       validated: settings?.default != undefined,
     },
     initVars: {
-      [variable]: value ? value[0] : settings?.default, 
+      [variable]: value ? value[0] : settings?.default,
     },
   });
 

+ 3 - 1
dashboard/src/components/form-refactor/field-components/Select.tsx

@@ -14,7 +14,9 @@ const Select: React.FC<SelectField> = (props) => {
   const { currentCluster } = useContext(Context);
   const { variables, setVars } = useFormField<SelectFieldState>(props.id, {
     initVars: {
-      [props.variable]: props.value ? props.value[0] : props.settings.default
+      [props.variable]: props.value
+        ? props.value[0]
+        : props.settings.default
         ? props.settings.default
         : props.settings.type == "provider"
         ? ({

+ 72 - 44
dashboard/src/components/form-refactor/types.ts

@@ -15,7 +15,7 @@ export interface GenericInputField extends GenericField {
   isReadOnly?: boolean;
   required?: boolean;
   variable: string;
-  settings?: any
+  settings?: any;
 
   // Read in value from Helm for existing revisions
   value?: any[];
@@ -51,10 +51,10 @@ export interface InputField extends GenericInputField {
   placeholder?: string;
   info?: string;
   settings?: {
-    type?: "text"|"password"|"number";
+    type?: "text" | "password" | "number";
     unit?: string;
     omitUnitFromValue?: boolean;
-    default: string|number;
+    default: string | number;
   };
 }
 
@@ -62,8 +62,8 @@ export interface CheckboxField extends GenericInputField {
   type: "checkbox";
   label?: string;
   settings?: {
-    default: boolean
-  }
+    default: boolean;
+  };
 }
 
 export interface KeyValueArrayField extends GenericInputField {
@@ -73,25 +73,27 @@ export interface KeyValueArrayField extends GenericInputField {
   envLoader?: boolean;
   fileUpload?: boolean;
   settings?: {
-    type: "env"|"normal";
-  }
+    type: "env" | "normal";
+  };
 }
 
 export interface ArrayInputField extends GenericInputField {
-  type: "array-input"
-  label?: string
+  type: "array-input";
+  label?: string;
 }
 
 export interface SelectField extends GenericInputField {
-  type: "select"
-  settings: {
-    type: "normal"
-    options: { value: string; label: string }[]
-    default?: string,
-  }|{
-    type: "provider"
-    default?: string,
-  }
+  type: "select";
+  settings:
+    | {
+        type: "normal";
+        options: { value: string; label: string }[];
+        default?: string;
+      }
+    | {
+        type: "provider";
+        default?: string;
+      };
   width: string;
   label?: string;
   dropdownLabel?: string;
@@ -100,15 +102,24 @@ export interface SelectField extends GenericInputField {
 }
 
 export interface VariableField extends GenericInputField {
-  type: "variable",
+  type: "variable";
   settings?: {
-    default: any
-  }
+    default: any;
+  };
 }
 
-export type FormField = HeadingField|SubtitleField|InputField|CheckboxField
-  |KeyValueArrayField|ArrayInputField|SelectField|ServiceIPListField|ResourceListField
-  |VeleroBackupField|VariableField;
+export type FormField =
+  | HeadingField
+  | SubtitleField
+  | InputField
+  | CheckboxField
+  | KeyValueArrayField
+  | ArrayInputField
+  | SelectField
+  | ServiceIPListField
+  | ResourceListField
+  | VeleroBackupField
+  | VariableField;
 
 export interface ShowIfAnd {
   and: ShowIf[];
@@ -153,8 +164,8 @@ export interface StringInputFieldState {}
 export interface CheckboxFieldState {}
 export interface KeyValueArrayFieldState {
   values: {
-    key: string,
-    value: string
+    key: string;
+    value: string;
   }[];
   showEnvModal: boolean;
   showEditorModal: boolean;
@@ -162,7 +173,12 @@ export interface KeyValueArrayFieldState {
 export interface ArrayInputFieldState {}
 export interface SelectFieldState {}
 
-export type PorterFormFieldFieldState = StringInputFieldState|CheckboxFieldState|KeyValueArrayField|ArrayInputFieldState|SelectFieldState;
+export type PorterFormFieldFieldState =
+  | StringInputFieldState
+  | CheckboxFieldState
+  | KeyValueArrayField
+  | ArrayInputFieldState
+  | SelectFieldState;
 
 // reducer interfaces
 
@@ -171,45 +187,57 @@ export interface PorterFormFieldValidationState {
 }
 
 export interface PorterFormVariableList {
-  [key: string]: any
+  [key: string]: any;
 }
 
 export interface PorterFormState {
   components: {
     [key: string]: {
-      state: PorterFormFieldFieldState
-      validation: PorterFormFieldValidationState
-    }
-  }
-  variables: PorterFormVariableList
+      state: PorterFormFieldFieldState;
+      validation: PorterFormFieldValidationState;
+    };
+  };
+  variables: PorterFormVariableList;
 }
 
 export interface PorterFormInitFieldAction {
-  type: "init-field",
+  type: "init-field";
   id: string;
   initValue: PorterFormFieldFieldState;
-  initValidation?: Partial<PorterFormFieldValidationState>
-  initVars?: PorterFormVariableList
+  initValidation?: Partial<PorterFormFieldValidationState>;
+  initVars?: PorterFormVariableList;
 }
 
 export interface PorterFormUpdateFieldAction {
-  type: "update-field",
+  type: "update-field";
   id: string;
-  updateFunc: (prev: PorterFormFieldFieldState) => Partial<PorterFormFieldFieldState>;
+  updateFunc: (
+    prev: PorterFormFieldFieldState
+  ) => Partial<PorterFormFieldFieldState>;
 }
 
 export interface PorterFormUpdateValidationAction {
-  type: "update-validation",
+  type: "update-validation";
   id: string;
-  updateFunc: (prev: PorterFormFieldValidationState) => PorterFormFieldValidationState;
+  updateFunc: (
+    prev: PorterFormFieldValidationState
+  ) => PorterFormFieldValidationState;
 }
 
 export interface PorterFormMutateVariablesAction {
-  type: "mutate-vars",
+  type: "mutate-vars";
   mutateFunc: (prev: PorterFormVariableList) => PorterFormVariableList;
 }
 
-export type PorterFormAction = PorterFormInitFieldAction|PorterFormUpdateFieldAction|PorterFormMutateVariablesAction|PorterFormUpdateValidationAction;
+export type PorterFormAction =
+  | PorterFormInitFieldAction
+  | PorterFormUpdateFieldAction
+  | PorterFormMutateVariablesAction
+  | PorterFormUpdateValidationAction;
 
-export type GetFinalVariablesFunction = (vars: PorterFormVariableList, props: FormField,
-                                         state: PorterFormFieldFieldState, context: Partial<ContextProps>) => PorterFormVariableList;
+export type GetFinalVariablesFunction = (
+  vars: PorterFormVariableList,
+  props: FormField,
+  state: PorterFormFieldFieldState,
+  context: Partial<ContextProps>
+) => PorterFormVariableList;

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -651,7 +651,7 @@ const ExpandedChart: React.FC<Props> = (props) => {
     return () => (isSubscribed = false);
   }, [components, currentCluster, currentProject, currentChart]);
 
-  console.log("i see", props.currentChart.form)
+  console.log("i see", props.currentChart.form);
   return (
     <>
       <StyledExpandedChart>

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -494,7 +494,7 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
     }
 
     // Filter tabs if previewing an old revision
-    this.setState({ 
+    this.setState({
       leftTabOptions: [{ label: "Jobs", value: "jobs" }],
       rightTabOptions,
     });