Skip to content

Commit

Permalink
fix(orchestrator): pass also initial form data to custom decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
batzionb committed Nov 24, 2024
1 parent 9f20ced commit dbf26b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changeset/cyan-tigers-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@janus-idp/backstage-plugin-orchestrator-form-react": patch
"@janus-idp/backstage-plugin-orchestrator-form-api": patch
"@janus-idp/backstage-plugin-orchestrator": patch
---

pass also initial form data to custom decorator
1 change: 1 addition & 0 deletions plugins/orchestrator-form-api/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface OrchestratorFormApi {
getFormDecorator(
schema: JSONSchema7,
uiSchema: UiSchema<JsonObject, JSONSchema7>,
initialFormData?: JsonObject
): OrchestratorFormDecorator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,17 @@ const FormComponent = (decoratorProps: FormDecoratorProps) => {
const OrchestratorFormWrapper = ({
schema,
uiSchema,
formData,
...props
}: OrchestratorFormWrapperProps) => {
const formApi =
useApiHolder().get(orchestratorFormApiRef) || defaultFormExtensionsApi;
const NewComponent = React.useMemo(() => {
const formDecorator = formApi.getFormDecorator(schema, uiSchema);
const formDecorator = formApi.getFormDecorator(schema, uiSchema, formData);
return formDecorator(FormComponent);
}, [schema, formApi, uiSchema]);
}, [schema, formApi, uiSchema, formData]);
return (
<WrapperFormPropsContext.Provider value={{ schema, uiSchema, ...props }}>
<WrapperFormPropsContext.Provider value={{ schema, uiSchema, formData, ...props }}>
<NewComponent />
</WrapperFormPropsContext.Provider>
);
Expand Down

0 comments on commit dbf26b3

Please sign in to comment.