Add conditional rendering of oneOf scaffolder action outputs on ActionsPage
Signed-off-by: Tanner Juedeman <tbjuedeman@gmail.com>
This commit is contained in:
@@ -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
|
||||
@@ -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(
|
||||
<ApiProvider apis={apis}>
|
||||
<ActionsPage />
|
||||
</ApiProvider>,
|
||||
{
|
||||
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([
|
||||
{
|
||||
|
||||
@@ -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 (
|
||||
<Box pb={3} key={action.id}>
|
||||
<Box display="flex" alignItems="center">
|
||||
@@ -374,7 +379,7 @@ export const ActionPageContent = () => {
|
||||
{renderTable(
|
||||
formatRows(`${action.id}.input`, action?.schema?.input),
|
||||
)}
|
||||
{oneOf}
|
||||
{oneOfInput}
|
||||
</Box>
|
||||
)}
|
||||
{action.schema?.output && (
|
||||
@@ -385,6 +390,7 @@ export const ActionPageContent = () => {
|
||||
{renderTable(
|
||||
formatRows(`${action.id}.output`, action?.schema?.output),
|
||||
)}
|
||||
{oneOfOutput}
|
||||
</Box>
|
||||
)}
|
||||
{action.examples && (
|
||||
|
||||
Reference in New Issue
Block a user