From a68ee8561f5d9a8f5ba9c1799d8d03ba4d8f51bf Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 28 Nov 2023 13:59:03 +0100 Subject: [PATCH] frontend-plugin-api: update createComponentExtension for new naming pattern Signed-off-by: Patrik Oldsberg --- packages/core-compat-api/api-report.md | 4 ++-- .../src/collectLegacyComponents.test.tsx | 15 ++++++++++----- .../src/collectLegacyComponents.tsx | 4 ++-- .../src/wiring/createApp.test.tsx | 8 ++++---- packages/frontend-plugin-api/api-report.md | 3 ++- .../src/extensions/createComponentExtension.tsx | 6 ++++-- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/core-compat-api/api-report.md b/packages/core-compat-api/api-report.md index 866517b5c8..93a2fa8cf1 100644 --- a/packages/core-compat-api/api-report.md +++ b/packages/core-compat-api/api-report.md @@ -8,7 +8,7 @@ import { AnyRouteRefParams } from '@backstage/core-plugin-api'; import { AppComponents } from '@backstage/core-plugin-api'; import { BackstagePlugin } from '@backstage/frontend-plugin-api'; -import { Extension } from '@backstage/frontend-plugin-api'; +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'; @@ -21,7 +21,7 @@ import { SubRouteRef as SubRouteRef_2 } from '@backstage/frontend-plugin-api'; // @public (undocumented) export function collectLegacyComponents( components: Partial, -): Extension[]; +): ExtensionDefinition[]; // @public (undocumented) export function collectLegacyRoutes( diff --git a/packages/core-compat-api/src/collectLegacyComponents.test.tsx b/packages/core-compat-api/src/collectLegacyComponents.test.tsx index 0600f58cf8..7ca11a777e 100644 --- a/packages/core-compat-api/src/collectLegacyComponents.test.tsx +++ b/packages/core-compat-api/src/collectLegacyComponents.test.tsx @@ -31,28 +31,33 @@ describe('collectLegacyComponents', () => { expect( collected.map(p => ({ - id: p.id, + kind: p.kind, + namespace: p.namespace, attachTo: p.attachTo, disabled: p.disabled, })), ).toEqual([ { - id: 'core.components.progress', + kind: 'component', + namespace: 'core.components.progress', attachTo: { id: 'core', input: 'components' }, disabled: false, }, { - id: 'core.components.bootErrorPage', + kind: 'component', + namespace: 'core.components.bootErrorPage', attachTo: { id: 'core', input: 'components' }, disabled: false, }, { - id: 'core.components.notFoundErrorPage', + kind: 'component', + namespace: 'core.components.notFoundErrorPage', attachTo: { id: 'core', input: 'components' }, disabled: false, }, { - id: 'core.components.errorBoundaryFallback', + kind: 'component', + namespace: 'core.components.errorBoundaryFallback', attachTo: { id: 'core', input: 'components' }, disabled: false, }, diff --git a/packages/core-compat-api/src/collectLegacyComponents.tsx b/packages/core-compat-api/src/collectLegacyComponents.tsx index 6092ca1be7..6ae6df7cff 100644 --- a/packages/core-compat-api/src/collectLegacyComponents.tsx +++ b/packages/core-compat-api/src/collectLegacyComponents.tsx @@ -15,10 +15,10 @@ */ import { - Extension, ComponentRef, createComponentExtension, coreComponentsRefs, + ExtensionDefinition, } from '@backstage/frontend-plugin-api'; import { AppComponents } from '@backstage/core-plugin-api'; @@ -33,7 +33,7 @@ const refs: Record> = { /** @public */ export function collectLegacyComponents(components: Partial) { - return Object.entries(components).reduce[]>( + return Object.entries(components).reduce[]>( (extensions, [name, component]) => { const ref = refs[name]; return ref diff --git a/packages/frontend-app-api/src/wiring/createApp.test.tsx b/packages/frontend-app-api/src/wiring/createApp.test.tsx index 348b56b5fd..2713a9743e 100644 --- a/packages/frontend-app-api/src/wiring/createApp.test.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.test.tsx @@ -201,10 +201,10 @@ describe('createApp', () => { ] components [ - - - - + + + + ] themes [ diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 65c865b352..c491579eaf 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -405,6 +405,7 @@ export function createComponentExtension< TInputs extends AnyExtensionInputMap, >(options: { ref: TRef; + name?: string; disabled?: boolean; inputs?: TInputs; configSchema?: PortableSchema; @@ -421,7 +422,7 @@ export function createComponentExtension< inputs: Expand>; }) => TRef['T']; }; -}): Extension; +}): ExtensionDefinition; // @public (undocumented) export function createExtension< diff --git a/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx b/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx index a20faa0b3a..c9780574b6 100644 --- a/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx +++ b/packages/frontend-plugin-api/src/extensions/createComponentExtension.tsx @@ -32,6 +32,7 @@ export function createComponentExtension< TInputs extends AnyExtensionInputMap, >(options: { ref: TRef; + name?: string; disabled?: boolean; inputs?: TInputs; configSchema?: PortableSchema; @@ -49,9 +50,10 @@ export function createComponentExtension< }) => TRef['T']; }; }) { - const id = options.ref.id; return createExtension({ - id, + kind: 'component', + namespace: options.ref.id, + name: options.name, attachTo: { id: 'core', input: 'components' }, inputs: options.inputs, disabled: options.disabled,