From f16d38086f3ca1050cee32c46fb3225b0cdba1c0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 17 Jul 2025 12:30:04 +0200 Subject: [PATCH 1/2] home: add missing vists API to NFS Signed-off-by: Patrik Oldsberg --- .changeset/eleven-tigers-drop.md | 5 +++++ plugins/home/report-alpha.api.md | 16 ++++++++++++++++ plugins/home/src/alpha.tsx | 22 +++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .changeset/eleven-tigers-drop.md diff --git a/.changeset/eleven-tigers-drop.md b/.changeset/eleven-tigers-drop.md new file mode 100644 index 0000000000..7abfe51744 --- /dev/null +++ b/.changeset/eleven-tigers-drop.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-home': patch +--- + +Add the missing Vists API to the alpha plugin, fixing a crash due to the API not being installed. diff --git a/plugins/home/report-alpha.api.md b/plugins/home/report-alpha.api.md index 98a8cab823..c7fcf8ab67 100644 --- a/plugins/home/report-alpha.api.md +++ b/plugins/home/report-alpha.api.md @@ -3,6 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyApiFactory } from '@backstage/frontend-plugin-api'; import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; @@ -19,6 +20,21 @@ const _default: FrontendPlugin< }, {}, { + 'api:home/visits': ExtensionDefinition<{ + kind: 'api'; + name: 'visits'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + params: { + factory: AnyApiFactory; + }; + }>; 'app-root-element:home/visit-listener': ExtensionDefinition<{ kind: 'app-root-element'; name: 'visit-listener'; diff --git a/plugins/home/src/alpha.tsx b/plugins/home/src/alpha.tsx index 880b53af40..0d5b0fb94c 100644 --- a/plugins/home/src/alpha.tsx +++ b/plugins/home/src/alpha.tsx @@ -22,9 +22,14 @@ import { createFrontendPlugin, createRouteRef, AppRootElementBlueprint, + identityApiRef, + storageApiRef, + createApiFactory, + ApiBlueprint, } from '@backstage/frontend-plugin-api'; import { compatWrapper } from '@backstage/core-compat-api'; import { VisitListener } from './components/'; +import { visitsApiRef, VisitsStorageApi } from './api'; const rootRouteRef = createRouteRef(); @@ -72,13 +77,28 @@ const visitListenerAppRootElement = AppRootElementBlueprint.make({ }, }); +const visitsApi = ApiBlueprint.make({ + name: 'visits', + params: { + factory: createApiFactory({ + api: visitsApiRef, + deps: { + storageApi: storageApiRef, + identityApi: identityApiRef, + }, + factory: ({ storageApi, identityApi }) => + VisitsStorageApi.create({ storageApi, identityApi }), + }), + }, +}); + /** * @alpha */ export default createFrontendPlugin({ pluginId: 'home', info: { packageJson: () => import('../package.json') }, - extensions: [homePage, visitListenerAppRootElement], + extensions: [homePage, visitsApi, visitListenerAppRootElement], routes: { root: rootRouteRef, }, From 75528cad5658ef7f7113eb835df79a9f059839e6 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 17 Jul 2025 14:43:20 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Signed-off-by: Patrik Oldsberg --- .changeset/eleven-tigers-drop.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/eleven-tigers-drop.md b/.changeset/eleven-tigers-drop.md index 7abfe51744..ea2702cfb5 100644 --- a/.changeset/eleven-tigers-drop.md +++ b/.changeset/eleven-tigers-drop.md @@ -2,4 +2,4 @@ '@backstage/plugin-home': patch --- -Add the missing Vists API to the alpha plugin, fixing a crash due to the API not being installed. +Add the missing Visits API to the alpha plugin, fixing a crash due to the API not being installed.