diff --git a/.changeset/healthy-dancers-dream.md b/.changeset/healthy-dancers-dream.md new file mode 100644 index 0000000000..6a9869f03a --- /dev/null +++ b/.changeset/healthy-dancers-dream.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-app-api': patch +--- + +The options parameter of `createApp` is now optional. diff --git a/.changeset/selfish-flies-kneel.md b/.changeset/selfish-flies-kneel.md new file mode 100644 index 0000000000..0f13f11d11 --- /dev/null +++ b/.changeset/selfish-flies-kneel.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-app-api': patch +--- + +No longer throw error on invalid input if the child is disabled. diff --git a/packages/frontend-app-api/api-report.md b/packages/frontend-app-api/api-report.md index 11c9ac03c5..3d6d936018 100644 --- a/packages/frontend-app-api/api-report.md +++ b/packages/frontend-app-api/api-report.md @@ -27,7 +27,7 @@ export type AppRouteBinder = < ) => void; // @public (undocumented) -export function createApp(options: { +export function createApp(options?: { features?: (BackstagePlugin | ExtensionOverrides)[]; configLoader?: () => Promise; bindRoutes?(context: { bind: AppRouteBinder }): void; diff --git a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts index 7c8f49f96d..68a95fa1fe 100644 --- a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts +++ b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts @@ -167,7 +167,8 @@ describe('instantiateAppNodeTree', () => { { ...makeSpec(simpleExtension), id: 'child-node', - attachTo: { id: 'root-node', input: 'test' }, + // Using an invalid input should not be an error when disabled + attachTo: { id: 'root-node', input: 'invalid' }, disabled: true, }, ]); diff --git a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts index 53f6fdf4da..003abbb97e 100644 --- a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts +++ b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts @@ -180,7 +180,9 @@ export function instantiateAppNodeTree(rootNode: AppNode): void { } return [{ id: child.spec.id, instance: childInstance }]; }); - instantiatedAttachments.set(input, instantiatedChildren); + if (instantiatedChildren.length > 0) { + instantiatedAttachments.set(input, instantiatedChildren); + } } (node as Mutable).instance = createAppNodeInstance({ diff --git a/packages/frontend-app-api/src/wiring/createApp.tsx b/packages/frontend-app-api/src/wiring/createApp.tsx index f02b440ff5..ca0e1d60d1 100644 --- a/packages/frontend-app-api/src/wiring/createApp.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.tsx @@ -225,7 +225,7 @@ function deduplicateFeatures( } /** @public */ -export function createApp(options: { +export function createApp(options?: { features?: (BackstagePlugin | ExtensionOverrides)[]; configLoader?: () => Promise; bindRoutes?(context: { bind: AppRouteBinder }): void; @@ -243,11 +243,11 @@ export function createApp(options: { ); const discoveredFeatures = getAvailableFeatures(config); - const loadedFeatures = (await options.featureLoader?.({ config })) ?? []; + const loadedFeatures = (await options?.featureLoader?.({ config })) ?? []; const allFeatures = deduplicateFeatures([ ...discoveredFeatures, ...loadedFeatures, - ...(options.features ?? []), + ...(options?.features ?? []), ]); const tree = createAppTree({ @@ -271,7 +271,7 @@ export function createApp(options: {