Merge pull request #26414 from backstage/blam/remove-namespace-where-possible

NFS: Removing `namespace` where possible as it's now deprecated
This commit is contained in:
Ben Lambert
2024-09-03 14:11:39 +02:00
committed by GitHub
25 changed files with 79 additions and 130 deletions
+9
View File
@@ -0,0 +1,9 @@
---
'@backstage/frontend-plugin-api': patch
'@backstage/frontend-test-utils': patch
'@backstage/frontend-app-api': patch
'@backstage/core-compat-api': patch
'@backstage/plugin-search-react': patch
---
Removing superfluous `namespace` parameter in favour of `pluginId` instead
+3 -3
View File
@@ -9,12 +9,12 @@ import { AnalyticsEvent } from '@backstage/core-plugin-api';
import { AnalyticsEvent as AnalyticsEvent_2 } from '@backstage/frontend-plugin-api';
import { AnyRouteRefParams } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { BackstagePlugin as BackstagePlugin_2 } from '@backstage/frontend-plugin-api';
import { ComponentType } from 'react';
import { ExtensionDefinition } from '@backstage/frontend-plugin-api';
import { ExtensionOverrides } from '@backstage/frontend-plugin-api';
import { ExternalRouteRef } from '@backstage/core-plugin-api';
import { ExternalRouteRef as ExternalRouteRef_2 } from '@backstage/frontend-plugin-api';
import { FrontendModule } from '@backstage/frontend-plugin-api';
import { FrontendPlugin } from '@backstage/frontend-plugin-api';
import { default as React_2 } from 'react';
import { ReactNode } from 'react';
@@ -29,7 +29,7 @@ export function compatWrapper(element: ReactNode): React_2.JSX.Element;
// @public (undocumented)
export function convertLegacyApp(
rootElement: React_2.JSX.Element,
): (FrontendPlugin | ExtensionOverrides)[];
): (FrontendPlugin | FrontendModule | ExtensionOverrides)[];
// @public (undocumented)
export function convertLegacyPageExtension(
@@ -46,7 +46,7 @@ export function convertLegacyPlugin(
options: {
extensions: ExtensionDefinition[];
},
): BackstagePlugin_2;
): FrontendPlugin;
// @public
export function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(
@@ -73,7 +73,7 @@ describe('collectLegacyRoutes', () => {
defaultConfig: {},
},
{
id: 'api:plugin.scoringdata.service',
id: 'api:score-card/plugin.scoringdata.service',
attachTo: { id: 'root', input: 'apis' },
disabled: false,
},
@@ -89,7 +89,7 @@ describe('collectLegacyRoutes', () => {
defaultConfig: {},
},
{
id: 'api:plugin.stackstorm.service',
id: 'api:stackstorm/plugin.stackstorm.service',
attachTo: { id: 'root', input: 'apis' },
disabled: false,
},
@@ -111,7 +111,7 @@ describe('collectLegacyRoutes', () => {
defaultConfig: {},
},
{
id: 'api:plugin.puppetdb.service',
id: 'api:puppetDb/plugin.puppetdb.service',
attachTo: { id: 'root', input: 'apis' },
disabled: false,
},
@@ -209,7 +209,7 @@ describe('collectLegacyRoutes', () => {
disabled: false,
},
{
id: 'api:plugin.catalog.service',
id: 'api:catalog/plugin.catalog.service',
attachTo: {
id: 'root',
input: 'apis',
@@ -218,7 +218,7 @@ describe('collectLegacyRoutes', () => {
disabled: false,
},
{
id: 'api:catalog-react.starred-entities',
id: 'api:catalog/catalog-react.starred-entities',
attachTo: {
id: 'root',
input: 'apis',
@@ -227,7 +227,7 @@ describe('collectLegacyRoutes', () => {
disabled: false,
},
{
id: 'api:plugin.catalog.entity-presentation',
id: 'api:catalog/plugin.catalog.entity-presentation',
attachTo: {
id: 'root',
input: 'apis',
@@ -241,7 +241,7 @@ describe('collectLegacyRoutes', () => {
id: 'score-card',
extensions: [
{
id: 'api:plugin.scoringdata.service',
id: 'api:score-card/plugin.scoringdata.service',
attachTo: { id: 'root', input: 'apis' },
disabled: false,
},
@@ -269,7 +269,7 @@ export function collectLegacyRoutes(
...extensions,
...Array.from(plugin.getApis()).map(factory =>
ApiBlueprint.make({
namespace: factory.api.id,
name: factory.api.id,
params: { factory },
}),
),
@@ -74,7 +74,7 @@ describe('BackwardsCompatProvider', () => {
);
expect(screen.getByTestId('ctx').textContent).toMatchInlineSnapshot(`
"plugins: app
"plugins: test, app
components: NotFoundErrorPage, BootErrorPage, Progress, Router, ErrorBoundaryFallback
icons: brokenImage, catalog, scaffolder, techdocs, search, chat, dashboard, docs, email, github, group, help, kind:api, kind:component, kind:domain, kind:group, kind:location, kind:system, kind:user, kind:resource, kind:template, user, warning"
`);
@@ -65,7 +65,7 @@ describe('convertLegacyApp', () => {
defaultConfig: {},
},
{
id: 'api:plugin.scoringdata.service',
id: 'api:score-card/plugin.scoringdata.service',
attachTo: { id: 'root', input: 'apis' },
disabled: false,
},
@@ -81,7 +81,7 @@ describe('convertLegacyApp', () => {
defaultConfig: {},
},
{
id: 'api:plugin.stackstorm.service',
id: 'api:stackstorm/plugin.stackstorm.service',
attachTo: { id: 'root', input: 'apis' },
disabled: false,
},
@@ -103,7 +103,7 @@ describe('convertLegacyApp', () => {
defaultConfig: {},
},
{
id: 'api:plugin.puppetdb.service',
id: 'api:puppetDb/plugin.puppetdb.service',
attachTo: { id: 'root', input: 'apis' },
disabled: false,
},
@@ -22,12 +22,13 @@ import React, {
isValidElement,
} from 'react';
import {
ExtensionOverrides,
FrontendModule,
FrontendPlugin,
coreExtensionData,
createExtension,
ExtensionOverrides,
createExtensionInput,
createExtensionOverrides,
createFrontendModule,
} from '@backstage/frontend-plugin-api';
import { getComponentData } from '@backstage/core-plugin-api';
import { collectLegacyRoutes } from './collectLegacyRoutes';
@@ -61,7 +62,7 @@ function selectChildren(
/** @public */
export function convertLegacyApp(
rootElement: React.JSX.Element,
): (FrontendPlugin | ExtensionOverrides)[] {
): (FrontendPlugin | FrontendModule | ExtensionOverrides)[] {
if (getComponentData(rootElement, 'core.type') === 'FlatRoutes') {
return collectLegacyRoutes(rootElement);
}
@@ -104,7 +105,6 @@ export function convertLegacyApp(
const [routesEl] = routesEls;
const CoreLayoutOverride = createExtension({
namespace: 'app',
name: 'layout',
attachTo: { id: 'app', input: 'root' },
inputs: {
@@ -127,7 +127,6 @@ export function convertLegacyApp(
},
});
const CoreNavOverride = createExtension({
namespace: 'app',
name: 'nav',
attachTo: { id: 'app/layout', input: 'nav' },
output: [],
@@ -139,7 +138,8 @@ export function convertLegacyApp(
return [
...collectedRoutes,
createExtensionOverrides({
createFrontendModule({
pluginId: 'app',
extensions: [CoreLayoutOverride, CoreNavOverride],
}),
];
@@ -84,7 +84,7 @@ describe('convertLegacyPlugin', () => {
});
expect(internalConverted.featureFlags).toEqual([{ name: 'test-flag' }]);
expect(internalConverted.extensions.map(e => e.id)).toEqual([
'api:plugin.test.client',
'api:test/plugin.test.client',
'page:test',
]);
});
@@ -18,7 +18,7 @@ import { BackstagePlugin as LegacyBackstagePlugin } from '@backstage/core-plugin
import {
ApiBlueprint,
ExtensionDefinition,
BackstagePlugin as NewBackstagePlugin,
FrontendPlugin as NewBackstagePlugin,
createFrontendPlugin,
} from '@backstage/frontend-plugin-api';
import { convertLegacyRouteRefs } from './convertLegacyRouteRef';
@@ -29,7 +29,7 @@ export function convertLegacyPlugin(
options: { extensions: ExtensionDefinition[] },
): NewBackstagePlugin {
const apiExtensions = Array.from(legacyPlugin.getApis()).map(factory =>
ApiBlueprint.make({ namespace: factory.api.id, params: { factory } }),
ApiBlueprint.make({ name: factory.api.id, params: { factory } }),
);
return createFrontendPlugin({
id: legacyPlugin.getId(),
@@ -22,7 +22,6 @@ import {
} from '@backstage/frontend-plugin-api';
export const Root = createExtension({
namespace: 'root',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
app: createExtensionInput([coreExtensionData.reactElement], {
@@ -89,7 +89,9 @@ function routeInfoFromExtensions(extensions: ExtensionDefinition[]) {
'root',
resolveAppNodeSpecs({
features: [appPlugin, plugin],
builtinExtensions: [resolveExtensionDefinition(Root)],
builtinExtensions: [
resolveExtensionDefinition(Root, { namespace: 'root' }),
],
parameters: readAppExtensionsConfig(new MockConfigApi({})),
forbidden: new Set(['root']),
}),
@@ -667,7 +667,6 @@ describe('instantiateAppNodeTree', () => {
describe('v2', () => {
const simpleExtension = resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
output: [testDataRef, otherDataRef.optional()],
@@ -684,6 +683,7 @@ describe('instantiateAppNodeTree', () => {
];
},
}),
{ namespace: 'app' },
);
function mirrorInputs(ctx: {
@@ -750,7 +750,6 @@ describe('instantiateAppNodeTree', () => {
makeSpec(
resolveExtensionDefinition(
createExtension({
namespace: 'root-node',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
test: createExtensionInput([testDataRef]),
@@ -758,6 +757,7 @@ describe('instantiateAppNodeTree', () => {
output: [inputMirrorDataRef],
factory: mirrorInputs,
}),
{ namespace: 'root-node' },
),
),
makeSpec(simpleExtension, {
@@ -790,7 +790,6 @@ describe('instantiateAppNodeTree', () => {
...makeSpec(
resolveExtensionDefinition(
createExtension({
namespace: 'root-node',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
test: createExtensionInput([testDataRef]),
@@ -798,6 +797,7 @@ describe('instantiateAppNodeTree', () => {
output: [inputMirrorDataRef],
factory: mirrorInputs,
}),
{ namespace: 'root-node' },
),
),
},
@@ -873,7 +873,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
@@ -897,6 +896,7 @@ describe('instantiateAppNodeTree', () => {
output: [inputMirrorDataRef],
factory: mirrorInputs,
}),
{ namespace: 'app' },
),
),
});
@@ -946,7 +946,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
output: [testDataRef],
@@ -956,6 +955,7 @@ describe('instantiateAppNodeTree', () => {
throw error;
},
}),
{ namespace: 'app' },
),
),
attachments: new Map(),
@@ -972,7 +972,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
output: [testDataRef, testDataRef],
@@ -980,6 +979,7 @@ describe('instantiateAppNodeTree', () => {
return [testDataRef('test'), testDataRef('test2')];
},
}),
{ namespace: 'app' },
),
),
attachments: new Map(),
@@ -996,7 +996,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
output: [testDataRef],
@@ -1004,6 +1003,7 @@ describe('instantiateAppNodeTree', () => {
return [] as any;
},
}),
{ namespace: 'app' },
),
),
attachments: new Map(),
@@ -1021,7 +1021,6 @@ describe('instantiateAppNodeTree', () => {
resolveExtensionDefinition(
// @ts-expect-error
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
output: [], // Output not declared
@@ -1029,6 +1028,7 @@ describe('instantiateAppNodeTree', () => {
return [testDataRef('test')] as any;
},
}),
{ namespace: 'app' },
),
),
attachments: new Map(),
@@ -1045,7 +1045,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
@@ -1056,6 +1055,7 @@ describe('instantiateAppNodeTree', () => {
output: [],
factory: () => [],
}),
{ namespace: 'app' },
),
),
attachments: new Map(),
@@ -1090,7 +1090,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'parent',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
@@ -1099,6 +1098,7 @@ describe('instantiateAppNodeTree', () => {
output: [],
factory: () => [],
}),
{ namespace: 'app' },
),
),
}),
@@ -1129,12 +1129,12 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'parent',
attachTo: { id: 'ignored', input: 'ignored' },
output: [],
factory: () => [],
}),
{ namespace: 'app' },
),
),
}),
@@ -1162,7 +1162,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
@@ -1173,6 +1172,7 @@ describe('instantiateAppNodeTree', () => {
output: [],
factory: () => [],
}),
{ namespace: 'app' },
),
),
}),
@@ -1197,7 +1197,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
@@ -1209,6 +1208,7 @@ describe('instantiateAppNodeTree', () => {
output: [],
factory: () => [],
}),
{ namespace: 'app' },
),
),
}),
@@ -1227,7 +1227,6 @@ describe('instantiateAppNodeTree', () => {
node: makeNode(
resolveExtensionDefinition(
createExtension({
namespace: 'app',
name: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
inputs: {
@@ -1238,6 +1237,7 @@ describe('instantiateAppNodeTree', () => {
output: [],
factory: () => [],
}),
{ namespace: 'app' },
),
),
}),
@@ -206,7 +206,9 @@ export function createSpecializedApp(options?: {
'root',
resolveAppNodeSpecs({
features,
builtinExtensions: [resolveExtensionDefinition(Root)],
builtinExtensions: [
resolveExtensionDefinition(Root, { namespace: 'root' }),
],
parameters: readAppExtensionsConfig(config),
forbidden: new Set(['root']),
}),
@@ -284,9 +284,9 @@ describe('createApp', () => {
</api:app/app-theme>
<api:app/components out=[core.api.factory]>
components [
<component:core.components.progress out=[core.component.component] />
<component:core.components.notFoundErrorPage out=[core.component.component] />
<component:core.components.errorBoundaryFallback out=[core.component.component] />
<component:app/core.components.progress out=[core.component.component] />
<component:app/core.components.notFoundErrorPage out=[core.component.component] />
<component:app/core.components.errorBoundaryFallback out=[core.component.component] />
]
</api:app/components>
<api:app/icons out=[core.api.factory] />
+1 -1
View File
@@ -454,7 +454,7 @@ export function createComponentExtension<TProps extends {}>(options: {
>;
};
kind: 'component';
namespace: string;
namespace: undefined;
name: string;
}>;
@@ -31,7 +31,7 @@ describe('ApiBlueprint', () => {
params: {
factory,
},
namespace: 'test',
name: 'test',
});
expect(extension).toMatchInlineSnapshot(`
@@ -47,8 +47,8 @@ describe('ApiBlueprint', () => {
"factory": [Function],
"inputs": {},
"kind": "api",
"name": undefined,
"namespace": "test",
"name": "test",
"namespace": undefined,
"output": [
[Function],
],
@@ -72,7 +72,7 @@ describe('ApiBlueprint', () => {
inputs: {
test: createExtensionInput([ApiBlueprint.dataRefs.factory]),
},
namespace: api.id,
name: api.id,
factory(originalFactory, { config: _config, inputs: _inputs }) {
return originalFactory({
factory: createApiFactory({
@@ -122,8 +122,8 @@ describe('ApiBlueprint', () => {
},
},
"kind": "api",
"name": undefined,
"namespace": "test",
"name": "test",
"namespace": undefined,
"output": [
[Function],
],
@@ -72,7 +72,6 @@ describe('AppRootWrapperBlueprint', () => {
it('should render the complex component wrapper', async () => {
const extension = AppRootWrapperBlueprint.makeWithOverrides({
name: 'test',
config: {
schema: {
name: z => z.string(),
@@ -59,7 +59,6 @@ describe('RouterBlueprint', () => {
it('should work with simple options', async () => {
const extension = RouterBlueprint.make({
namespace: 'test',
params: {
Component: ({ children }) => (
<MemoryRouter>
@@ -86,7 +85,6 @@ describe('RouterBlueprint', () => {
it('should work with complex options and props', async () => {
const extension = RouterBlueprint.makeWithOverrides({
namespace: 'test',
name: 'test',
config: {
schema: {
@@ -115,9 +113,8 @@ describe('RouterBlueprint', () => {
config: { name: 'Robin' },
}).add(
createExtension({
namespace: 'test',
attachTo: {
id: 'app-router-component:test/test',
id: 'app-router-component:test',
input: 'children',
},
output: [coreExtensionData.reactElement],
@@ -57,7 +57,6 @@ describe('SignInPageBlueprint', () => {
const MockSignInPage = () => <div data-testid="mock-sign-in" />;
const extension = SignInPageBlueprint.make({
name: 'test',
params: { loader: async () => () => <MockSignInPage /> },
});
@@ -33,8 +33,7 @@ export function createComponentExtension<TProps extends {}>(options: {
}) {
return createExtension({
kind: 'component',
namespace: options.ref.id,
name: options.name,
name: options.ref.id,
attachTo: { id: 'api:app/components', input: 'components' },
disabled: options.disabled,
output: [createComponentExtension.componentDataRef],
@@ -31,7 +31,6 @@ function unused(..._any: any[]) {}
describe('createExtension', () => {
it('should create an extension with a simple output', () => {
const baseConfig = {
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef],
};
@@ -41,7 +40,7 @@ describe('createExtension', () => {
return [stringDataRef('bar')];
},
});
expect(extension).toMatchObject({ version: 'v2', namespace: 'test' });
expect(extension).toMatchObject({ version: 'v2' });
// Member arrow function declaration
createExtension({
@@ -161,7 +160,6 @@ describe('createExtension', () => {
it('should create an extension with a some optional output', () => {
const baseConfig = {
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef.optional()],
};
@@ -169,7 +167,7 @@ describe('createExtension', () => {
...baseConfig,
factory: () => [stringDataRef('bar')],
});
expect(extension).toMatchObject({ version: 'v2', namespace: 'test' });
expect(extension).toMatchObject({ version: 'v2' });
createExtension({
...baseConfig,
@@ -206,7 +204,6 @@ describe('createExtension', () => {
it('should create an extension with input', () => {
const extension = createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
inputs: {
mixed: createExtensionInput([stringDataRef, numberDataRef.optional()]),
@@ -250,15 +247,14 @@ describe('createExtension', () => {
return [stringDataRef('bar')];
},
});
expect(extension).toMatchObject({ version: 'v2', namespace: 'test' });
expect(extension).toMatchObject({ version: 'v2' });
expect(String(extension)).toBe(
'ExtensionDefinition{namespace=test,attachTo=root@default}',
'ExtensionDefinition{attachTo=root@default}',
);
});
it('should create an extension with config', () => {
const extension = createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
config: {
schema: {
@@ -284,9 +280,9 @@ describe('createExtension', () => {
return [stringDataRef('bar')];
},
});
expect(extension).toMatchObject({ version: 'v2', namespace: 'test' });
expect(extension).toMatchObject({ version: 'v2' });
expect(String(extension)).toBe(
'ExtensionDefinition{namespace=test,attachTo=root@default}',
'ExtensionDefinition{attachTo=root@default}',
);
expect(
@@ -330,7 +326,6 @@ describe('createExtension', () => {
expect(
// @ts-expect-error
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef],
factory() {
@@ -342,7 +337,6 @@ describe('createExtension', () => {
expect(
// @ts-expect-error
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef],
factory() {
@@ -354,7 +348,6 @@ describe('createExtension', () => {
// Duplicate output, we won't attempt to handle this a compile time and instead error out at runtime
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef],
factory() {
@@ -366,7 +359,6 @@ describe('createExtension', () => {
expect(
// @ts-expect-error
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef],
factory() {
@@ -377,7 +369,6 @@ describe('createExtension', () => {
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef],
factory() {
@@ -388,7 +379,6 @@ describe('createExtension', () => {
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef.optional()],
factory() {
@@ -399,7 +389,6 @@ describe('createExtension', () => {
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef.optional()],
factory() {
@@ -413,7 +402,6 @@ describe('createExtension', () => {
expect(
// @ts-expect-error
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef],
*factory() {
@@ -425,7 +413,6 @@ describe('createExtension', () => {
expect(
// @ts-expect-error
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef],
*factory() {
@@ -437,7 +424,6 @@ describe('createExtension', () => {
// Duplicate output, we won't attempt to handle this a compile time and instead error out at runtime
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef],
*factory() {
@@ -450,7 +436,6 @@ describe('createExtension', () => {
expect(
// @ts-expect-error
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef],
*factory() {
@@ -462,7 +447,6 @@ describe('createExtension', () => {
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef],
*factory() {
@@ -474,7 +458,6 @@ describe('createExtension', () => {
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef.optional()],
*factory() {
@@ -486,7 +469,6 @@ describe('createExtension', () => {
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef.optional()],
*factory() {
@@ -499,7 +481,6 @@ describe('createExtension', () => {
it('should support new form of inputs', () => {
expect(
createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
inputs: {
header: createExtensionInput([stringDataRef.optional()], {
@@ -534,7 +515,6 @@ describe('createExtension', () => {
describe('overrides', () => {
it('should allow overriding of config and merging', () => {
const testExtension = createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'blob' },
output: [stringDataRef],
config: {
@@ -563,7 +543,6 @@ describe('createExtension', () => {
it('should allow overriding of outputs', () => {
const testExtension = createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'blob' },
output: [stringDataRef],
inputs: {
@@ -603,7 +582,6 @@ describe('createExtension', () => {
it('should allow overriding the factory function and calling the original factory', () => {
const testExtension = createExtension({
namespace: 'test',
attachTo: { id: 'root', input: 'blob' },
output: [stringDataRef],
config: {
@@ -635,7 +613,6 @@ describe('createExtension', () => {
it('should allow overriding the returned values from the parent factory', () => {
const testExtension = createExtension({
kind: 'thing',
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef, numberDataRef],
config: {
@@ -666,7 +643,6 @@ describe('createExtension', () => {
it('should work functionally with overrides', () => {
const testExtension = createExtension({
kind: 'thing',
namespace: 'test',
attachTo: { id: 'root', input: 'default' },
output: [stringDataRef],
config: {
@@ -30,7 +30,6 @@ const stringDataRef = createExtensionDataRef<string>().with({
describe('createExtensionTester', () => {
it('should return the correct dataRef when called', () => {
const extension = createExtension({
namespace: 'test',
attachTo: { id: 'ignored', input: 'ignored' },
output: [stringDataRef],
factory: () => [stringDataRef('test-text')],
@@ -43,7 +42,6 @@ describe('createExtensionTester', () => {
it('should throw an error if trying to access an instance not provided to the tester', () => {
const extension = createExtension({
namespace: 'test',
name: 'e1',
attachTo: { id: 'ignored', input: 'ignored' },
output: [stringDataRef],
@@ -51,7 +49,6 @@ describe('createExtensionTester', () => {
});
const extension2 = createExtension({
namespace: 'test',
name: 'e2',
attachTo: { id: 'ignored', input: 'ignored' },
output: [stringDataRef],
@@ -61,13 +58,12 @@ describe('createExtensionTester', () => {
const tester = createExtensionTester(extension);
expect(() => tester.query(extension2)).toThrow(
"Extension with ID 'test/e2' not found, please make sure it's added to the tester",
"Extension with ID 'e2' not found, please make sure it's added to the tester",
);
});
it('should throw an error if trying to access an instance which is not part of the tree', () => {
const extension = createExtension({
namespace: 'test',
name: 'e1',
attachTo: { id: 'ignored', input: 'ignored' },
output: [stringDataRef],
@@ -75,7 +71,6 @@ describe('createExtensionTester', () => {
});
const extension2 = createExtension({
namespace: 'test',
name: 'e2',
attachTo: { id: 'ignored', input: 'ignored' },
output: [stringDataRef],
@@ -85,7 +80,7 @@ describe('createExtensionTester', () => {
const tester = createExtensionTester(extension).add(extension2);
expect(() => tester.query(extension2)).toThrow(
"Extension with ID 'test/e2' has not been instantiated, because it is not part of the test subject's extension tree",
"Extension with ID 'e2' has not been instantiated, because it is not part of the test subject's extension tree",
);
});
@@ -99,7 +94,6 @@ describe('createExtensionTester', () => {
});
const extension = createExtension({
namespace: 'test',
name: 'e1',
attachTo: { id: 'ignored', input: 'ignored' },
output: [stringDataRef, internalRef.optional()],
@@ -129,7 +123,6 @@ describe('createExtensionTester', () => {
});
const extension = createExtension({
namespace: 'test',
name: 'e1',
inputs: {
ignored: createExtensionInput([stringDataRef]),
@@ -140,9 +133,8 @@ describe('createExtensionTester', () => {
});
const extraExtension = createExtension({
namespace: 'test',
name: 'e2',
attachTo: { id: 'test/e1', input: 'ignored' },
attachTo: { id: 'e1', input: 'ignored' },
output: [stringDataRef, internalRef.optional()],
factory: () => [stringDataRef('test-text')],
});
@@ -25,7 +25,6 @@ import { ConfigReader } from '@backstage/config';
import { JsonObject } from '@backstage/types';
import {
createExtension,
createExtensionOverrides,
ExtensionDefinition,
coreExtensionData,
RouteRef,
@@ -33,6 +32,7 @@ import {
IconComponent,
RouterBlueprint,
NavItemBlueprint,
createFrontendPlugin,
} from '@backstage/frontend-plugin-api';
import appPlugin from '@backstage/plugin-app';
@@ -136,7 +136,6 @@ export function renderInTestApp(
): RenderResult {
const extensions: Array<ExtensionDefinition> = [
createExtension({
namespace: 'test',
attachTo: { id: 'app/routes', input: 'routes' },
output: [coreExtensionData.reactElement, coreExtensionData.routePath],
factory: () => {
@@ -147,7 +146,6 @@ export function renderInTestApp(
},
}),
RouterBlueprint.make({
namespace: 'test',
params: {
Component: ({ children }) => <MemoryRouter>{children}</MemoryRouter>,
},
@@ -182,10 +180,11 @@ export function renderInTestApp(
}
const features: FrontendFeature[] = [
appPluginOverride,
createExtensionOverrides({
createFrontendPlugin({
id: 'test',
extensions,
}),
appPluginOverride,
];
if (options?.features) {
-24
View File
@@ -29,30 +29,6 @@ const appPlugin: FrontendPlugin<
{},
{},
{
[x: `component:app/${string}`]: ExtensionDefinition<{
config: {};
configInput: {};
output: ConfigurableExtensionDataRef<
{
ref: ComponentRef;
impl: ComponentType;
},
'core.component.component',
{}
>;
inputs: {
[x: string]: ExtensionInput<
AnyExtensionDataRef,
{
optional: boolean;
singleton: boolean;
}
>;
};
kind: 'component';
namespace: string;
name: string;
}>;
app: ExtensionDefinition<{
config: {};
configInput: {};
@@ -87,7 +87,7 @@ describe('SearchResultListItemBlueprint', () => {
});
const mockSearchPage = PageBlueprint.makeWithOverrides({
namespace: 'search',
name: 'search',
inputs: {
items: createExtensionInput([searchResultListItemDataRef]),
},