Merge pull request #20999 from backstage/rugvip/two-fixes
frontend-app-api: two small fixes
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/frontend-app-api': patch
|
||||
---
|
||||
|
||||
The options parameter of `createApp` is now optional.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/frontend-app-api': patch
|
||||
---
|
||||
|
||||
No longer throw error on invalid input if the child is disabled.
|
||||
@@ -27,7 +27,7 @@ export type AppRouteBinder = <
|
||||
) => void;
|
||||
|
||||
// @public (undocumented)
|
||||
export function createApp(options: {
|
||||
export function createApp(options?: {
|
||||
features?: (BackstagePlugin | ExtensionOverrides)[];
|
||||
configLoader?: () => Promise<ConfigApi>;
|
||||
bindRoutes?(context: { bind: AppRouteBinder }): void;
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -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<AppNode>).instance = createAppNodeInstance({
|
||||
|
||||
@@ -225,7 +225,7 @@ function deduplicateFeatures(
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export function createApp(options: {
|
||||
export function createApp(options?: {
|
||||
features?: (BackstagePlugin | ExtensionOverrides)[];
|
||||
configLoader?: () => Promise<ConfigApi>;
|
||||
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: {
|
||||
<RoutingProvider
|
||||
{...extractRouteInfoFromAppNode(tree.root)}
|
||||
routeBindings={resolveRouteBindings(
|
||||
options.bindRoutes,
|
||||
options?.bindRoutes,
|
||||
config,
|
||||
routeIds,
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user