diff --git a/.changeset/silent-moose-eat.md b/.changeset/silent-moose-eat.md new file mode 100644 index 0000000000..bc66f55181 --- /dev/null +++ b/.changeset/silent-moose-eat.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Support `catalogFilter` array on `OwnedEntityPicker` diff --git a/plugins/scaffolder/src/components/fields/OwnedEntityPicker/OwnedEntityPicker.tsx b/plugins/scaffolder/src/components/fields/OwnedEntityPicker/OwnedEntityPicker.tsx index d5351d54e5..02c437ceb6 100644 --- a/plugins/scaffolder/src/components/fields/OwnedEntityPicker/OwnedEntityPicker.tsx +++ b/plugins/scaffolder/src/components/fields/OwnedEntityPicker/OwnedEntityPicker.tsx @@ -90,17 +90,11 @@ function buildEntityPickerUISchema( uiSchema?.['ui:options'] || {}; const allowedKinds = uiOptions.allowedKinds; - const catalogFilter = { - ...uiOptions.catalogFilter, - ...(allowedKinds - ? { - kind: allowedKinds, - [`relations.${RELATION_OWNED_BY}`]: identityRefs || [], - } - : { - [`relations.${RELATION_OWNED_BY}`]: identityRefs || [], - }), - }; + const catalogFilter = asArray(uiOptions.catalogFilter).map(e => ({ + ...e, + ...(allowedKinds ? { kind: allowedKinds } : {}), + [`relations.${RELATION_OWNED_BY}`]: identityRefs || [], + })); return { 'ui:options': { @@ -108,3 +102,10 @@ function buildEntityPickerUISchema( }, }; } + +function asArray(catalogFilter: any): any[] { + if (catalogFilter) { + return Array.isArray(catalogFilter) ? catalogFilter : [catalogFilter]; + } + return [{}]; +}