Merge pull request #21877 from backstage/blam/fix-scaffolder-state

[scaffolder] Fix issue where parameters is set to empty object
This commit is contained in:
Ben Lambert
2023-12-15 10:14:09 +01:00
committed by GitHub
3 changed files with 22 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-react': patch
---
Fix bug where `properties` is set to empty object when it should be empty for schema dependencies
@@ -263,7 +263,6 @@ describe('useTemplateSchema', () => {
expect(first.schema).toEqual({
type: 'object',
properties: {},
});
});
});
@@ -59,13 +59,18 @@ export const useTemplateSchema = (
return stepFeatureFlag ? featureFlags.isActive(stepFeatureFlag) : true;
})
// Then filter out the properties that are not enabled with feature flag
.map(step => ({
...step,
schema: {
...step.schema,
// Title is rendered at the top of the page, so let's ignore this from jsonschemaform
title: undefined,
properties: Object.fromEntries(
.map(step => {
const strippedSchema = {
...step,
schema: {
...step.schema,
// Title is rendered at the top of the page, so let's ignore this from jsonschemaform
title: undefined,
},
} as ParsedTemplateSchema;
if (step.schema?.properties) {
strippedSchema.schema.properties = Object.fromEntries(
Object.entries((step.schema?.properties ?? []) as JsonObject).filter(
([key]) => {
const stepFeatureFlag =
@@ -75,9 +80,11 @@ export const useTemplateSchema = (
: true;
},
),
),
},
}));
);
}
return strippedSchema;
});
return {
presentation: manifest.presentation,