From cc2ee1d05fe9d450a6fa5fa960c89c972657e77d Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 15 Aug 2024 09:00:09 +0200 Subject: [PATCH] chore: fix deprecations in app-next Signed-off-by: blam --- packages/app-next/src/App.tsx | 35 +++-- .../app-next/src/examples/pagesPlugin.tsx | 142 +++++++++--------- .../app-next/src/overrides/SignInPage.tsx | 9 +- 3 files changed, 101 insertions(+), 85 deletions(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index b57c680474..c41f33e01b 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -26,8 +26,8 @@ import homePlugin, { import { coreExtensionData, createExtension, - createApiExtension, createExtensionOverrides, + ApiBlueprint, } from '@backstage/frontend-plugin-api'; import techdocsPlugin from '@backstage/plugin-techdocs/alpha'; import appVisualizerPlugin from '@backstage/plugin-app-visualizer'; @@ -40,6 +40,7 @@ import { createApiFactory, configApiRef } from '@backstage/core-plugin-api'; import { ScmAuth, ScmIntegrationsApi, + scmAuthApiRef, scmIntegrationsApiRef, } from '@backstage/integration-react'; import kubernetesPlugin from '@backstage/plugin-kubernetes/alpha'; @@ -77,25 +78,31 @@ TODO: const homePageExtension = createExtension({ name: 'myhomepage', attachTo: { id: 'page:home', input: 'props' }, - output: { - children: coreExtensionData.reactElement, - title: titleExtensionDataRef, - }, + output: [coreExtensionData.reactElement, titleExtensionDataRef], factory() { - return { children: homePage, title: 'just a title' }; + return [ + coreExtensionData.reactElement(homePage), + titleExtensionDataRef('just a title'), + ]; }, }); -const scmAuthExtension = createApiExtension({ - factory: ScmAuth.createDefaultApiFactory(), +const scmAuthExtension = ApiBlueprint.make({ + namespace: scmAuthApiRef.id, + params: { + factory: ScmAuth.createDefaultApiFactory(), + }, }); -const scmIntegrationApi = createApiExtension({ - factory: createApiFactory({ - api: scmIntegrationsApiRef, - deps: { configApi: configApiRef }, - factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi), - }), +const scmIntegrationApi = ApiBlueprint.make({ + namespace: scmIntegrationsApiRef.id, + params: { + factory: createApiFactory({ + api: scmIntegrationsApiRef, + deps: { configApi: configApiRef }, + factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi), + }), + }, }); const collectedLegacyPlugins = convertLegacyApp( diff --git a/packages/app-next/src/examples/pagesPlugin.tsx b/packages/app-next/src/examples/pagesPlugin.tsx index 2b9907dd59..8eca7d1e6c 100644 --- a/packages/app-next/src/examples/pagesPlugin.tsx +++ b/packages/app-next/src/examples/pagesPlugin.tsx @@ -17,11 +17,11 @@ import React from 'react'; import { Link } from '@backstage/core-components'; import { - createPageExtension, createFrontendPlugin, createRouteRef, createExternalRouteRef, useRouteRef, + PageBlueprint, } from '@backstage/frontend-plugin-api'; import { Route, Routes } from 'react-router-dom'; @@ -37,91 +37,97 @@ export const pageXRouteRef = createRouteRef(); // path: '/page2', // }); -const IndexPage = createPageExtension({ +const IndexPage = PageBlueprint.make({ name: 'index', - defaultPath: '/', - routeRef: indexRouteRef, - loader: async () => { - const Component = () => { - const page1Link = useRouteRef(page1RouteRef); - return ( -
- op - {page1Link && ( + params: { + defaultPath: '/', + routeRef: indexRouteRef, + loader: async () => { + const Component = () => { + const page1Link = useRouteRef(page1RouteRef); + return ( +
+ op + {page1Link && ( +
+ Page 1 +
+ )}
- Page 1 + Home +
+
+ GraphiQL +
+
+ Search +
+
+ Settings
- )} -
- Home
-
- GraphiQL -
-
- Search -
-
- Settings -
-
- ); - }; - return ; + ); + }; + return ; + }, }, }); -const Page1 = createPageExtension({ +const Page1 = PageBlueprint.make({ name: 'page1', - defaultPath: '/page1', - routeRef: page1RouteRef, - loader: async () => { - const Component = () => { - const indexLink = useRouteRef(indexRouteRef); - const xLink = useRouteRef(externalPageXRouteRef); - // const page2Link = useRouteRef(page2RouteRef); - - return ( -
-

This is page 1

- {indexLink && Go back} - Page 2 - {/* Page 2 */} - {xLink && Page X} + params: { + defaultPath: '/page1', + routeRef: page1RouteRef, + loader: async () => { + const Component = () => { + const indexLink = useRouteRef(indexRouteRef); + const xLink = useRouteRef(externalPageXRouteRef); + // const page2Link = useRouteRef(page2RouteRef); + return (
- Sub-page content: +

This is page 1

+ {indexLink && Go back} + Page 2 + {/* Page 2 */} + {xLink && Page X} +
- - This is also page 1} /> - This is page 2} /> - + Sub-page content: +
+ + This is also page 1} /> + This is page 2} /> + +
-
- ); - }; - return ; + ); + }; + return ; + }, }, }); -const ExternalPage = createPageExtension({ +const ExternalPage = PageBlueprint.make({ name: 'pageX', - defaultPath: '/pageX', - routeRef: pageXRouteRef, - loader: async () => { - const Component = () => { - const indexLink = useRouteRef(indexRouteRef); - // const pageXLink = useRouteRef(pageXRouteRef); + params: { + defaultPath: '/pageX', + routeRef: pageXRouteRef, + loader: async () => { + const Component = () => { + const indexLink = useRouteRef(indexRouteRef); + // const pageXLink = useRouteRef(pageXRouteRef); - return ( -
-

This is page X

- {indexLink && Go back} -
- ); - }; - return ; + return ( +
+

This is page X

+ {indexLink && Go back} +
+ ); + }; + return ; + }, }, }); diff --git a/packages/app-next/src/overrides/SignInPage.tsx b/packages/app-next/src/overrides/SignInPage.tsx index 364a749293..52dd01fcde 100644 --- a/packages/app-next/src/overrides/SignInPage.tsx +++ b/packages/app-next/src/overrides/SignInPage.tsx @@ -17,13 +17,16 @@ import React from 'react'; import { SignInPage } from '@backstage/core-components'; import { + SignInPageBlueprint, createExtensionOverrides, - createSignInPageExtension, } from '@backstage/frontend-plugin-api'; -const signInPage = createSignInPageExtension({ +const signInPage = SignInPageBlueprint.make({ name: 'guest', - loader: async () => props => , + params: { + loader: async () => props => + , + }, }); export const signInPageOverrides = createExtensionOverrides({