diff --git a/.changeset/afraid-pots-protect.md b/.changeset/afraid-pots-protect.md new file mode 100644 index 0000000000..35ba1dc861 --- /dev/null +++ b/.changeset/afraid-pots-protect.md @@ -0,0 +1,19 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Previously when supplying custom scaffolder field extensions, it was necessary to also include the default ones if they were needed. Since the field extensions are keyed by name, there's no harm in leaving the default ones in place when adding custom ones - if templates don't refer to them they will be ignored, and if custom ones are introduced with the same name, the custom ones will take priority over the default ones. + +Users configuring custom field extensions can remove the default ones from the scaffolder route after this change, and they'll still be available: + +```diff + }> + +- +- +- +- + + + +``` diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index 1132368a91..f0ee099924 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -45,10 +45,6 @@ import { ScaffolderPage, scaffolderPlugin, ScaffolderFieldExtensions, - RepoUrlPickerFieldExtension, - OwnerPickerFieldExtension, - EntityPickerFieldExtension, - EntityNamePickerFieldExtension, } from '@backstage/plugin-scaffolder'; import { SearchPage } from '@backstage/plugin-search'; import { TechRadarPage } from '@backstage/plugin-tech-radar'; @@ -129,10 +125,6 @@ const routes = ( /> }> - - - - diff --git a/plugins/scaffolder/src/components/Router.tsx b/plugins/scaffolder/src/components/Router.tsx index 43c8dd6ebb..3d7bbcaf5f 100644 --- a/plugins/scaffolder/src/components/Router.tsx +++ b/plugins/scaffolder/src/components/Router.tsx @@ -32,7 +32,7 @@ import { useElementFilter } from '@backstage/core-plugin-api'; export const Router = () => { const outlet = useOutlet(); - const foundExtensions = useElementFilter(outlet, elements => + const customFieldExtensions = useElementFilter(outlet, elements => elements .selectByComponentData({ key: FIELD_EXTENSION_WRAPPER_KEY, @@ -42,9 +42,15 @@ export const Router = () => { }), ); - const fieldExtensions = foundExtensions.length - ? foundExtensions - : DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS; + const fieldExtensions = [ + ...customFieldExtensions, + ...DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS.filter( + ({ name }) => + !customFieldExtensions.some( + customFieldExtension => customFieldExtension.name === name, + ), + ), + ]; return (