add scaffolder review step custom name option

Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
Stephen Glass
2024-08-24 13:08:17 -04:00
parent e2a4a828e8
commit 4512f7190f
3 changed files with 45 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-react': patch
---
Add `ui:backstage.review.name` option for custom item names on scaffolder review page
@@ -434,4 +434,38 @@ describe('ReviewState', () => {
queryByRole('row', { name: 'Name > Example > Test type6' }),
).not.toBeInTheDocument();
});
it('should allow custom review name', async () => {
const formState = {
foo: 'test',
};
const schemas: ParsedTemplateSchema[] = [
{
mergedSchema: {
type: 'object',
properties: {
foo: {
type: 'string',
'ui:backstage': {
review: {
name: 'bar',
},
},
},
},
},
schema: {},
title: 'test',
uiSchema: {},
},
];
const { queryByRole } = render(
<ReviewState formState={formState} schemas={schemas} />,
);
expect(queryByRole('row', { name: 'Bar test' })).toBeInTheDocument();
expect(queryByRole('row', { name: 'Foo test' })).not.toBeInTheDocument();
});
});
@@ -41,11 +41,13 @@ function processSchema(
data: formState,
});
const name = definitionInSchema?.['ui:backstage']?.review?.name ?? key;
if (definitionInSchema) {
const backstageReviewOptions = definitionInSchema['ui:backstage']?.review;
if (backstageReviewOptions) {
if (backstageReviewOptions.mask) {
return [[key, backstageReviewOptions.mask]];
return [[name, backstageReviewOptions.mask]];
}
if (backstageReviewOptions.show === false) {
return [];
@@ -56,13 +58,13 @@ function processSchema(
definitionInSchema['ui:widget'] === 'password' ||
definitionInSchema['ui:field']?.toLocaleLowerCase('en-us') === 'secret'
) {
return [[key, '******']];
return [[name, '******']];
}
if (definitionInSchema.enum && definitionInSchema.enumNames) {
return [
[
key,
name,
definitionInSchema.enumNames[
definitionInSchema.enum.indexOf(value)
] || value,
@@ -78,7 +80,7 @@ function processSchema(
}
}
return [[key, value]];
return [[name, value]];
}
/**