From e632a09b9d3d340abf95d09906156208b0fec7ba Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 2 Sep 2024 16:18:24 +0200 Subject: [PATCH 01/12] chore: update core-compat-api Signed-off-by: blam --- .../src/collectLegacyRoutes.test.tsx | 14 +++++++------- .../core-compat-api/src/collectLegacyRoutes.tsx | 2 +- .../core-compat-api/src/convertLegacyApp.test.tsx | 6 +++--- packages/core-compat-api/src/convertLegacyApp.ts | 10 +++++----- .../src/convertLegacyPlugin.test.tsx | 2 +- .../core-compat-api/src/convertLegacyPlugin.ts | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/core-compat-api/src/collectLegacyRoutes.test.tsx b/packages/core-compat-api/src/collectLegacyRoutes.test.tsx index 4c2acd35a6..0319628b14 100644 --- a/packages/core-compat-api/src/collectLegacyRoutes.test.tsx +++ b/packages/core-compat-api/src/collectLegacyRoutes.test.tsx @@ -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, }, diff --git a/packages/core-compat-api/src/collectLegacyRoutes.tsx b/packages/core-compat-api/src/collectLegacyRoutes.tsx index 197c245278..43e66ce859 100644 --- a/packages/core-compat-api/src/collectLegacyRoutes.tsx +++ b/packages/core-compat-api/src/collectLegacyRoutes.tsx @@ -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 }, }), ), diff --git a/packages/core-compat-api/src/convertLegacyApp.test.tsx b/packages/core-compat-api/src/convertLegacyApp.test.tsx index b76a6c2d71..224ab46221 100644 --- a/packages/core-compat-api/src/convertLegacyApp.test.tsx +++ b/packages/core-compat-api/src/convertLegacyApp.test.tsx @@ -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, }, diff --git a/packages/core-compat-api/src/convertLegacyApp.ts b/packages/core-compat-api/src/convertLegacyApp.ts index 2729664941..c3e569e85f 100644 --- a/packages/core-compat-api/src/convertLegacyApp.ts +++ b/packages/core-compat-api/src/convertLegacyApp.ts @@ -23,11 +23,12 @@ import React, { } from 'react'; import { ExtensionOverrides, + FrontendModule, FrontendPlugin, coreExtensionData, createExtension, 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)[] { 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], }), ]; diff --git a/packages/core-compat-api/src/convertLegacyPlugin.test.tsx b/packages/core-compat-api/src/convertLegacyPlugin.test.tsx index 3d5b001c61..01266a35b7 100644 --- a/packages/core-compat-api/src/convertLegacyPlugin.test.tsx +++ b/packages/core-compat-api/src/convertLegacyPlugin.test.tsx @@ -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', ]); }); diff --git a/packages/core-compat-api/src/convertLegacyPlugin.ts b/packages/core-compat-api/src/convertLegacyPlugin.ts index bf5759f214..5fd5e585e6 100644 --- a/packages/core-compat-api/src/convertLegacyPlugin.ts +++ b/packages/core-compat-api/src/convertLegacyPlugin.ts @@ -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(), From 5f29b079164a986fd1ea8cc26f606f6584a8febf Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 2 Sep 2024 16:37:55 +0200 Subject: [PATCH 02/12] chore: default namespace to test in createExtensionTester Signed-off-by: blam --- packages/frontend-test-utils/src/app/createExtensionTester.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index f9c1b3cb89..b520ee35bb 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -110,6 +110,8 @@ export class ExtensionTester { const definition = { ...extension, + // If no namespace is set, we default to "test" + namespace: namespace ?? 'test', // setting name "test" as fallback name: !namespace && !name ? 'test' : name, }; From ff60b8cd7013b5dbbfecc89f2bd9dd70b51945f1 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 2 Sep 2024 16:38:18 +0200 Subject: [PATCH 03/12] chore: work on frontend-app-api Signed-off-by: blam --- .../frontend-app-api/src/extensions/Root.ts | 1 - .../extractRouteInfoFromAppNode.test.ts | 4 ++- .../src/tree/instantiateAppNodeTree.test.ts | 28 +++++++++---------- .../src/wiring/createSpecializedApp.tsx | 4 ++- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/frontend-app-api/src/extensions/Root.ts b/packages/frontend-app-api/src/extensions/Root.ts index 3b1c237e7a..66c4db3140 100644 --- a/packages/frontend-app-api/src/extensions/Root.ts +++ b/packages/frontend-app-api/src/extensions/Root.ts @@ -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], { diff --git a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts index 4e1c37e9a0..7ffe64d6d7 100644 --- a/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts +++ b/packages/frontend-app-api/src/routing/extractRouteInfoFromAppNode.test.ts @@ -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']), }), diff --git a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts index 06d412b30e..f24a9e17f3 100644 --- a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts +++ b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.test.ts @@ -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' }, ), ), }), diff --git a/packages/frontend-app-api/src/wiring/createSpecializedApp.tsx b/packages/frontend-app-api/src/wiring/createSpecializedApp.tsx index 27f1d52822..612befc597 100644 --- a/packages/frontend-app-api/src/wiring/createSpecializedApp.tsx +++ b/packages/frontend-app-api/src/wiring/createSpecializedApp.tsx @@ -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']), }), From ba263b350c1ca9e4dae9a9159da933a81c158300 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 2 Sep 2024 16:38:32 +0200 Subject: [PATCH 04/12] chore: updating frontend-plugin-api Signed-off-by: blam --- .../src/blueprints/ApiBlueprint.test.ts | 12 ++-- .../src/blueprints/RouterBlueprint.test.tsx | 3 - .../extensions/createComponentExtension.tsx | 3 +- .../src/wiring/createExtension.test.ts | 68 +++++++------------ 4 files changed, 30 insertions(+), 56 deletions(-) diff --git a/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.test.ts b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.test.ts index 800eb5d7b1..519b7a4d1a 100644 --- a/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.test.ts +++ b/packages/frontend-plugin-api/src/blueprints/ApiBlueprint.test.ts @@ -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], ], diff --git a/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx index 3062d6d9de..99ceb2a7fa 100644 --- a/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx @@ -59,7 +59,6 @@ describe('RouterBlueprint', () => { it('should work with simple options', async () => { const extension = RouterBlueprint.make({ - namespace: 'test', params: { Component: ({ children }) => ( @@ -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,7 +113,6 @@ describe('RouterBlueprint', () => { config: { name: 'Robin' }, }).add( createExtension({ - namespace: 'test', attachTo: { id: 'app-router-component:test/test', input: 'children', diff --git a/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx b/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx index c8fa907bc8..ca8f1f807b 100644 --- a/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx @@ -33,8 +33,7 @@ export function createComponentExtension(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], diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 68478a756e..d22effa513 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -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,7 @@ 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 +644,7 @@ describe('createExtension', () => { it('should work functionally with overrides', () => { const testExtension = createExtension({ kind: 'thing', - namespace: 'test', + attachTo: { id: 'root', input: 'default' }, output: [stringDataRef], config: { @@ -749,28 +727,28 @@ describe('createExtension', () => { const optExt = createExtension({ name: 'o', - attachTo: { id: 'subject', input: 'opt' }, + attachTo: { id: 'test/subject', input: 'opt' }, output: [testDataRef1], factory: () => [testDataRef1('orig-opt')], }); const singleExt = createExtension({ name: 's', - attachTo: { id: 'subject', input: 'single' }, + attachTo: { id: 'test/subject', input: 'single' }, output: [testDataRef1, testDataRef2.optional()], factory: () => [testDataRef1('orig-single')], }); const multi1Ext = createExtension({ name: 'm1', - attachTo: { id: 'subject', input: 'multi' }, + attachTo: { id: 'test/subject', input: 'multi' }, output: [testDataRef1], factory: () => [testDataRef1('orig-multi1')], }); const multi2Ext = createExtension({ name: 'm2', - attachTo: { id: 'subject', input: 'multi' }, + attachTo: { id: 'test/subject', input: 'multi' }, output: [testDataRef1], factory: () => [testDataRef1('orig-multi2')], }); @@ -786,7 +764,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'm1=orig-multi1,m2=orig-multi2', + multi: 'test/m1=orig-multi1,test/m2=orig-multi2', }); // All values provided @@ -813,7 +791,7 @@ describe('createExtension', () => { opt: 'opt', single: 'single', singleOpt: 'singleOpt', - multi: 'm1=multi1,m2=multi2', + multi: 'test/m1=multi1,test/m2=multi2', }); // Minimal values provided @@ -862,7 +840,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'm1=orig-multi1,m2=orig-multi2', + multi: 'test/m1=orig-multi1,test/m2=orig-multi2', }); // Forward inputs separately @@ -889,7 +867,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'm1=orig-multi1,m2=orig-multi2', + multi: 'test/m1=orig-multi1,test/m2=orig-multi2', }); // Reordering inputs @@ -916,7 +894,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'm2=orig-multi2,m1=orig-multi1', + multi: 'test/m2=orig-multi2,test/m1=orig-multi1', }); // Filter out inputs @@ -943,7 +921,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'm2=orig-multi2', + multi: 'test/m2=orig-multi2', }); // Overriding based on original input @@ -974,7 +952,7 @@ describe('createExtension', () => { opt: 'none', single: 'override-orig-single', singleOpt: 'new-singleOpt', - multi: 'm1=override-orig-multi1,m2=override-orig-multi2', + multi: 'test/m1=override-orig-multi1,test/m2=override-orig-multi2', }); // Mismatched input override length @@ -997,7 +975,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'subject', override data provided for input 'multi' must match the length of the original inputs"`, + `"Failed to instantiate extension 'test/subject', override data provided for input 'multi' must match the length of the original inputs"`, ); // Mix forward and data override @@ -1020,7 +998,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'subject', override data for input 'multi' may not mix forwarded inputs with data overrides"`, + `"Failed to instantiate extension 'test/subject', override data for input 'multi' may not mix forwarded inputs with data overrides"`, ); // Required input not provided @@ -1043,7 +1021,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'subject', missing required extension data value(s) 'test1'"`, + `"Failed to instantiate extension 'test/subject', missing required extension data value(s) 'test1'"`, ); // Wrong value provided @@ -1072,7 +1050,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'subject', extension data 'test2' was provided but not declared"`, + `"Failed to instantiate extension 'test/subject', extension data 'test2' was provided but not declared"`, ); }); }); From 84d89bb5f3f4c28984a466fd10a274a26f6a6fc8 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 2 Sep 2024 16:57:30 +0200 Subject: [PATCH 05/12] chore: fix the router test a different way, don't set namespace as test by default Signed-off-by: blam --- .../core-compat-api/src/convertLegacyApp.ts | 1 - .../src/blueprints/RouterBlueprint.test.tsx | 2 +- .../src/wiring/createExtension.test.ts | 30 +++++++++---------- .../src/app/createExtensionTester.tsx | 2 -- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/packages/core-compat-api/src/convertLegacyApp.ts b/packages/core-compat-api/src/convertLegacyApp.ts index c3e569e85f..610c9e8842 100644 --- a/packages/core-compat-api/src/convertLegacyApp.ts +++ b/packages/core-compat-api/src/convertLegacyApp.ts @@ -22,7 +22,6 @@ import React, { isValidElement, } from 'react'; import { - ExtensionOverrides, FrontendModule, FrontendPlugin, coreExtensionData, diff --git a/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx index 99ceb2a7fa..ab6bb1eb1f 100644 --- a/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx @@ -114,7 +114,7 @@ describe('RouterBlueprint', () => { }).add( createExtension({ attachTo: { - id: 'app-router-component:test/test', + id: 'app-router-component:test', input: 'children', }, output: [coreExtensionData.reactElement], diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index d22effa513..3c68c910f7 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -727,28 +727,28 @@ describe('createExtension', () => { const optExt = createExtension({ name: 'o', - attachTo: { id: 'test/subject', input: 'opt' }, + attachTo: { id: 'subject', input: 'opt' }, output: [testDataRef1], factory: () => [testDataRef1('orig-opt')], }); const singleExt = createExtension({ name: 's', - attachTo: { id: 'test/subject', input: 'single' }, + attachTo: { id: 'subject', input: 'single' }, output: [testDataRef1, testDataRef2.optional()], factory: () => [testDataRef1('orig-single')], }); const multi1Ext = createExtension({ name: 'm1', - attachTo: { id: 'test/subject', input: 'multi' }, + attachTo: { id: 'subject', input: 'multi' }, output: [testDataRef1], factory: () => [testDataRef1('orig-multi1')], }); const multi2Ext = createExtension({ name: 'm2', - attachTo: { id: 'test/subject', input: 'multi' }, + attachTo: { id: 'subject', input: 'multi' }, output: [testDataRef1], factory: () => [testDataRef1('orig-multi2')], }); @@ -764,7 +764,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'test/m1=orig-multi1,test/m2=orig-multi2', + multi: 'm1=orig-multi1,m2=orig-multi2', }); // All values provided @@ -791,7 +791,7 @@ describe('createExtension', () => { opt: 'opt', single: 'single', singleOpt: 'singleOpt', - multi: 'test/m1=multi1,test/m2=multi2', + multi: 'm1=multi1,m2=multi2', }); // Minimal values provided @@ -840,7 +840,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'test/m1=orig-multi1,test/m2=orig-multi2', + multi: 'm1=orig-multi1,m2=orig-multi2', }); // Forward inputs separately @@ -867,7 +867,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'test/m1=orig-multi1,test/m2=orig-multi2', + multi: 'm1=orig-multi1,m2=orig-multi2', }); // Reordering inputs @@ -894,7 +894,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'test/m2=orig-multi2,test/m1=orig-multi1', + multi: 'm2=orig-multi2,m1=orig-multi1', }); // Filter out inputs @@ -921,7 +921,7 @@ describe('createExtension', () => { opt: 'orig-opt', single: 'orig-single', singleOpt: 'none', - multi: 'test/m2=orig-multi2', + multi: 'm2=orig-multi2', }); // Overriding based on original input @@ -952,7 +952,7 @@ describe('createExtension', () => { opt: 'none', single: 'override-orig-single', singleOpt: 'new-singleOpt', - multi: 'test/m1=override-orig-multi1,test/m2=override-orig-multi2', + multi: 'm1=override-orig-multi1,m2=override-orig-multi2', }); // Mismatched input override length @@ -975,7 +975,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'test/subject', override data provided for input 'multi' must match the length of the original inputs"`, + `"Failed to instantiate extension 'subject', override data provided for input 'multi' must match the length of the original inputs"`, ); // Mix forward and data override @@ -998,7 +998,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'test/subject', override data for input 'multi' may not mix forwarded inputs with data overrides"`, + `"Failed to instantiate extension 'subject', override data for input 'multi' may not mix forwarded inputs with data overrides"`, ); // Required input not provided @@ -1021,7 +1021,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'test/subject', missing required extension data value(s) 'test1'"`, + `"Failed to instantiate extension 'subject', missing required extension data value(s) 'test1'"`, ); // Wrong value provided @@ -1050,7 +1050,7 @@ describe('createExtension', () => { .add(multi2Ext) .get(outputRef), ).toThrowErrorMatchingInlineSnapshot( - `"Failed to instantiate extension 'test/subject', extension data 'test2' was provided but not declared"`, + `"Failed to instantiate extension 'subject', extension data 'test2' was provided but not declared"`, ); }); }); diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.tsx index b520ee35bb..f9c1b3cb89 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.tsx @@ -110,8 +110,6 @@ export class ExtensionTester { const definition = { ...extension, - // If no namespace is set, we default to "test" - namespace: namespace ?? 'test', // setting name "test" as fallback name: !namespace && !name ? 'test' : name, }; From d7f25e1d43e7dae5832f1da2ed609bb850388983 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 2 Sep 2024 17:00:08 +0200 Subject: [PATCH 06/12] chore: fixing formatting Signed-off-by: blam --- packages/frontend-plugin-api/src/wiring/createExtension.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts index 3c68c910f7..5e8aa1c57a 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.test.ts @@ -613,7 +613,6 @@ describe('createExtension', () => { it('should allow overriding the returned values from the parent factory', () => { const testExtension = createExtension({ kind: 'thing', - attachTo: { id: 'root', input: 'default' }, output: [stringDataRef, numberDataRef], config: { @@ -644,7 +643,6 @@ describe('createExtension', () => { it('should work functionally with overrides', () => { const testExtension = createExtension({ kind: 'thing', - attachTo: { id: 'root', input: 'default' }, output: [stringDataRef], config: { From 1ac573b4f3e4f8ffa34ff0d81cb3bfd9160d74f7 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 3 Sep 2024 07:59:02 +0200 Subject: [PATCH 07/12] chore: smol refactor Signed-off-by: blam --- .../src/app/createExtensionTester.test.tsx | 14 +++----------- .../src/app/renderInTestApp.tsx | 4 ++-- .../SearchResultListItemBlueprint.test.tsx | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx index 582bbeed00..a6265ae3ac 100644 --- a/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx +++ b/packages/frontend-test-utils/src/app/createExtensionTester.test.tsx @@ -30,7 +30,6 @@ const stringDataRef = createExtensionDataRef().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')], }); diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index fae67a260c..80897e942a 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -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, + createExtensionOverrides, } from '@backstage/frontend-plugin-api'; import appPlugin from '@backstage/plugin-app'; @@ -182,10 +182,10 @@ export function renderInTestApp( } const features: FrontendFeature[] = [ - appPluginOverride, createExtensionOverrides({ extensions, }), + appPluginOverride, ]; if (options?.features) { diff --git a/plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.test.tsx b/plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.test.tsx index b50ca9e55a..6b8f75d70c 100644 --- a/plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.test.tsx +++ b/plugins/search-react/src/alpha/blueprints/SearchResultListItemBlueprint.test.tsx @@ -87,7 +87,7 @@ describe('SearchResultListItemBlueprint', () => { }); const mockSearchPage = PageBlueprint.makeWithOverrides({ - namespace: 'search', + name: 'search', inputs: { items: createExtensionInput([searchResultListItemDataRef]), }, From 538972e19eb451e5cce402fa2c07ffb1b4b65916 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 3 Sep 2024 10:19:04 +0200 Subject: [PATCH 08/12] chore: fix namespace snapshot Signed-off-by: blam --- packages/frontend-defaults/src/createApp.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/frontend-defaults/src/createApp.test.tsx b/packages/frontend-defaults/src/createApp.test.tsx index 1954554816..2890700653 100644 --- a/packages/frontend-defaults/src/createApp.test.tsx +++ b/packages/frontend-defaults/src/createApp.test.tsx @@ -284,9 +284,9 @@ describe('createApp', () => { components [ - - - + + + ] From 40b8a7a280f9361b078a66c9b8b562eeef8a5a0b Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 3 Sep 2024 12:02:17 +0200 Subject: [PATCH 09/12] chore: should be wrapped up in a plugin instead of a module Signed-off-by: blam --- .../src/blueprints/SignInPageBlueprint.test.tsx | 1 - packages/frontend-test-utils/src/app/renderInTestApp.tsx | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx index 2637873930..a85b5e6f39 100644 --- a/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/SignInPageBlueprint.test.tsx @@ -57,7 +57,6 @@ describe('SignInPageBlueprint', () => { const MockSignInPage = () =>
; const extension = SignInPageBlueprint.make({ - name: 'test', params: { loader: async () => () => }, }); diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index 80897e942a..e53566a118 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -32,7 +32,7 @@ import { IconComponent, RouterBlueprint, NavItemBlueprint, - createExtensionOverrides, + createFrontendPlugin, } from '@backstage/frontend-plugin-api'; import appPlugin from '@backstage/plugin-app'; @@ -136,7 +136,6 @@ export function renderInTestApp( ): RenderResult { const extensions: Array = [ 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 }) => {children}, }, @@ -182,7 +180,8 @@ export function renderInTestApp( } const features: FrontendFeature[] = [ - createExtensionOverrides({ + createFrontendPlugin({ + id: 'test', extensions, }), appPluginOverride, From 5cbb4c6fd10ca656bc20779960590ee5f0b555a3 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 3 Sep 2024 13:16:14 +0200 Subject: [PATCH 10/12] chore: fix remaining tests Signed-off-by: blam --- .../core-compat-api/src/compatWrapper/compatWrapper.test.tsx | 2 +- .../src/blueprints/AppRootWrapperBlueprint.test.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx index bee379a792..fe4770a08c 100644 --- a/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx +++ b/packages/core-compat-api/src/compatWrapper/compatWrapper.test.tsx @@ -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" `); diff --git a/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.test.tsx index cda0085fec..f9214121ce 100644 --- a/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/AppRootWrapperBlueprint.test.tsx @@ -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(), From 948d4319836ebbcc731eff0c3a79213f9af8908e Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 3 Sep 2024 13:19:43 +0200 Subject: [PATCH 11/12] chore: add changeset Signed-off-by: blam --- .changeset/shiny-carpets-worry.md | 9 ++++++++ packages/core-compat-api/api-report.md | 7 +++---- packages/frontend-plugin-api/api-report.md | 2 +- plugins/app/api-report.md | 24 ---------------------- 4 files changed, 13 insertions(+), 29 deletions(-) create mode 100644 .changeset/shiny-carpets-worry.md diff --git a/.changeset/shiny-carpets-worry.md b/.changeset/shiny-carpets-worry.md new file mode 100644 index 0000000000..f1c3bbe292 --- /dev/null +++ b/.changeset/shiny-carpets-worry.md @@ -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 diff --git a/packages/core-compat-api/api-report.md b/packages/core-compat-api/api-report.md index e61ee451d9..aaf840df8c 100644 --- a/packages/core-compat-api/api-report.md +++ b/packages/core-compat-api/api-report.md @@ -9,12 +9,11 @@ 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 +28,7 @@ export function compatWrapper(element: ReactNode): React_2.JSX.Element; // @public (undocumented) export function convertLegacyApp( rootElement: React_2.JSX.Element, -): (FrontendPlugin | ExtensionOverrides)[]; +): (FrontendPlugin | FrontendModule)[]; // @public (undocumented) export function convertLegacyPageExtension( @@ -46,7 +45,7 @@ export function convertLegacyPlugin( options: { extensions: ExtensionDefinition[]; }, -): BackstagePlugin_2; +): FrontendPlugin; // @public export function convertLegacyRouteRef( diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 276ca190a6..75d91d28f0 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -454,7 +454,7 @@ export function createComponentExtension(options: { >; }; kind: 'component'; - namespace: string; + namespace: undefined; name: string; }>; diff --git a/plugins/app/api-report.md b/plugins/app/api-report.md index fbf77debb4..6f2e6e0463 100644 --- a/plugins/app/api-report.md +++ b/plugins/app/api-report.md @@ -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: {}; From 4d39e3b4ae431de662bfbb405bdb151a3471ab03 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 3 Sep 2024 13:55:36 +0200 Subject: [PATCH 12/12] chore: revert small change Signed-off-by: blam --- packages/core-compat-api/api-report.md | 3 ++- packages/core-compat-api/src/convertLegacyApp.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core-compat-api/api-report.md b/packages/core-compat-api/api-report.md index aaf840df8c..ddb3bc6bf4 100644 --- a/packages/core-compat-api/api-report.md +++ b/packages/core-compat-api/api-report.md @@ -11,6 +11,7 @@ import { AnyRouteRefParams } from '@backstage/core-plugin-api'; import { BackstagePlugin } from '@backstage/core-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'; @@ -28,7 +29,7 @@ export function compatWrapper(element: ReactNode): React_2.JSX.Element; // @public (undocumented) export function convertLegacyApp( rootElement: React_2.JSX.Element, -): (FrontendPlugin | FrontendModule)[]; +): (FrontendPlugin | FrontendModule | ExtensionOverrides)[]; // @public (undocumented) export function convertLegacyPageExtension( diff --git a/packages/core-compat-api/src/convertLegacyApp.ts b/packages/core-compat-api/src/convertLegacyApp.ts index 610c9e8842..3f35c78408 100644 --- a/packages/core-compat-api/src/convertLegacyApp.ts +++ b/packages/core-compat-api/src/convertLegacyApp.ts @@ -26,6 +26,7 @@ import { FrontendPlugin, coreExtensionData, createExtension, + ExtensionOverrides, createExtensionInput, createFrontendModule, } from '@backstage/frontend-plugin-api'; @@ -61,7 +62,7 @@ function selectChildren( /** @public */ export function convertLegacyApp( rootElement: React.JSX.Element, -): (FrontendPlugin | FrontendModule)[] { +): (FrontendPlugin | FrontendModule | ExtensionOverrides)[] { if (getComponentData(rootElement, 'core.type') === 'FlatRoutes') { return collectLegacyRoutes(rootElement); }