Skip to content

Commit

Permalink
fix: launchform
Browse files Browse the repository at this point in the history
Signed-off-by: James <[email protected]>
  • Loading branch information
james-union committed Feb 28, 2023
1 parent 797bcc2 commit d126390
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 72 deletions.
8 changes: 4 additions & 4 deletions packages/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/pickers": "^3.2.2",
"@rjsf/core": "3.2.1",
"@rjsf/material-ui": "3.2.1",
"@rjsf/utils": "^5.0.0-beta.12",
"@rjsf/validator-ajv6": "^5.0.0-beta.12",
"@rjsf/core": "^5.1.0",
"@rjsf/material-ui": "^5.1.0",
"@rjsf/utils": "^5.1.0",
"@rjsf/validator-ajv8": "^5.1.0",
"@types/d3-shape": "^1.2.6",
"@xstate/react": "^1.0.0",
"axios": "^0.27.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import Form from '@rjsf/material-ui';
import validator from '@rjsf/validator-ajv8';
import { State } from 'xstate';
import { LaunchAdvancedOptionsRef } from './types';
import {
Expand Down Expand Up @@ -80,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 @@ -169,6 +170,8 @@ export const LaunchFormAdvancedInputs = React.forwardRef<
[],
);

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

return (
<>
<section title="Labels" className={styles.collapsibleSection}>
Expand All @@ -194,6 +197,7 @@ export const LaunchFormAdvancedInputs = React.forwardRef<
}}
formData={labelsParamData}
onChange={handleLabelsChange}
validator={validator}
>
<div />
</Form>
Expand Down Expand Up @@ -226,6 +230,7 @@ export const LaunchFormAdvancedInputs = React.forwardRef<
}}
formData={annotationsParamData}
onChange={handleAnnotationsParamData}
validator={validator}
>
<div />
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TextField, Card, CardContent, CardHeader } from '@material-ui/core';
import { useState } from 'react';
import Form from '@rjsf/material-ui';
import { MuiThemeProvider, createTheme } from '@material-ui/core/styles';
import validator from '@rjsf/validator-ajv8';
import { makeStringChangeHandler } from './handlers';
import { InputProps } from './types';
import { getLaunchInputId } from './utils';
Expand Down Expand Up @@ -86,9 +87,9 @@ export const StructInput: React.FC<InputProps> = props => {
jsonFormRenderable && value ? JSON.parse(value as string) : {},
);

const onFormChange = ({ formData }, _e) => {
onChange(JSON.stringify(formData));
setParamData(formData);
const onFormChange = (_e, newVal) => {
// onChange(JSON.stringify(formData));
// setParamData(formData);
};

return jsonFormRenderable ? (
Expand All @@ -98,6 +99,7 @@ export const StructInput: React.FC<InputProps> = props => {
<CardContent>
<Form
schema={JSON.parse(JSON.stringify(parsedJson))}
validator={validator}
formData={paramData}
onChange={onFormChange}
>
Expand Down
77 changes: 73 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2119,10 +2119,10 @@ __metadata:
"@material-ui/core": ^4.12.4
"@material-ui/icons": ^4.11.3
"@material-ui/pickers": ^3.2.2
"@rjsf/core": 3.2.1
"@rjsf/material-ui": 3.2.1
"@rjsf/utils": ^5.0.0-beta.12
"@rjsf/validator-ajv6": ^5.0.0-beta.12
"@rjsf/core": ^5.1.0
"@rjsf/material-ui": ^5.1.0
"@rjsf/utils": ^5.1.0
"@rjsf/validator-ajv8": ^5.1.0
"@types/d3-shape": ^1.2.6
"@types/debug": ^0.0.30
"@types/dom-helpers": ^3.4.1
Expand Down Expand Up @@ -3364,6 +3364,21 @@ __metadata:
languageName: node
linkType: hard

"@rjsf/core@npm:^5.1.0":
version: 5.1.0
resolution: "@rjsf/core@npm:5.1.0"
dependencies:
lodash: ^4.17.15
lodash-es: ^4.17.15
nanoid: ^3.3.4
prop-types: ^15.7.2
peerDependencies:
"@rjsf/utils": ^5.0.0
react: ^16.14.0 || >=17
checksum: ff38046bb25de86b57e404c5d1ccea84b0485e916caf33a3cb25b030a38ed930a9b89a411671a7c29b047da38e0c682e20b43b13e61d77df770299385ba3c67a
languageName: node
linkType: hard

"@rjsf/material-ui@npm:3.2.1":
version: 3.2.1
resolution: "@rjsf/material-ui@npm:3.2.1"
Expand All @@ -3376,6 +3391,19 @@ __metadata:
languageName: node
linkType: hard

"@rjsf/material-ui@npm:^5.1.0":
version: 5.1.0
resolution: "@rjsf/material-ui@npm:5.1.0"
peerDependencies:
"@material-ui/core": ^4.12.3
"@material-ui/icons": ^4.11.2
"@rjsf/core": ^5.0.0
"@rjsf/utils": ^5.0.0
react: ^16.14.0 || >=17
checksum: f8e2c486f33a60703cae5bb42ae82bc431b3d743c239868ca71907e7b4127a39d1688200820c0c8acdf3ecd3f5eaddef4ba47264695feead28e9b439d9be7ce8
languageName: node
linkType: hard

"@rjsf/utils@npm:^5.0.0-beta.12":
version: 5.0.0-beta.14
resolution: "@rjsf/utils@npm:5.0.0-beta.14"
Expand All @@ -3391,6 +3419,21 @@ __metadata:
languageName: node
linkType: hard

"@rjsf/utils@npm:^5.1.0":
version: 5.1.0
resolution: "@rjsf/utils@npm:5.1.0"
dependencies:
json-schema-merge-allof: ^0.8.1
jsonpointer: ^5.0.1
lodash: ^4.17.15
lodash-es: ^4.17.15
react-is: ^18.2.0
peerDependencies:
react: ^16.14.0 || >=17
checksum: 76d7caf144f98b1547067bfdc2b1baecf452c63bd9d6f2cae6c162a99154bb4d2f5033f6abc0e26ab767dca9ea743f1f5a9d796696e90dd5ed1fdca5ee3c5280
languageName: node
linkType: hard

"@rjsf/validator-ajv6@npm:^5.0.0-beta.12":
version: 5.0.0-beta.14
resolution: "@rjsf/validator-ajv6@npm:5.0.0-beta.14"
Expand All @@ -3404,6 +3447,20 @@ __metadata:
languageName: node
linkType: hard

"@rjsf/validator-ajv8@npm:^5.1.0":
version: 5.1.0
resolution: "@rjsf/validator-ajv8@npm:5.1.0"
dependencies:
ajv: ^8.12.0
ajv-formats: ^2.1.1
lodash: ^4.17.15
lodash-es: ^4.17.15
peerDependencies:
"@rjsf/utils": ^5.0.0
checksum: 3430a0aea8235deedd306b535ea3a62a9bcdd4dcf0bf1d022fe036041dceb5ca7c147b17ae50a0d25bb7c953729e987d96c68f5220f8fde4b56a89cf3f106a49
languageName: node
linkType: hard

"@semantic-release/changelog@npm:^5.0.1":
version: 5.0.1
resolution: "@semantic-release/changelog@npm:5.0.1"
Expand Down Expand Up @@ -6513,6 +6570,18 @@ __metadata:
languageName: node
linkType: hard

"ajv@npm:^8.12.0":
version: 8.12.0
resolution: "ajv@npm:8.12.0"
dependencies:
fast-deep-equal: ^3.1.1
json-schema-traverse: ^1.0.0
require-from-string: ^2.0.2
uri-js: ^4.2.2
checksum: 4dc13714e316e67537c8b31bc063f99a1d9d9a497eb4bbd55191ac0dcd5e4985bbb71570352ad6f1e76684fb6d790928f96ba3b2d4fd6e10024be9612fe3f001
languageName: node
linkType: hard

"ansi-align@npm:^3.0.0":
version: 3.0.1
resolution: "ansi-align@npm:3.0.1"
Expand Down

0 comments on commit d126390

Please sign in to comment.