Skip to content

Commit

Permalink
fix: stuck issue
Browse files Browse the repository at this point in the history
Signed-off-by: James <[email protected]>
  • Loading branch information
james-union committed Mar 1, 2023
1 parent d126390 commit c2eaee7
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,68 +81,68 @@ export const LaunchFormAdvancedInputs = React.forwardRef<
const [maxParallelism, setMaxParallelism] = React.useState('');
const [rawOutputDataConfig, setRawOutputDataConfig] = React.useState('');

// React.useEffect(() => {
// if (isValueValid(other.disableAll)) {
// setDisableAll(other.disableAll!);
// }
// if (isValueValid(other.maxParallelism)) {
// setMaxParallelism(`${other.maxParallelism}`);
// }
// if (
// other?.rawOutputDataConfig?.outputLocationPrefix !== undefined &&
// other.rawOutputDataConfig.outputLocationPrefix !== null
// ) {
// setRawOutputDataConfig(other.rawOutputDataConfig.outputLocationPrefix);
// }
// const newLabels = {
// ...(other.labels?.values || {}),
// ...(launchPlan?.spec?.labels?.values || {}),
// };
// const newAnnotations = {
// ...(other.annotations?.values || {}),
// ...(launchPlan?.spec?.annotations?.values || {}),
// };
// setLabelsParamData(newLabels);
// setAnnotationsParamData(newAnnotations);
// }, [
// other.disableAll,
// other.maxParallelism,
// other.rawOutputDataConfig,
// other.labels,
// other.annotations,
// launchPlan?.spec,
// ]);
React.useEffect(() => {
if (isValueValid(other.disableAll)) {
setDisableAll(other.disableAll!);
}
if (isValueValid(other.maxParallelism)) {
setMaxParallelism(`${other.maxParallelism}`);
}
if (
other?.rawOutputDataConfig?.outputLocationPrefix !== undefined &&
other.rawOutputDataConfig.outputLocationPrefix !== null
) {
setRawOutputDataConfig(other.rawOutputDataConfig.outputLocationPrefix);
}
const newLabels = {
...(other.labels?.values || {}),
...(launchPlan?.spec?.labels?.values || {}),
};
const newAnnotations = {
...(other.annotations?.values || {}),
...(launchPlan?.spec?.annotations?.values || {}),
};
setLabelsParamData(newLabels);
setAnnotationsParamData(newAnnotations);
}, [
other.disableAll,
other.maxParallelism,
other.rawOutputDataConfig,
other.labels,
other.annotations,
launchPlan?.spec,
]);

// React.useImperativeHandle(
// ref,
// () => ({
// getValues: () => {
// return {
// disableAll,
// rawOutputDataConfig: {
// outputLocationPrefix: rawOutputDataConfig,
// },
// maxParallelism: parseInt(maxParallelism || '', 10),
// labels: {
// values: labelsParamData,
// },
// annotations: {
// values: annotationsParamData,
// },
// } as Admin.IExecutionSpec;
// },
// validate: () => {
// return true;
// },
// }),
// [
// disableAll,
// maxParallelism,
// rawOutputDataConfig,
// labelsParamData,
// annotationsParamData,
// ],
// );
React.useImperativeHandle(
ref,
() => ({
getValues: () => {
return {
disableAll,
rawOutputDataConfig: {
outputLocationPrefix: rawOutputDataConfig,
},
maxParallelism: parseInt(maxParallelism || '', 10),
labels: {
values: labelsParamData,
},
annotations: {
values: annotationsParamData,
},
} as Admin.IExecutionSpec;
},
validate: () => {
return true;
},
}),
[
disableAll,
maxParallelism,
rawOutputDataConfig,
labelsParamData,
annotationsParamData,
],
);

const handleDisableAllChange = React.useCallback(() => {
setDisableAll(prevState => !prevState);
Expand Down Expand Up @@ -170,8 +170,6 @@ export const LaunchFormAdvancedInputs = React.forwardRef<
[],
);

console.log('MYLOG', { annotationsParamData, labelsParamData });

return (
<>
<section title="Labels" className={styles.collapsibleSection}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ export const LaunchWorkflowForm: React.FC<LaunchWorkflowFormProps> = props => {
showErrors={state.context.showErrors}
/>
) : null}
<LaunchFormAdvancedInputs ref={advancedOptionsRef} state={state} />
{isEnterInputsState(baseState) ? (
<LaunchFormAdvancedInputs
ref={advancedOptionsRef}
state={state}
/>
) : null}
<LaunchInterruptibleInput
initialValue={state.context.interruptible}
ref={interruptibleInputRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ export const StructInput: React.FC<InputProps> = props => {
jsonFormRenderable && value ? JSON.parse(value as string) : {},
);

const onFormChange = (_e, newVal) => {
// onChange(JSON.stringify(formData));
// setParamData(formData);
};
const onFormChange = React.useCallback(({ target: { value } }) => {
onChange(JSON.stringify(value));
setParamData(value);
}, []);

return jsonFormRenderable ? (
<MuiThemeProvider theme={muiTheme}>
Expand Down

0 comments on commit c2eaee7

Please sign in to comment.