updates to use createExtensionInput
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -17,17 +17,16 @@
|
||||
import {
|
||||
coreExtensionData,
|
||||
createExtension,
|
||||
createExtensionInput,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
|
||||
export const Core = createExtension({
|
||||
id: 'core',
|
||||
at: 'root',
|
||||
inputs: {
|
||||
apis: {
|
||||
extensionData: {
|
||||
api: coreExtensionData.apiFactory,
|
||||
},
|
||||
},
|
||||
apis: createExtensionInput({
|
||||
api: coreExtensionData.apiFactory,
|
||||
}),
|
||||
},
|
||||
output: {},
|
||||
factory() {},
|
||||
|
||||
@@ -18,6 +18,7 @@ import React from 'react';
|
||||
import {
|
||||
createExtension,
|
||||
coreExtensionData,
|
||||
createExtensionInput,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
import { SidebarPage } from '@backstage/core-components';
|
||||
|
||||
@@ -25,39 +26,28 @@ export const CoreLayout = createExtension({
|
||||
id: 'core.layout',
|
||||
at: 'root',
|
||||
inputs: {
|
||||
nav: {
|
||||
extensionData: {
|
||||
nav: createExtensionInput(
|
||||
{
|
||||
element: coreExtensionData.reactElement,
|
||||
},
|
||||
},
|
||||
content: {
|
||||
extensionData: {
|
||||
{ singleton: true },
|
||||
),
|
||||
content: createExtensionInput(
|
||||
{
|
||||
element: coreExtensionData.reactElement,
|
||||
},
|
||||
},
|
||||
{ singleton: true },
|
||||
),
|
||||
},
|
||||
output: {
|
||||
element: coreExtensionData.reactElement,
|
||||
},
|
||||
factory({ bind, inputs }) {
|
||||
// TODO: Support this as part of the core system
|
||||
if (inputs.nav.length !== 1) {
|
||||
throw Error(
|
||||
`Extension 'core.layout' did not receive exactly one 'nav' input, got ${inputs.nav.length}`,
|
||||
);
|
||||
}
|
||||
if (inputs.content.length !== 1) {
|
||||
throw Error(
|
||||
`Extension 'core.layout' did not receive exactly one 'content' input, got ${inputs.content.length}`,
|
||||
);
|
||||
}
|
||||
|
||||
bind({
|
||||
// TODO: set base path using the logic from AppRouter
|
||||
element: (
|
||||
<SidebarPage>
|
||||
{inputs.nav[0].element}
|
||||
{inputs.content[0].element}
|
||||
{inputs.nav.element}
|
||||
{inputs.content.element}
|
||||
</SidebarPage>
|
||||
),
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ import React from 'react';
|
||||
import {
|
||||
createExtension,
|
||||
coreExtensionData,
|
||||
createExtensionInput,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
import { useRoutes } from 'react-router-dom';
|
||||
|
||||
@@ -25,13 +26,11 @@ export const CoreRoutes = createExtension({
|
||||
id: 'core.routes',
|
||||
at: 'core.layout/content',
|
||||
inputs: {
|
||||
routes: {
|
||||
extensionData: {
|
||||
path: coreExtensionData.routePath,
|
||||
ref: coreExtensionData.routeRef,
|
||||
element: coreExtensionData.reactElement,
|
||||
},
|
||||
},
|
||||
routes: createExtensionInput({
|
||||
path: coreExtensionData.routePath,
|
||||
ref: coreExtensionData.routeRef,
|
||||
element: coreExtensionData.reactElement,
|
||||
}),
|
||||
},
|
||||
output: {
|
||||
element: coreExtensionData.reactElement,
|
||||
|
||||
Reference in New Issue
Block a user