From db6310b6a06c6a679fa911082449617924c43f01 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Mon, 12 Dec 2022 10:26:16 +0000 Subject: [PATCH 1/2] show array of types on installations actions page Signed-off-by: Brian Fletcher --- .changeset/tiny-kangaroos-speak.md | 5 +++++ .../scaffolder/src/components/ActionsPage/ActionsPage.tsx | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/tiny-kangaroos-speak.md diff --git a/.changeset/tiny-kangaroos-speak.md b/.changeset/tiny-kangaroos-speak.md new file mode 100644 index 0000000000..436466c82d --- /dev/null +++ b/.changeset/tiny-kangaroos-speak.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Show input type array correctly on installed actions page. diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx index 78efaa43ff..29951d7cb1 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx @@ -22,6 +22,7 @@ import { Table, TableBody, Box, + Chip, TableCell, TableContainer, TableHead, @@ -107,7 +108,11 @@ export const ActionsPage = () => { {props.title} {props.description} - {props.type} + <> + {[props.type].flat().map(type => ( + + ))} + ); From 1dbf2ce24bc517368564d7d6eed44f0736c01407 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Mon, 12 Dec 2022 11:06:06 +0000 Subject: [PATCH 2/2] add test Signed-off-by: Brian Fletcher --- .../ActionsPage/ActionsPage.test.tsx | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx index 8e2184edf1..02f3c066ca 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.test.tsx @@ -115,6 +115,48 @@ describe('TemplatePage', () => { expect(rendered.getByText('Test output')).toBeInTheDocument(); }); + it('renders action with multipel input types', async () => { + scaffolderApiMock.listActions.mockResolvedValue([ + { + id: 'test', + description: 'example description', + schema: { + input: { + type: 'object', + required: ['foobar'], + properties: { + foobar: { + title: 'Test title', + type: ['array', 'number'], + }, + }, + }, + output: { + type: 'object', + properties: { + buzz: { + title: 'Test output', + type: 'string', + }, + }, + }, + }, + }, + ]); + const rendered = await renderInTestApp( + + + , + { + mountedRoutes: { + '/create/actions': rootRouteRef, + }, + }, + ); + expect(rendered.getByText('array')).toBeInTheDocument(); + expect(rendered.getByText('number')).toBeInTheDocument(); + }); + it('renders action with oneOf input', async () => { scaffolderApiMock.listActions.mockResolvedValue([ {