chore: fix a bug that properties is set to empty object when it should not be present when parsing template schema

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2023-12-15 09:42:32 +01:00
parent 7b0199f287
commit b548f02fbf
2 changed files with 17 additions and 11 deletions
@@ -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,