refactor: apply review suggestions
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
'@backstage/frontend-app-api': minor
|
||||
---
|
||||
|
||||
Use an empty root plugin for built-in extension app node specs.
|
||||
Use an app plugin for built-in extension app node specs.
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
'@backstage/frontend-app-api': minor
|
||||
---
|
||||
|
||||
**BREAKING:** The `AppNodeSpec.plugin` property is now required.
|
||||
The `AppNodeSpec.plugin` property is now required.
|
||||
|
||||
@@ -57,7 +57,7 @@ function makeSpec<TConfig, TConfigInput>(
|
||||
attachTo: extension.attachTo,
|
||||
disabled: extension.disabled,
|
||||
extension: extension as Extension<unknown, unknown>,
|
||||
plugin: createFrontendPlugin({ pluginId: 'root' }),
|
||||
plugin: createFrontendPlugin({ pluginId: 'app' }),
|
||||
...spec,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
Extension,
|
||||
ExtensionDefinition,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
import { resolveAppNodeSpecs, rootPlugin } from './resolveAppNodeSpecs';
|
||||
import { resolveAppNodeSpecs } from './resolveAppNodeSpecs';
|
||||
|
||||
function makeExt(
|
||||
id: string,
|
||||
@@ -62,15 +62,15 @@ describe('resolveAppNodeSpecs', () => {
|
||||
builtinExtensions: [a],
|
||||
parameters: [],
|
||||
}),
|
||||
).toStrictEqual([
|
||||
).toEqual([
|
||||
{
|
||||
id: 'a',
|
||||
extension: a,
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: true,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -91,8 +91,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'b',
|
||||
@@ -100,8 +100,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -130,8 +130,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'derp', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'test/a',
|
||||
@@ -217,8 +217,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'a',
|
||||
@@ -226,8 +226,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -257,8 +257,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'd',
|
||||
@@ -266,8 +266,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'c',
|
||||
@@ -275,8 +275,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'a',
|
||||
@@ -284,8 +284,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: true,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'b',
|
||||
@@ -293,8 +293,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'f',
|
||||
@@ -302,8 +302,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: false,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
{
|
||||
id: 'g',
|
||||
@@ -311,8 +311,8 @@ describe('resolveAppNodeSpecs', () => {
|
||||
attachTo: { id: 'root', input: 'default' },
|
||||
disabled: true,
|
||||
config: undefined,
|
||||
plugin: rootPlugin,
|
||||
source: rootPlugin,
|
||||
plugin: expect.any(Object),
|
||||
source: expect.any(Object),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -30,8 +30,6 @@ import {
|
||||
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
|
||||
import { toInternalExtension } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';
|
||||
|
||||
export const rootPlugin = createFrontendPlugin({ pluginId: 'root' });
|
||||
|
||||
/** @internal */
|
||||
export function resolveAppNodeSpecs(options: {
|
||||
features?: FrontendFeature[];
|
||||
@@ -93,6 +91,12 @@ export function resolveAppNodeSpecs(options: {
|
||||
);
|
||||
}
|
||||
|
||||
const appPlugin =
|
||||
plugins.find(plugin => plugin.id === 'app') ??
|
||||
createFrontendPlugin({
|
||||
pluginId: 'app',
|
||||
});
|
||||
|
||||
const configuredExtensions = [
|
||||
...pluginExtensions.map(({ plugin, ...extension }) => {
|
||||
const internalExtension = toInternalExtension(extension);
|
||||
@@ -112,8 +116,8 @@ export function resolveAppNodeSpecs(options: {
|
||||
return {
|
||||
extension: internalExtension,
|
||||
params: {
|
||||
source: rootPlugin,
|
||||
plugin: rootPlugin,
|
||||
source: appPlugin,
|
||||
plugin: appPlugin,
|
||||
attachTo: internalExtension.attachTo,
|
||||
disabled: internalExtension.disabled,
|
||||
config: undefined as unknown,
|
||||
|
||||
@@ -38,7 +38,7 @@ const baseSpec = {
|
||||
extension,
|
||||
attachTo: { id: 'nonexistent', input: 'nonexistent' },
|
||||
disabled: false,
|
||||
plugin: createFrontendPlugin({ pluginId: 'root' }),
|
||||
plugin: createFrontendPlugin({ pluginId: 'app' }),
|
||||
};
|
||||
|
||||
describe('buildAppTree', () => {
|
||||
|
||||
@@ -268,7 +268,7 @@ export interface AppNodeSpec {
|
||||
// (undocumented)
|
||||
readonly id: string;
|
||||
// (undocumented)
|
||||
readonly plugin?: FrontendPlugin;
|
||||
readonly plugin: FrontendPlugin;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
||||
Reference in New Issue
Block a user