From 3a6e5fcbdd08fd72f57eb79c1e29752139e5b72d Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 2 Oct 2023 22:38:37 +0200 Subject: [PATCH 01/18] user-settings: add new backend system support Signed-off-by: Vincenzo Scamporlino --- plugins/user-settings/package.json | 5 ++-- .../user-settings/src/{alpha.ts => alpha.tsx} | 25 +++++++++++++++++++ yarn.lock | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) rename plugins/user-settings/src/{alpha.ts => alpha.tsx} (51%) diff --git a/plugins/user-settings/package.json b/plugins/user-settings/package.json index 7afe5b8fc0..399eda0a61 100644 --- a/plugins/user-settings/package.json +++ b/plugins/user-settings/package.json @@ -7,13 +7,13 @@ "license": "Apache-2.0", "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts", + "./alpha": "./src/alpha.tsx", "./package.json": "./package.json" }, "typesVersions": { "*": { "alpha": [ - "src/alpha.ts" + "src/alpha.tsx" ], "package.json": [ "package.json" @@ -50,6 +50,7 @@ "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", + "@backstage/frontend-plugin-api": "workspace:^", "@backstage/plugin-catalog-react": "workspace:^", "@backstage/theme": "workspace:^", "@backstage/types": "workspace:^", diff --git a/plugins/user-settings/src/alpha.ts b/plugins/user-settings/src/alpha.tsx similarity index 51% rename from plugins/user-settings/src/alpha.ts rename to plugins/user-settings/src/alpha.tsx index e1f7678bae..ac753a4138 100644 --- a/plugins/user-settings/src/alpha.ts +++ b/plugins/user-settings/src/alpha.tsx @@ -1,3 +1,9 @@ +import { createRouteRef } from '@backstage/core-plugin-api'; +import { + createPageExtension, + createPlugin, +} from '@backstage/frontend-plugin-api'; + /* * Copyright 2023 The Backstage Authors * @@ -13,4 +19,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import React from 'react'; + export * from './translation'; + +export const userSettingsRouteRef = createRouteRef({ + id: 'plugin.user-settings.page', +}); + +export const UserSettingsPage = createPageExtension({ + id: 'plugin.user-settings.page', + defaultPath: '/settings', + routeRef: userSettingsRouteRef, + loader: () => + import('./components/SettingsPage').then(m => ), +}); + +export default createPlugin({ + id: 'user-settings', + extensions: [UserSettingsPage], +}); diff --git a/yarn.lock b/yarn.lock index 369b6c0356..a4c362a0ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9971,6 +9971,7 @@ __metadata: "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" "@backstage/errors": "workspace:^" + "@backstage/frontend-plugin-api": "workspace:^" "@backstage/plugin-catalog": "workspace:^" "@backstage/plugin-catalog-react": "workspace:^" "@backstage/test-utils": "workspace:^" From 16bd91c65e7cdef05579bbc5cfb6fa4754fee668 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 2 Oct 2023 22:39:59 +0200 Subject: [PATCH 02/18] core-app-api: expose appTheme and some translation stuff Signed-off-by: Vincenzo Scamporlino --- packages/core-app-api/package.json | 4 ++++ packages/core-app-api/src/alpha.ts | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 packages/core-app-api/src/alpha.ts diff --git a/packages/core-app-api/package.json b/packages/core-app-api/package.json index e3332998df..c7b00c9c57 100644 --- a/packages/core-app-api/package.json +++ b/packages/core-app-api/package.json @@ -7,10 +7,14 @@ }, "exports": { ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", "./package.json": "./package.json" }, "typesVersions": { "*": { + "alpha": [ + "src/alpha.ts" + ], "package.json": [ "package.json" ] diff --git a/packages/core-app-api/src/alpha.ts b/packages/core-app-api/src/alpha.ts new file mode 100644 index 0000000000..286f3aa242 --- /dev/null +++ b/packages/core-app-api/src/alpha.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AppThemeSelector } from './apis'; +import { AppLanguageSelector } from './apis/implementations/AppLanguageApi'; +import { I18nextTranslationApi } from './apis/implementations/TranslationApi'; + +export { AppLanguageSelector, AppThemeSelector, I18nextTranslationApi }; From d7f8ea9e9285d8801c139ff8d93a2a3226654369 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 2 Oct 2023 22:40:49 +0200 Subject: [PATCH 03/18] frontend-app-api: register appLanguageApi and translationApi Signed-off-by: Vincenzo Scamporlino --- .../frontend-app-api/src/wiring/createApp.tsx | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/frontend-app-api/src/wiring/createApp.tsx b/packages/frontend-app-api/src/wiring/createApp.tsx index 873e774ad8..f37d05ec6f 100644 --- a/packages/frontend-app-api/src/wiring/createApp.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.tsx @@ -57,9 +57,14 @@ import { ApiFactoryRegistry, ApiProvider, ApiResolver, - AppThemeSelector, } from '@backstage/core-app-api'; +import { + AppLanguageSelector, + AppThemeSelector, + I18nextTranslationApi, +} from '@backstage/core-app-api/alpha'; + // TODO: Get rid of all of these // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { AppThemeProvider } from '../../../core-app-api/src/app/AppThemeProvider'; @@ -86,6 +91,10 @@ import { SidebarItem } from '@backstage/core-components'; import { DarkTheme, LightTheme } from '../extensions/themes'; import { extractRouteInfoFromInstanceTree } from '../routing/extractRouteInfoFromInstanceTree'; import { getOrCreateGlobalSingleton } from '@backstage/version-bridge'; +import { + appLanguageApiRef, + translationApiRef, +} from '@backstage/core-plugin-api/alpha'; /** @public */ export interface ExtensionTreeNode { @@ -474,6 +483,21 @@ function createApiHolder( factory: () => configApi, }); + factoryRegistry.register('static', { + api: appLanguageApiRef, + deps: {}, + factory: () => AppLanguageSelector.createWithStorage(), + }); + + factoryRegistry.register('default', { + api: translationApiRef, + deps: { languageApi: appLanguageApiRef }, + factory: ({ languageApi }) => + I18nextTranslationApi.create({ + languageApi, + }), + }); + // TODO: ship these as default extensions instead for (const factory of defaultApis as AnyApiFactory[]) { if (!factoryRegistry.register('app', factory)) { From f69dd1874984fa66afcac7c2dc29aaf5ca4ff89e Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 2 Oct 2023 22:41:27 +0200 Subject: [PATCH 04/18] app-next: render some user-settings stuff Signed-off-by: Vincenzo Scamporlino --- packages/app-next/src/App.tsx | 3 ++- packages/app-next/src/examples/pagesPlugin.tsx | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index 01353feb4f..96a4de80eb 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -18,6 +18,7 @@ import { createApp } from '@backstage/frontend-app-api'; import { pagesPlugin } from './examples/pagesPlugin'; import graphiqlPlugin from '@backstage/plugin-graphiql/alpha'; import techRadarPlugin from '@backstage/plugin-tech-radar/alpha'; +import userSettingsPlugin from '@backstage/plugin-user-settings/alpha'; /* @@ -49,7 +50,7 @@ TODO: /* app.tsx */ const app = createApp({ - features: [graphiqlPlugin, pagesPlugin, techRadarPlugin], + features: [graphiqlPlugin, pagesPlugin, techRadarPlugin, userSettingsPlugin], // bindRoutes({ bind }) { // bind(catalogPlugin.externalRoutes, { // createComponent: scaffolderPlugin.routes.root, diff --git a/packages/app-next/src/examples/pagesPlugin.tsx b/packages/app-next/src/examples/pagesPlugin.tsx index 1ec1cfa5a1..361691a9a8 100644 --- a/packages/app-next/src/examples/pagesPlugin.tsx +++ b/packages/app-next/src/examples/pagesPlugin.tsx @@ -50,6 +50,9 @@ const IndexPage = createPageExtension({
Search
+
+ Settings +
); }; From 0b38419cf60dbfe101b56d45aa7170929be91785 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 2 Oct 2023 22:43:31 +0200 Subject: [PATCH 05/18] catalog-react: temporarily disable some routing checks Signed-off-by: Vincenzo Scamporlino --- .../src/components/EntityRefLink/EntityRefLink.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx index d682abdc2b..47031b669c 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx @@ -47,7 +47,13 @@ export type EntityRefLinkProps = { export const EntityRefLink = forwardRef( (props, ref) => { const { entityRef, defaultKind, title, children, ...linkProps } = props; - const entityRoute = useRouteRef(entityRouteRef); + let entityRoute = () => ''; + try { + // eslint-disable-next-line react-hooks/rules-of-hooks + entityRoute = useRouteRef(entityRouteRef); + } catch (e) { + /* */ + } let kind; let namespace; From 25d849affd79b6b237b1f29f1d03aafe48c85159 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 5 Oct 2023 22:24:19 +0200 Subject: [PATCH 06/18] Revert "catalog-react: temporarily disable some routing checks" This reverts commit a5000bf9cf235f35689f50aeaaa5f92fa458fe5f. Signed-off-by: Vincenzo Scamporlino --- .../src/components/EntityRefLink/EntityRefLink.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx index 47031b669c..d682abdc2b 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx @@ -47,13 +47,7 @@ export type EntityRefLinkProps = { export const EntityRefLink = forwardRef( (props, ref) => { const { entityRef, defaultKind, title, children, ...linkProps } = props; - let entityRoute = () => ''; - try { - // eslint-disable-next-line react-hooks/rules-of-hooks - entityRoute = useRouteRef(entityRouteRef); - } catch (e) { - /* */ - } + const entityRoute = useRouteRef(entityRouteRef); let kind; let namespace; From 8fcdb32dbf8808ae8bb03485f9f1af1d302e914b Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 5 Oct 2023 22:42:59 +0200 Subject: [PATCH 07/18] app-next: hook up fake entityRoute Signed-off-by: Vincenzo Scamporlino --- packages/app-next/src/App.tsx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index 96a4de80eb..65d729bf92 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -14,11 +14,17 @@ * limitations under the License. */ +import React from 'react'; import { createApp } from '@backstage/frontend-app-api'; import { pagesPlugin } from './examples/pagesPlugin'; import graphiqlPlugin from '@backstage/plugin-graphiql/alpha'; import techRadarPlugin from '@backstage/plugin-tech-radar/alpha'; import userSettingsPlugin from '@backstage/plugin-user-settings/alpha'; +import { + createPageExtension, + createPlugin, +} from '@backstage/frontend-plugin-api'; +import { entityRouteRef } from '@backstage/plugin-catalog-react'; /* @@ -49,8 +55,26 @@ TODO: /* app.tsx */ +const fakePlugin = createPlugin({ + id: 'fake', + extensions: [ + createPageExtension({ + id: 'catalog:entity', + defaultPath: '/fakeentity', + routeRef: entityRouteRef, + loader: async () =>
hello 😅
, + }), + ], +}); + const app = createApp({ - features: [graphiqlPlugin, pagesPlugin, techRadarPlugin, userSettingsPlugin], + features: [ + graphiqlPlugin, + pagesPlugin, + techRadarPlugin, + userSettingsPlugin, + fakePlugin, + ], // bindRoutes({ bind }) { // bind(catalogPlugin.externalRoutes, { // createComponent: scaffolderPlugin.routes.root, From b69cf95dfda0cae0abdcb734ad596bd3709835c4 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Thu, 5 Oct 2023 23:41:42 +0200 Subject: [PATCH 08/18] user-settings: match subroutes Signed-off-by: Vincenzo Scamporlino --- packages/app-next/src/examples/pagesPlugin.tsx | 2 +- plugins/user-settings/src/alpha.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/app-next/src/examples/pagesPlugin.tsx b/packages/app-next/src/examples/pagesPlugin.tsx index 361691a9a8..5ae1029769 100644 --- a/packages/app-next/src/examples/pagesPlugin.tsx +++ b/packages/app-next/src/examples/pagesPlugin.tsx @@ -51,7 +51,7 @@ const IndexPage = createPageExtension({ Search
- Settings + Settings
); diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index ac753a4138..5ae098184a 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -29,7 +29,7 @@ export const userSettingsRouteRef = createRouteRef({ export const UserSettingsPage = createPageExtension({ id: 'plugin.user-settings.page', - defaultPath: '/settings', + defaultPath: '/settings/*', routeRef: userSettingsRouteRef, loader: () => import('./components/SettingsPage').then(m => ), From d10a39b4b864bc45ae8ab723a6f11685b5b0d18b Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 6 Oct 2023 10:10:13 +0200 Subject: [PATCH 09/18] user-settings: add providerSettings extension data Signed-off-by: Vincenzo Scamporlino --- plugins/user-settings/src/alpha.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index 5ae098184a..7e21ae057f 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -1,5 +1,7 @@ import { createRouteRef } from '@backstage/core-plugin-api'; import { + createExtensionDataRef, + createExtensionInput, createPageExtension, createPlugin, } from '@backstage/frontend-plugin-api'; @@ -27,12 +29,27 @@ export const userSettingsRouteRef = createRouteRef({ id: 'plugin.user-settings.page', }); +export const userSettingsProviderSettingsExtensionData = + createExtensionDataRef( + 'plugin.user-settings.page.providerSettings', + ); + export const UserSettingsPage = createPageExtension({ id: 'plugin.user-settings.page', defaultPath: '/settings/*', routeRef: userSettingsRouteRef, - loader: () => - import('./components/SettingsPage').then(m => ), + inputs: { + providerSettings: createExtensionInput( + { + component: userSettingsProviderSettingsExtensionData, + }, + { singleton: true }, + ), + }, + loader: ({ inputs }) => + import('./components/SettingsPage').then(m => ( + + )), }); export default createPlugin({ From fdb8cef4d8ac0dd108a7c0e1e22378a5efb19e37 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 6 Oct 2023 12:00:18 +0200 Subject: [PATCH 10/18] user-settings: api reports Signed-off-by: Vincenzo Scamporlino --- plugins/user-settings/alpha-api-report.md | 27 +++++++++++++++++++++++ plugins/user-settings/src/alpha.tsx | 12 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/plugins/user-settings/alpha-api-report.md b/plugins/user-settings/alpha-api-report.md index 203cfac601..8a12861f86 100644 --- a/plugins/user-settings/alpha-api-report.md +++ b/plugins/user-settings/alpha-api-report.md @@ -3,8 +3,35 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +/// + +import { BackstagePlugin } from '@backstage/frontend-plugin-api'; +import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; +import { Extension } from '@backstage/frontend-plugin-api'; +import { RouteRef } from '@backstage/core-plugin-api'; import { TranslationRef } from '@backstage/core-plugin-api/alpha'; +// @alpha (undocumented) +const _default: BackstagePlugin; +export default _default; + +// @alpha (undocumented) +export const UserSettingsPage: Extension<{ + path: string + /** + * @alpha + */; +}>; + +// @alpha (undocumented) +export const userSettingsProviderSettingsExtensionData: ConfigurableExtensionDataRef< + JSX.Element, + {} +>; + +// @alpha (undocumented) +export const userSettingsRouteRef: RouteRef; + // @alpha (undocumented) export const userSettingsTranslationRef: TranslationRef< 'user-settings', diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index 7e21ae057f..3e4c862fa5 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -25,15 +25,24 @@ import React from 'react'; export * from './translation'; +/** + * @alpha + */ export const userSettingsRouteRef = createRouteRef({ id: 'plugin.user-settings.page', }); +/** + * @alpha + */ export const userSettingsProviderSettingsExtensionData = createExtensionDataRef( 'plugin.user-settings.page.providerSettings', ); +/** + * @alpha + */ export const UserSettingsPage = createPageExtension({ id: 'plugin.user-settings.page', defaultPath: '/settings/*', @@ -52,6 +61,9 @@ export const UserSettingsPage = createPageExtension({ )), }); +/** + * @alpha + */ export default createPlugin({ id: 'user-settings', extensions: [UserSettingsPage], From 2dd349cbef9c2f6261dfd2c10c6d06e59411ca79 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 6 Oct 2023 15:04:10 +0200 Subject: [PATCH 11/18] user-settings: remove extension data Signed-off-by: Vincenzo Scamporlino --- plugins/user-settings/alpha-api-report.md | 14 +------------- plugins/user-settings/src/alpha.tsx | 16 ++++------------ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/plugins/user-settings/alpha-api-report.md b/plugins/user-settings/alpha-api-report.md index 8a12861f86..843a6cf7af 100644 --- a/plugins/user-settings/alpha-api-report.md +++ b/plugins/user-settings/alpha-api-report.md @@ -3,10 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -/// - import { BackstagePlugin } from '@backstage/frontend-plugin-api'; -import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; import { Extension } from '@backstage/frontend-plugin-api'; import { RouteRef } from '@backstage/core-plugin-api'; import { TranslationRef } from '@backstage/core-plugin-api/alpha'; @@ -17,18 +14,9 @@ export default _default; // @alpha (undocumented) export const UserSettingsPage: Extension<{ - path: string - /** - * @alpha - */; + path: string; }>; -// @alpha (undocumented) -export const userSettingsProviderSettingsExtensionData: ConfigurableExtensionDataRef< - JSX.Element, - {} ->; - // @alpha (undocumented) export const userSettingsRouteRef: RouteRef; diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index 3e4c862fa5..9804fb40ea 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -1,6 +1,6 @@ import { createRouteRef } from '@backstage/core-plugin-api'; import { - createExtensionDataRef, + coreExtensionData, createExtensionInput, createPageExtension, createPlugin, @@ -32,14 +32,6 @@ export const userSettingsRouteRef = createRouteRef({ id: 'plugin.user-settings.page', }); -/** - * @alpha - */ -export const userSettingsProviderSettingsExtensionData = - createExtensionDataRef( - 'plugin.user-settings.page.providerSettings', - ); - /** * @alpha */ @@ -50,14 +42,14 @@ export const UserSettingsPage = createPageExtension({ inputs: { providerSettings: createExtensionInput( { - component: userSettingsProviderSettingsExtensionData, + element: coreExtensionData.reactElement, }, - { singleton: true }, + { singleton: true, optional: true }, ), }, loader: ({ inputs }) => import('./components/SettingsPage').then(m => ( - + )), }); From 9e85c9bc9fb6e0c7a126c72f6e6b110b42fbc6d6 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 9 Oct 2023 16:10:19 +0200 Subject: [PATCH 12/18] core-app-api: api report Signed-off-by: Vincenzo Scamporlino --- packages/core-app-api/alpha-api-report.md | 94 +++++++++++++++++++++++ packages/core-app-api/src/alpha.ts | 18 ++++- 2 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 packages/core-app-api/alpha-api-report.md diff --git a/packages/core-app-api/alpha-api-report.md b/packages/core-app-api/alpha-api-report.md new file mode 100644 index 0000000000..23d055efee --- /dev/null +++ b/packages/core-app-api/alpha-api-report.md @@ -0,0 +1,94 @@ +## API Report File for "@backstage/core-app-api" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { AppLanguageApi } from '@backstage/core-plugin-api/alpha'; +import { AppTheme } from '@backstage/core-plugin-api'; +import { AppThemeApi } from '@backstage/core-plugin-api'; +import { Observable } from '@backstage/types'; +import { TranslationApi } from '@backstage/core-plugin-api/alpha'; +import { TranslationMessages } from '@backstage/core-plugin-api/alpha'; +import { TranslationRef } from '@backstage/core-plugin-api/alpha'; +import { TranslationResource } from '@backstage/core-plugin-api/alpha'; +import { TranslationSnapshot } from '@backstage/core-plugin-api/alpha'; + +// @alpha +export class AppLanguageSelector implements AppLanguageApi { + // (undocumented) + static create(options?: AppLanguageSelectorOptions): AppLanguageSelector; + // (undocumented) + static createWithStorage( + options?: AppLanguageSelectorOptions, + ): AppLanguageSelector; + // (undocumented) + getAvailableLanguages(): { + languages: string[]; + }; + // (undocumented) + getLanguage(): { + language: string; + }; + // (undocumented) + language$(): Observable<{ + language: string; + }>; + // (undocumented) + setLanguage(language?: string | undefined): void; +} + +// @alpha (undocumented) +export interface AppLanguageSelectorOptions { + // (undocumented) + availableLanguages?: string[]; + // (undocumented) + defaultLanguage?: string; +} + +// @public +export class AppThemeSelector implements AppThemeApi { + constructor(themes: AppTheme[]); + // (undocumented) + activeThemeId$(): Observable; + // (undocumented) + static createWithStorage(themes: AppTheme[]): AppThemeSelector; + // (undocumented) + getActiveThemeId(): string | undefined; + // (undocumented) + getInstalledThemes(): AppTheme[]; + // (undocumented) + setActiveThemeId(themeId?: string): void; +} + +// @alpha (undocumented) +export class I18nextTranslationApi implements TranslationApi { + // (undocumented) + static create(options: I18nextTranslationApiOptions): I18nextTranslationApi; + // (undocumented) + getTranslation< + TMessages extends { + [key in string]: string; + }, + >( + translationRef: TranslationRef, + ): TranslationSnapshot; + // (undocumented) + translation$< + TMessages extends { + [key in string]: string; + }, + >( + translationRef: TranslationRef, + ): Observable>; +} + +// @alpha (undocumented) +export interface I18nextTranslationApiOptions { + // (undocumented) + languageApi: AppLanguageApi; + // (undocumented) + resources?: Array; +} + +// (No @packageDocumentation comment for this package) +``` diff --git a/packages/core-app-api/src/alpha.ts b/packages/core-app-api/src/alpha.ts index 286f3aa242..de7f5a3925 100644 --- a/packages/core-app-api/src/alpha.ts +++ b/packages/core-app-api/src/alpha.ts @@ -14,7 +14,19 @@ * limitations under the License. */ import { AppThemeSelector } from './apis'; -import { AppLanguageSelector } from './apis/implementations/AppLanguageApi'; -import { I18nextTranslationApi } from './apis/implementations/TranslationApi'; +import { + AppLanguageSelector, + AppLanguageSelectorOptions, +} from './apis/implementations/AppLanguageApi'; +import { + I18nextTranslationApi, + I18nextTranslationApiOptions, +} from './apis/implementations/TranslationApi'; -export { AppLanguageSelector, AppThemeSelector, I18nextTranslationApi }; +export { + type AppLanguageSelectorOptions, + type I18nextTranslationApiOptions, + AppLanguageSelector, + AppThemeSelector, + I18nextTranslationApi, +}; From 18c8dee6f5b11ac8b1b270ffccabf4e085f7c875 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 9 Oct 2023 22:23:29 +0200 Subject: [PATCH 13/18] a bunch of changesets Signed-off-by: Vincenzo Scamporlino --- .changeset/afraid-dingos-listen.md | 5 +++++ .changeset/heavy-plants-doubt.md | 5 +++++ .changeset/lemon-spoons-fail.md | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 .changeset/afraid-dingos-listen.md create mode 100644 .changeset/heavy-plants-doubt.md create mode 100644 .changeset/lemon-spoons-fail.md diff --git a/.changeset/afraid-dingos-listen.md b/.changeset/afraid-dingos-listen.md new file mode 100644 index 0000000000..254d03a18d --- /dev/null +++ b/.changeset/afraid-dingos-listen.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-app-api': patch +--- + +Exported `I18nextTranslationApi` utility diff --git a/.changeset/heavy-plants-doubt.md b/.changeset/heavy-plants-doubt.md new file mode 100644 index 0000000000..fc2acf74eb --- /dev/null +++ b/.changeset/heavy-plants-doubt.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-user-settings': patch +--- + +Added experimental support for declarative integration diff --git a/.changeset/lemon-spoons-fail.md b/.changeset/lemon-spoons-fail.md new file mode 100644 index 0000000000..4d7d5ca9aa --- /dev/null +++ b/.changeset/lemon-spoons-fail.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-app-api': patch +--- + +Exported `AppLanguageSelector` utility From 73e704f3ed21427339261b57879b1260d2a1973d Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Tue, 10 Oct 2023 19:38:35 +0200 Subject: [PATCH 14/18] core-app-api: rollback alpha exports Signed-off-by: Vincenzo Scamporlino --- .changeset/afraid-dingos-listen.md | 5 - .changeset/lemon-spoons-fail.md | 5 - packages/core-app-api/alpha-api-report.md | 94 ------------------- packages/core-app-api/package.json | 4 - packages/core-app-api/src/alpha.ts | 32 ------- .../frontend-app-api/src/wiring/createApp.tsx | 11 +-- 6 files changed, 5 insertions(+), 146 deletions(-) delete mode 100644 .changeset/afraid-dingos-listen.md delete mode 100644 .changeset/lemon-spoons-fail.md delete mode 100644 packages/core-app-api/alpha-api-report.md delete mode 100644 packages/core-app-api/src/alpha.ts diff --git a/.changeset/afraid-dingos-listen.md b/.changeset/afraid-dingos-listen.md deleted file mode 100644 index 254d03a18d..0000000000 --- a/.changeset/afraid-dingos-listen.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/core-app-api': patch ---- - -Exported `I18nextTranslationApi` utility diff --git a/.changeset/lemon-spoons-fail.md b/.changeset/lemon-spoons-fail.md deleted file mode 100644 index 4d7d5ca9aa..0000000000 --- a/.changeset/lemon-spoons-fail.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/core-app-api': patch ---- - -Exported `AppLanguageSelector` utility diff --git a/packages/core-app-api/alpha-api-report.md b/packages/core-app-api/alpha-api-report.md deleted file mode 100644 index 23d055efee..0000000000 --- a/packages/core-app-api/alpha-api-report.md +++ /dev/null @@ -1,94 +0,0 @@ -## API Report File for "@backstage/core-app-api" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts -import { AppLanguageApi } from '@backstage/core-plugin-api/alpha'; -import { AppTheme } from '@backstage/core-plugin-api'; -import { AppThemeApi } from '@backstage/core-plugin-api'; -import { Observable } from '@backstage/types'; -import { TranslationApi } from '@backstage/core-plugin-api/alpha'; -import { TranslationMessages } from '@backstage/core-plugin-api/alpha'; -import { TranslationRef } from '@backstage/core-plugin-api/alpha'; -import { TranslationResource } from '@backstage/core-plugin-api/alpha'; -import { TranslationSnapshot } from '@backstage/core-plugin-api/alpha'; - -// @alpha -export class AppLanguageSelector implements AppLanguageApi { - // (undocumented) - static create(options?: AppLanguageSelectorOptions): AppLanguageSelector; - // (undocumented) - static createWithStorage( - options?: AppLanguageSelectorOptions, - ): AppLanguageSelector; - // (undocumented) - getAvailableLanguages(): { - languages: string[]; - }; - // (undocumented) - getLanguage(): { - language: string; - }; - // (undocumented) - language$(): Observable<{ - language: string; - }>; - // (undocumented) - setLanguage(language?: string | undefined): void; -} - -// @alpha (undocumented) -export interface AppLanguageSelectorOptions { - // (undocumented) - availableLanguages?: string[]; - // (undocumented) - defaultLanguage?: string; -} - -// @public -export class AppThemeSelector implements AppThemeApi { - constructor(themes: AppTheme[]); - // (undocumented) - activeThemeId$(): Observable; - // (undocumented) - static createWithStorage(themes: AppTheme[]): AppThemeSelector; - // (undocumented) - getActiveThemeId(): string | undefined; - // (undocumented) - getInstalledThemes(): AppTheme[]; - // (undocumented) - setActiveThemeId(themeId?: string): void; -} - -// @alpha (undocumented) -export class I18nextTranslationApi implements TranslationApi { - // (undocumented) - static create(options: I18nextTranslationApiOptions): I18nextTranslationApi; - // (undocumented) - getTranslation< - TMessages extends { - [key in string]: string; - }, - >( - translationRef: TranslationRef, - ): TranslationSnapshot; - // (undocumented) - translation$< - TMessages extends { - [key in string]: string; - }, - >( - translationRef: TranslationRef, - ): Observable>; -} - -// @alpha (undocumented) -export interface I18nextTranslationApiOptions { - // (undocumented) - languageApi: AppLanguageApi; - // (undocumented) - resources?: Array; -} - -// (No @packageDocumentation comment for this package) -``` diff --git a/packages/core-app-api/package.json b/packages/core-app-api/package.json index c7b00c9c57..e3332998df 100644 --- a/packages/core-app-api/package.json +++ b/packages/core-app-api/package.json @@ -7,14 +7,10 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts", "./package.json": "./package.json" }, "typesVersions": { "*": { - "alpha": [ - "src/alpha.ts" - ], "package.json": [ "package.json" ] diff --git a/packages/core-app-api/src/alpha.ts b/packages/core-app-api/src/alpha.ts deleted file mode 100644 index de7f5a3925..0000000000 --- a/packages/core-app-api/src/alpha.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AppThemeSelector } from './apis'; -import { - AppLanguageSelector, - AppLanguageSelectorOptions, -} from './apis/implementations/AppLanguageApi'; -import { - I18nextTranslationApi, - I18nextTranslationApiOptions, -} from './apis/implementations/TranslationApi'; - -export { - type AppLanguageSelectorOptions, - type I18nextTranslationApiOptions, - AppLanguageSelector, - AppThemeSelector, - I18nextTranslationApi, -}; diff --git a/packages/frontend-app-api/src/wiring/createApp.tsx b/packages/frontend-app-api/src/wiring/createApp.tsx index f37d05ec6f..640368ff83 100644 --- a/packages/frontend-app-api/src/wiring/createApp.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.tsx @@ -57,13 +57,8 @@ import { ApiFactoryRegistry, ApiProvider, ApiResolver, -} from '@backstage/core-app-api'; - -import { - AppLanguageSelector, AppThemeSelector, - I18nextTranslationApi, -} from '@backstage/core-app-api/alpha'; +} from '@backstage/core-app-api'; // TODO: Get rid of all of these // eslint-disable-next-line @backstage/no-relative-monorepo-imports @@ -81,6 +76,10 @@ import { overrideBaseUrlConfigs } from '../../../core-app-api/src/app/overrideBa // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { RoutingProvider } from '../../../core-app-api/src/routing/RoutingProvider'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { AppLanguageSelector } from '../../../core-app-api/src/apis/implementations/AppLanguageApi/AppLanguageSelector'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { I18nextTranslationApi } from '../../../core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports import { apis as defaultApis, components as defaultComponents, From 00d9803ce96fb66e302a6fad11aea327c1bca9a1 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Tue, 10 Oct 2023 23:09:29 +0200 Subject: [PATCH 15/18] user-settings: keep page extension internal Signed-off-by: Vincenzo Scamporlino --- plugins/user-settings/alpha-api-report.md | 6 ------ plugins/user-settings/src/alpha.tsx | 5 +---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/plugins/user-settings/alpha-api-report.md b/plugins/user-settings/alpha-api-report.md index 843a6cf7af..a4f41a729a 100644 --- a/plugins/user-settings/alpha-api-report.md +++ b/plugins/user-settings/alpha-api-report.md @@ -4,7 +4,6 @@ ```ts import { BackstagePlugin } from '@backstage/frontend-plugin-api'; -import { Extension } from '@backstage/frontend-plugin-api'; import { RouteRef } from '@backstage/core-plugin-api'; import { TranslationRef } from '@backstage/core-plugin-api/alpha'; @@ -12,11 +11,6 @@ import { TranslationRef } from '@backstage/core-plugin-api/alpha'; const _default: BackstagePlugin; export default _default; -// @alpha (undocumented) -export const UserSettingsPage: Extension<{ - path: string; -}>; - // @alpha (undocumented) export const userSettingsRouteRef: RouteRef; diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index 9804fb40ea..8e1be0d00c 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -32,10 +32,7 @@ export const userSettingsRouteRef = createRouteRef({ id: 'plugin.user-settings.page', }); -/** - * @alpha - */ -export const UserSettingsPage = createPageExtension({ +const UserSettingsPage = createPageExtension({ id: 'plugin.user-settings.page', defaultPath: '/settings/*', routeRef: userSettingsRouteRef, From 1e60a9c3a5a1123f8bcb277f9e70fa77c0eb15e3 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Tue, 10 Oct 2023 23:22:38 +0200 Subject: [PATCH 16/18] fronten-app-api: routing system matches subroutes Signed-off-by: Vincenzo Scamporlino --- .changeset/long-owls-complain.md | 5 +++++ packages/frontend-app-api/src/extensions/CoreRoutes.tsx | 2 +- plugins/user-settings/src/alpha.tsx | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/long-owls-complain.md diff --git a/.changeset/long-owls-complain.md b/.changeset/long-owls-complain.md new file mode 100644 index 0000000000..f96b0f0987 --- /dev/null +++ b/.changeset/long-owls-complain.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-app-api': patch +--- + +Fixed an issue preventing the routing system to match subroutes diff --git a/packages/frontend-app-api/src/extensions/CoreRoutes.tsx b/packages/frontend-app-api/src/extensions/CoreRoutes.tsx index 5006a87cac..8d22b40eec 100644 --- a/packages/frontend-app-api/src/extensions/CoreRoutes.tsx +++ b/packages/frontend-app-api/src/extensions/CoreRoutes.tsx @@ -39,7 +39,7 @@ export const CoreRoutes = createExtension({ const Routes = () => { const element = useRoutes( inputs.routes.map(route => ({ - path: route.path, + path: `${route.path}/*`, element: route.element, })), ); diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index 8e1be0d00c..2eb2febfe6 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -34,7 +34,7 @@ export const userSettingsRouteRef = createRouteRef({ const UserSettingsPage = createPageExtension({ id: 'plugin.user-settings.page', - defaultPath: '/settings/*', + defaultPath: '/settings', routeRef: userSettingsRouteRef, inputs: { providerSettings: createExtensionInput( From a991ed97826137e359ac7650024d76ae40d53edd Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Wed, 11 Oct 2023 12:01:19 +0200 Subject: [PATCH 17/18] app-next: create extension override for entity page Signed-off-by: Vincenzo Scamporlino --- packages/app-next/src/App.tsx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index 65d729bf92..2ab447c68f 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -21,8 +21,8 @@ import graphiqlPlugin from '@backstage/plugin-graphiql/alpha'; import techRadarPlugin from '@backstage/plugin-tech-radar/alpha'; import userSettingsPlugin from '@backstage/plugin-user-settings/alpha'; import { + createExtensionOverrides, createPageExtension, - createPlugin, } from '@backstage/frontend-plugin-api'; import { entityRouteRef } from '@backstage/plugin-catalog-react'; @@ -55,16 +55,11 @@ TODO: /* app.tsx */ -const fakePlugin = createPlugin({ - id: 'fake', - extensions: [ - createPageExtension({ - id: 'catalog:entity', - defaultPath: '/fakeentity', - routeRef: entityRouteRef, - loader: async () =>
hello 😅
, - }), - ], +const entityPageExtension = createPageExtension({ + id: 'catalog:entity', + defaultPath: '/catalog/:namespace/:kind/:name', + routeRef: entityRouteRef, + loader: async () =>
Just a temporary mocked entity page
, }); const app = createApp({ @@ -73,7 +68,9 @@ const app = createApp({ pagesPlugin, techRadarPlugin, userSettingsPlugin, - fakePlugin, + createExtensionOverrides({ + extensions: [entityPageExtension], + }), ], // bindRoutes({ bind }) { // bind(catalogPlugin.externalRoutes, { From 224907840cd36d66cdaa388fce29103114b0f266 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Wed, 11 Oct 2023 12:01:45 +0200 Subject: [PATCH 18/18] user-settings: minor fixes Signed-off-by: Vincenzo Scamporlino --- .changeset/heavy-plants-doubt.md | 2 +- plugins/user-settings/src/alpha.tsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.changeset/heavy-plants-doubt.md b/.changeset/heavy-plants-doubt.md index fc2acf74eb..3988a16752 100644 --- a/.changeset/heavy-plants-doubt.md +++ b/.changeset/heavy-plants-doubt.md @@ -2,4 +2,4 @@ '@backstage/plugin-user-settings': patch --- -Added experimental support for declarative integration +Added experimental support for declarative integration via the `/alpha` subpath. diff --git a/plugins/user-settings/src/alpha.tsx b/plugins/user-settings/src/alpha.tsx index 2eb2febfe6..8d68ccf259 100644 --- a/plugins/user-settings/src/alpha.tsx +++ b/plugins/user-settings/src/alpha.tsx @@ -1,11 +1,3 @@ -import { createRouteRef } from '@backstage/core-plugin-api'; -import { - coreExtensionData, - createExtensionInput, - createPageExtension, - createPlugin, -} from '@backstage/frontend-plugin-api'; - /* * Copyright 2023 The Backstage Authors * @@ -21,6 +13,14 @@ import { * See the License for the specific language governing permissions and * limitations under the License. */ +import { createRouteRef } from '@backstage/core-plugin-api'; +import { + coreExtensionData, + createExtensionInput, + createPageExtension, + createPlugin, +} from '@backstage/frontend-plugin-api'; + import React from 'react'; export * from './translation';