core-compat-api: updates for extension ID refactor
Co-authored-by: Camila Belo <camilaibs@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/core-compat-api': patch
|
||||
---
|
||||
|
||||
Updates for compatibility with the new extension IDs.
|
||||
@@ -51,13 +51,13 @@ describe('collectLegacyRoutes', () => {
|
||||
id: 'score-card',
|
||||
extensions: [
|
||||
{
|
||||
id: 'plugin.score-card.page',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:score-card',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'score-board' },
|
||||
},
|
||||
{
|
||||
id: 'apis.plugin.scoringdata.service',
|
||||
id: 'api:score-card',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
},
|
||||
@@ -67,13 +67,13 @@ describe('collectLegacyRoutes', () => {
|
||||
id: 'stackstorm',
|
||||
extensions: [
|
||||
{
|
||||
id: 'plugin.stackstorm.page',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:stackstorm',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'stackstorm' },
|
||||
},
|
||||
{
|
||||
id: 'apis.plugin.stackstorm.service',
|
||||
id: 'api:stackstorm',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
},
|
||||
@@ -83,19 +83,19 @@ describe('collectLegacyRoutes', () => {
|
||||
id: 'puppetDb',
|
||||
extensions: [
|
||||
{
|
||||
id: 'plugin.puppetDb.page',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:puppetDb',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'puppetdb' },
|
||||
},
|
||||
{
|
||||
id: 'plugin.puppetDb.page2',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:puppetDb/2',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'puppetdb' },
|
||||
},
|
||||
{
|
||||
id: 'apis.plugin.puppetdb.service',
|
||||
id: 'api:puppetDb',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
},
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
import React, { ReactNode } from 'react';
|
||||
import {
|
||||
Extension,
|
||||
createApiExtension,
|
||||
createPageExtension,
|
||||
createPlugin,
|
||||
BackstagePlugin,
|
||||
ExtensionDefinition,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
import { Route, Routes } from 'react-router-dom';
|
||||
import {
|
||||
@@ -64,7 +64,7 @@ export function collectLegacyRoutes(
|
||||
): BackstagePlugin[] {
|
||||
const createdPluginIds = new Map<
|
||||
LegacyBackstagePlugin,
|
||||
Extension<unknown>[]
|
||||
ExtensionDefinition<unknown>[]
|
||||
>();
|
||||
|
||||
React.Children.forEach(
|
||||
@@ -95,19 +95,18 @@ export function collectLegacyRoutes(
|
||||
'core.mountPoint',
|
||||
);
|
||||
|
||||
const pluginId = plugin.getId();
|
||||
|
||||
const detectedExtensions =
|
||||
createdPluginIds.get(plugin) ?? new Array<Extension<unknown>>();
|
||||
createdPluginIds.get(plugin) ??
|
||||
new Array<ExtensionDefinition<unknown>>();
|
||||
createdPluginIds.set(plugin, detectedExtensions);
|
||||
|
||||
const path: string = route.props.path;
|
||||
|
||||
detectedExtensions.push(
|
||||
createPageExtension({
|
||||
id: `plugin.${pluginId}.page${
|
||||
detectedExtensions.length ? detectedExtensions.length + 1 : ''
|
||||
}`,
|
||||
name: detectedExtensions.length
|
||||
? String(detectedExtensions.length + 1)
|
||||
: undefined,
|
||||
defaultPath: path[0] === '/' ? path.slice(1) : path,
|
||||
routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined,
|
||||
|
||||
@@ -131,9 +130,10 @@ export function collectLegacyRoutes(
|
||||
id: plugin.getId(),
|
||||
extensions: [
|
||||
...extensions,
|
||||
...Array.from(plugin.getApis()).map(factory =>
|
||||
...Array.from(plugin.getApis()).map((factory, index) =>
|
||||
createApiExtension({
|
||||
factory,
|
||||
name: index > 0 ? String(index + 1) : undefined,
|
||||
}),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -59,13 +59,13 @@ describe('convertLegacyApp', () => {
|
||||
id: 'score-card',
|
||||
extensions: [
|
||||
{
|
||||
id: 'plugin.score-card.page',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:score-card',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'score-board' },
|
||||
},
|
||||
{
|
||||
id: 'apis.plugin.scoringdata.service',
|
||||
id: 'api:score-card',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
},
|
||||
@@ -75,13 +75,13 @@ describe('convertLegacyApp', () => {
|
||||
id: 'stackstorm',
|
||||
extensions: [
|
||||
{
|
||||
id: 'plugin.stackstorm.page',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:stackstorm',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'stackstorm' },
|
||||
},
|
||||
{
|
||||
id: 'apis.plugin.stackstorm.service',
|
||||
id: 'api:stackstorm',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
},
|
||||
@@ -91,19 +91,19 @@ describe('convertLegacyApp', () => {
|
||||
id: 'puppetDb',
|
||||
extensions: [
|
||||
{
|
||||
id: 'plugin.puppetDb.page',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:puppetDb',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'puppetdb' },
|
||||
},
|
||||
{
|
||||
id: 'plugin.puppetDb.page2',
|
||||
attachTo: { id: 'core.routes', input: 'routes' },
|
||||
id: 'page:puppetDb/2',
|
||||
attachTo: { id: 'core/routes', input: 'routes' },
|
||||
disabled: false,
|
||||
defaultConfig: { path: 'puppetdb' },
|
||||
},
|
||||
{
|
||||
id: 'apis.plugin.puppetdb.service',
|
||||
id: 'api:puppetDb',
|
||||
attachTo: { id: 'core', input: 'apis' },
|
||||
disabled: false,
|
||||
},
|
||||
@@ -113,13 +113,13 @@ describe('convertLegacyApp', () => {
|
||||
id: undefined,
|
||||
extensions: [
|
||||
{
|
||||
id: 'core.layout',
|
||||
id: 'core/layout',
|
||||
attachTo: { id: 'core', input: 'root' },
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
id: 'core.nav',
|
||||
attachTo: { id: 'core.layout', input: 'nav' },
|
||||
id: 'core/nav',
|
||||
attachTo: { id: 'core/layout', input: 'nav' },
|
||||
disabled: true,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -100,7 +100,8 @@ export function convertLegacyApp(
|
||||
const [routesEl] = routesEls;
|
||||
|
||||
const CoreLayoutOverride = createExtension({
|
||||
id: 'core.layout',
|
||||
namespace: 'core',
|
||||
name: 'layout',
|
||||
attachTo: { id: 'core', input: 'root' },
|
||||
inputs: {
|
||||
content: createExtensionInput(
|
||||
@@ -121,8 +122,9 @@ export function convertLegacyApp(
|
||||
},
|
||||
});
|
||||
const CoreNavOverride = createExtension({
|
||||
id: 'core.nav',
|
||||
attachTo: { id: 'core.layout', input: 'nav' },
|
||||
namespace: 'core',
|
||||
name: 'nav',
|
||||
attachTo: { id: 'core/layout', input: 'nav' },
|
||||
output: {},
|
||||
factory: () => ({}),
|
||||
disabled: true,
|
||||
|
||||
Reference in New Issue
Block a user