diff --git a/.changeset/olive-berries-poke.md b/.changeset/olive-berries-poke.md new file mode 100644 index 0000000000..b06a8b9f17 --- /dev/null +++ b/.changeset/olive-berries-poke.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-react': major +--- + +Fix for next version of template scaffolder for the steps without properties diff --git a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx index 153c48468d..d257d69c59 100644 --- a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx +++ b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx @@ -232,5 +232,39 @@ describe('useTemplateSchema', () => { }, }); }); + + it('should deal with steps having no properties', () => { + const manifest: TemplateParameterSchema = { + title: 'Test Template', + description: 'Test Template Description', + steps: [ + { + title: 'About step', + description: + 'The first step giving the initial information about the template', + schema: { + type: 'object', + }, + }, + ], + }; + + const { result } = renderHook(() => useTemplateSchema(manifest), { + wrapper: ({ children }) => ( + false }]]} + > + {children} + + ), + }); + + const [first] = result.current.steps; + + expect(first.schema).toEqual({ + type: 'object', + properties: {}, + }); + }); }); }); diff --git a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts index 26980b15cf..e9f7382e8d 100644 --- a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts +++ b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts @@ -62,7 +62,7 @@ export const useTemplateSchema = ( // Title is rendered at the top of the page, so let's ignore this from jsonschemaform title: undefined, properties: Object.fromEntries( - Object.entries(step.schema.properties as JsonObject).filter( + Object.entries((step.schema.properties || []) as JsonObject).filter( ([key]) => { const stepFeatureFlag = step.uiSchema[key]?.['ui:backstage']?.featureFlag;