feat: use collect legacy routes in app-next
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
committed by
Patrik Oldsberg
parent
8462548e8f
commit
4830d0df02
@@ -12,6 +12,7 @@
|
||||
"@backstage/cli": "workspace:^",
|
||||
"@backstage/config": "workspace:^",
|
||||
"@backstage/core-app-api": "workspace:^",
|
||||
"@backstage/core-compat-api": "workspace:^",
|
||||
"@backstage/core-components": "workspace:^",
|
||||
"@backstage/core-plugin-api": "workspace:^",
|
||||
"@backstage/frontend-app-api": "workspace:^",
|
||||
|
||||
@@ -27,6 +27,7 @@ import homePlugin, {
|
||||
import {
|
||||
coreExtensionData,
|
||||
createExtension,
|
||||
createApiExtension,
|
||||
createExtensionOverrides,
|
||||
createPageExtension,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
@@ -34,6 +35,16 @@ import { entityRouteRef } from '@backstage/plugin-catalog-react';
|
||||
import techdocsPlugin from '@backstage/plugin-techdocs/alpha';
|
||||
import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha';
|
||||
import { homePage } from './HomePage';
|
||||
import { collectLegacyRoutes } from '@backstage/core-compat-api';
|
||||
import { FlatRoutes } from '@backstage/core-app-api';
|
||||
import { Route } from 'react-router';
|
||||
import { CatalogImportPage } from '@backstage/plugin-catalog-import';
|
||||
import { createApiFactory, configApiRef } from '@backstage/core-plugin-api';
|
||||
import {
|
||||
ScmAuth,
|
||||
ScmIntegrationsApi,
|
||||
scmIntegrationsApiRef,
|
||||
} from '@backstage/integration-react';
|
||||
|
||||
/*
|
||||
|
||||
@@ -83,6 +94,24 @@ const homePageExtension = createExtension({
|
||||
},
|
||||
});
|
||||
|
||||
const scmAuthExtension = createApiExtension({
|
||||
factory: ScmAuth.createDefaultApiFactory(),
|
||||
});
|
||||
|
||||
const scmIntegrationApi = createApiExtension({
|
||||
factory: createApiFactory({
|
||||
api: scmIntegrationsApiRef,
|
||||
deps: { configApi: configApiRef },
|
||||
factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi),
|
||||
}),
|
||||
});
|
||||
|
||||
const collectedLegacyRoutes = collectLegacyRoutes(
|
||||
<FlatRoutes>
|
||||
<Route path="/catalog-import" element={<CatalogImportPage />} />
|
||||
</FlatRoutes>,
|
||||
);
|
||||
|
||||
const app = createApp({
|
||||
features: [
|
||||
graphiqlPlugin,
|
||||
@@ -92,7 +121,13 @@ const app = createApp({
|
||||
userSettingsPlugin,
|
||||
homePlugin,
|
||||
createExtensionOverrides({
|
||||
extensions: [entityPageExtension, homePageExtension],
|
||||
extensions: [
|
||||
entityPageExtension,
|
||||
homePageExtension,
|
||||
scmAuthExtension,
|
||||
scmIntegrationApi,
|
||||
...collectedLegacyRoutes,
|
||||
],
|
||||
}),
|
||||
],
|
||||
/* Handled through config instead */
|
||||
|
||||
@@ -15,13 +15,18 @@
|
||||
*/
|
||||
|
||||
import React, { ReactNode } from 'react';
|
||||
import { Extension, createPageExtension } from '@backstage/frontend-plugin-api';
|
||||
import {
|
||||
Extension,
|
||||
createApiExtension,
|
||||
createPageExtension,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
import { Route, Routes } from 'react-router-dom';
|
||||
import {
|
||||
BackstagePlugin,
|
||||
RouteRef,
|
||||
getComponentData,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha';
|
||||
|
||||
export function collectLegacyRoutes(
|
||||
flatRoutesElement: JSX.Element,
|
||||
@@ -77,7 +82,7 @@ export function collectLegacyRoutes(
|
||||
const detectedExtension = createPageExtension({
|
||||
id: `plugin.${pluginId}.page`,
|
||||
defaultPath: path[0] === '/' ? path.slice(1) : path,
|
||||
routeRef,
|
||||
routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined,
|
||||
|
||||
loader: async () =>
|
||||
route.props.children ? (
|
||||
@@ -91,7 +96,13 @@ export function collectLegacyRoutes(
|
||||
),
|
||||
});
|
||||
|
||||
plugin.getApis(); // Create DI API extensions from these
|
||||
results.push(
|
||||
...Array.from(plugin.getApis()).map(factory =>
|
||||
createApiExtension({
|
||||
factory,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
// TODO: Create converted plugin instance instead. We need to move over APIs etc.
|
||||
results.push(detectedExtension);
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
export { collectLegacyRoutes } from './collectLegacyRoutes';
|
||||
|
||||
@@ -3952,7 +3952,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/core-compat-api@workspace:packages/core-compat-api":
|
||||
"@backstage/core-compat-api@workspace:^, @backstage/core-compat-api@workspace:packages/core-compat-api":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/core-compat-api@workspace:packages/core-compat-api"
|
||||
dependencies:
|
||||
@@ -25274,6 +25274,7 @@ __metadata:
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/config": "workspace:^"
|
||||
"@backstage/core-app-api": "workspace:^"
|
||||
"@backstage/core-compat-api": "workspace:^"
|
||||
"@backstage/core-components": "workspace:^"
|
||||
"@backstage/core-plugin-api": "workspace:^"
|
||||
"@backstage/frontend-app-api": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user