From 790fe3c4c117ea3da0044424eab40eaba94faa3e Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Tue, 19 Sep 2023 15:52:27 +0200 Subject: [PATCH 1/3] Initial setup for alpha TechDocs FE DI Co-authored-by: Johan Haals Signed-off-by: Philipp Hugenroth --- plugins/techdocs/src/alpha.tsx | 98 +++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index bea4b7ab34..864780afff 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -18,8 +18,23 @@ import React from 'react'; import { createPlugin, createSchemaFromZod, + createApiExtension, + createPageExtension, } from '@backstage/frontend-plugin-api'; import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; +import { + configApiRef, + createApiFactory, + discoveryApiRef, + fetchApiRef, + identityApiRef, +} from '@backstage/core-plugin-api'; +import { + techdocsApiRef, + techdocsStorageApiRef, +} from '@backstage/plugin-techdocs-react'; +import { TechDocsClient, TechDocsStorageClient } from './client'; +import { rootDocsRouteRef, rootRouteRef } from './routes'; /** @alpha */ export const TechDocsSearchResultListItemExtension = @@ -44,8 +59,89 @@ export const TechDocsSearchResultListItemExtension = }, }); +/** + * Responsible for rendering the provided router element + * + * @alpha + */ +const TechDocsIndexPage = createPageExtension({ + id: 'plugin.techdocs.indexPage', + defaultPath: '/docs', + routeRef: rootRouteRef, + loader: () => + import('./home/components/TechDocsIndexPage').then(m => ( + + )), +}); + +/** + * Component responsible for composing a TechDocs reader page experience + * + * @alpha + */ +const TechDocsReaderPage = createPageExtension({ + id: 'plugin.techdocs.readerPage', + loader: () => + import('./reader/components/TechDocsReaderPage').then(m => ( + + )), + routeRef: rootDocsRouteRef, + defaultPath: '/docs/:namespace/:kind/:name/*', +}); + +/** @alpha */ +const techDocsStorage = createApiExtension({ + api: techdocsStorageApiRef, + + factory() { + return createApiFactory({ + api: techdocsStorageApiRef, + deps: { + configApi: configApiRef, + discoveryApi: discoveryApiRef, + identityApi: identityApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ configApi, discoveryApi, identityApi, fetchApi }) => + new TechDocsStorageClient({ + configApi, + discoveryApi, + identityApi, + fetchApi, + }), + }); + }, +}); + +/** @alpha */ +const techDocsClient = createApiExtension({ + api: techdocsApiRef, + factory() { + return createApiFactory({ + api: techdocsApiRef, + deps: { + configApi: configApiRef, + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ configApi, discoveryApi, fetchApi }) => + new TechDocsClient({ + configApi, + discoveryApi, + fetchApi, + }), + }); + }, +}); + /** @alpha */ export default createPlugin({ id: 'techdocs', - extensions: [TechDocsSearchResultListItemExtension], + extensions: [ + TechDocsIndexPage, + TechDocsReaderPage, + techDocsClient, + techDocsStorage, + TechDocsSearchResultListItemExtension, + ], }); From 27740caa2df15f499ebab45106eca3b194628b98 Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Wed, 27 Sep 2023 14:18:42 +0200 Subject: [PATCH 2/3] Add changeset & add to app-next Signed-off-by: Philipp Hugenroth --- .changeset/modern-owls-mate.md | 5 +++++ packages/app-next/src/App.tsx | 2 ++ plugins/techdocs/src/alpha.tsx | 11 ++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changeset/modern-owls-mate.md diff --git a/.changeset/modern-owls-mate.md b/.changeset/modern-owls-mate.md new file mode 100644 index 0000000000..73d98f426c --- /dev/null +++ b/.changeset/modern-owls-mate.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': minor +--- + +Added experimental support for declarative integration. diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index 2ab447c68f..f19fb1c109 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -25,6 +25,7 @@ import { createPageExtension, } from '@backstage/frontend-plugin-api'; import { entityRouteRef } from '@backstage/plugin-catalog-react'; +import techdocsPlugin from '@backstage/plugin-techdocs/alpha'; /* @@ -67,6 +68,7 @@ const app = createApp({ graphiqlPlugin, pagesPlugin, techRadarPlugin, + techdocsPlugin, userSettingsPlugin, createExtensionOverrides({ extensions: [entityPageExtension], diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index 864780afff..2f991f2fcc 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -25,6 +25,7 @@ import { createSearchResultListItemExtension } from '@backstage/plugin-search-re import { configApiRef, createApiFactory, + createRouteRef, discoveryApiRef, fetchApiRef, identityApiRef, @@ -34,7 +35,15 @@ import { techdocsStorageApiRef, } from '@backstage/plugin-techdocs-react'; import { TechDocsClient, TechDocsStorageClient } from './client'; -import { rootDocsRouteRef, rootRouteRef } from './routes'; + +const rootRouteRef = createRouteRef({ + id: 'plugin.techdocs.indexPage', +}); + +const rootDocsRouteRef = createRouteRef({ + id: 'plugin.techdocs.readerPage', + params: ['namespace', 'kind', 'name'], +}); /** @alpha */ export const TechDocsSearchResultListItemExtension = From cb0da264671aa8ea8370cfe1954b01c81535c94a Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Thu, 12 Oct 2023 12:09:43 +0200 Subject: [PATCH 3/3] Update .changeset/modern-owls-mate.md Co-authored-by: Patrik Oldsberg Signed-off-by: Philipp Hugenroth --- .changeset/modern-owls-mate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/modern-owls-mate.md b/.changeset/modern-owls-mate.md index 73d98f426c..bed33c6bbc 100644 --- a/.changeset/modern-owls-mate.md +++ b/.changeset/modern-owls-mate.md @@ -2,4 +2,4 @@ '@backstage/plugin-techdocs': minor --- -Added experimental support for declarative integration. +Added experimental support for declarative integration via the `/alpha` subpath.