diff --git a/.changeset/wise-cycles-sparkle.md b/.changeset/wise-cycles-sparkle.md new file mode 100644 index 0000000000..2412280b0c --- /dev/null +++ b/.changeset/wise-cycles-sparkle.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +'@backstage/plugin-scaffolder': patch +--- + +Added conditional rendering of oneOf output schemas on the Installed Actions page for scaffolder actions diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx index acfdabac5b..a3b3049beb 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx @@ -125,6 +125,63 @@ describe('TemplatePage', () => { expect(rendered.getByText('Test output')).toBeInTheDocument(); }); + it('renders action with oneOf output', async () => { + scaffolderApiMock.listActions.mockResolvedValue([ + { + id: 'test', + description: 'example description', + schema: { + input: { + type: 'object', + required: ['foobar'], + properties: { + foobar: { + title: 'Test title', + type: 'string', + }, + }, + }, + output: { + oneOf: [ + { + type: 'object', + properties: { + buzz: { + title: 'Test output1', + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + buzz: { + title: 'Test output2', + type: 'string', + }, + }, + }, + ], + }, + }, + }, + ]); + const rendered = await renderInTestApp( + + + , + { + mountedRoutes: { + '/create/actions': rootRouteRef, + }, + }, + ); + expect(rendered.getByText('oneOf')).toBeInTheDocument(); + expect(rendered.getByText('Test title')).toBeInTheDocument(); + expect(rendered.getByText('Test output1')).toBeInTheDocument(); + expect(rendered.getByText('Test output2')).toBeInTheDocument(); + }); + it('renders action with multiple input types', async () => { scaffolderApiMock.listActions.mockResolvedValue([ { diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx index f85c1f0e6b..50f7726202 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx @@ -340,11 +340,16 @@ export const ActionPageContent = () => { return undefined; } - const oneOf = renderTables( + const oneOfInput = renderTables( 'oneOf', `${action.id}.input`, action.schema?.input?.oneOf, ); + const oneOfOutput = renderTables( + 'oneOf', + `${action.id}.output`, + action.schema?.output?.oneOf, + ); return ( @@ -374,7 +379,7 @@ export const ActionPageContent = () => { {renderTable( formatRows(`${action.id}.input`, action?.schema?.input), )} - {oneOf} + {oneOfInput} )} {action.schema?.output && ( @@ -385,6 +390,7 @@ export const ActionPageContent = () => { {renderTable( formatRows(`${action.id}.output`, action?.schema?.output), )} + {oneOfOutput} )} {action.examples && (