Skip to content

Commit

Permalink
LaunchForm RJSF Form issue (#692)
Browse files Browse the repository at this point in the history
* fix: launchform

Signed-off-by: James <[email protected]>

* fix: stuck issue

Signed-off-by: James <[email protected]>

* fix: on form change

Signed-off-by: James <[email protected]>

* fix: merge master into branch

Signed-off-by: James <[email protected]>

---------

Signed-off-by: James <[email protected]>
  • Loading branch information
james-union authored Mar 2, 2023
1 parent 1319917 commit 90e4fa2
Show file tree
Hide file tree
Showing 5 changed files with 152 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 @@ -194,6 +195,7 @@ export const LaunchFormAdvancedInputs = React.forwardRef<
}}
formData={labelsParamData}
onChange={handleLabelsChange}
validator={validator}
>
<div />
</Form>
Expand Down Expand Up @@ -226,6 +228,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 @@ -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 @@ -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,10 +87,10 @@ export const StructInput: React.FC<InputProps> = props => {
jsonFormRenderable && value ? JSON.parse(value as string) : {},
);

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

return jsonFormRenderable ? (
<MuiThemeProvider theme={muiTheme}>
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
Loading

0 comments on commit 90e4fa2

Please sign in to comment.