From d578189c44e8439e2e9d3699416acfe40e508a25 Mon Sep 17 00:00:00 2001 From: Jacob Bolda Date: Tue, 5 Dec 2023 13:57:05 -0600 Subject: [PATCH] Pass `formContext` through scaffolder `FormProps` (#369) * allow passing form context to scaffolder form * change file --- .changeset/big-chefs-provide.md | 5 +++++ .../src/components/Form/Form.tsx | 2 +- .../src/components/Form/RJSFForm.tsx | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/big-chefs-provide.md diff --git a/.changeset/big-chefs-provide.md b/.changeset/big-chefs-provide.md new file mode 100644 index 0000000000..24fcc0dd54 --- /dev/null +++ b/.changeset/big-chefs-provide.md @@ -0,0 +1,5 @@ +--- +'@frontside/backstage-plugin-scaffolder-workflow': minor +--- + +Allow passing formContext through the FormProps to scaffolder form. diff --git a/plugins/scaffolder-frontend-workflow/src/components/Form/Form.tsx b/plugins/scaffolder-frontend-workflow/src/components/Form/Form.tsx index ab51769b9c..e3ae26ba85 100644 --- a/plugins/scaffolder-frontend-workflow/src/components/Form/Form.tsx +++ b/plugins/scaffolder-frontend-workflow/src/components/Form/Form.tsx @@ -62,7 +62,7 @@ export const Form = ({ uiSchema={step.uiSchema} fields={fields} formData={formData} - formContext={{ formData }} + formContext={{ ...props.formContext, formData }} onSubmit={onSubmit} onChange={handleChange} {...props} diff --git a/plugins/scaffolder-frontend-workflow/src/components/Form/RJSFForm.tsx b/plugins/scaffolder-frontend-workflow/src/components/Form/RJSFForm.tsx index 450b943bd2..b3204ef5c0 100644 --- a/plugins/scaffolder-frontend-workflow/src/components/Form/RJSFForm.tsx +++ b/plugins/scaffolder-frontend-workflow/src/components/Form/RJSFForm.tsx @@ -4,5 +4,5 @@ export const RJSFForm = withTheme(require('@rjsf/material-ui').Theme); export type RJSFFormProps = Pick< FormProps, - 'transformErrors' | 'extraErrors' | 'className' | 'ref' + 'transformErrors' | 'extraErrors' | 'formContext' | 'className' | 'ref' >;