From d58c324777bf90eddc43d0aa8c5668f7a14a5f9b Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Fri, 29 Sep 2023 09:21:40 +0200 Subject: [PATCH 1/4] chore(techdocs): configure alpha subpath Signed-off-by: Camila Belo --- plugins/techdocs/package.json | 19 ++++++++++++++++--- plugins/techdocs/src/alpha.tsx | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 plugins/techdocs/src/alpha.tsx diff --git a/plugins/techdocs/package.json b/plugins/techdocs/package.json index 7a34577f01..058e838fe6 100644 --- a/plugins/techdocs/package.json +++ b/plugins/techdocs/package.json @@ -6,9 +6,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.tsx", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.tsx" + ], + "package.json": [ + "package.json" + ] + } }, "backstage": { "role": "frontend-plugin" diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx new file mode 100644 index 0000000000..eb2f165350 --- /dev/null +++ b/plugins/techdocs/src/alpha.tsx @@ -0,0 +1,15 @@ +/* + * 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. + */ From 2718c8d4cbba8ec601ddf0a028da14e859ed937d Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Fri, 29 Sep 2023 09:38:13 +0200 Subject: [PATCH 2/4] feat(techdocs): migrate search result item extension Signed-off-by: Camila Belo --- plugins/techdocs/package.json | 1 + plugins/techdocs/src/alpha.tsx | 36 ++++++++++++++++++++++++++++++++++ yarn.lock | 1 + 3 files changed, 38 insertions(+) diff --git a/plugins/techdocs/package.json b/plugins/techdocs/package.json index 058e838fe6..80951ed400 100644 --- a/plugins/techdocs/package.json +++ b/plugins/techdocs/package.json @@ -52,6 +52,7 @@ "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", + "@backstage/frontend-plugin-api": "workspace:^", "@backstage/integration": "workspace:^", "@backstage/integration-react": "workspace:^", "@backstage/plugin-catalog-react": "workspace:^", diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index eb2f165350..bea4b7ab34 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -13,3 +13,39 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import React from 'react'; +import { + createPlugin, + createSchemaFromZod, +} from '@backstage/frontend-plugin-api'; +import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; + +/** @alpha */ +export const TechDocsSearchResultListItemExtension = + createSearchResultListItemExtension({ + id: 'techdocs', + configSchema: createSchemaFromZod(z => + z.object({ + // TODO: Define how the icon can be configurable + title: z.string().optional(), + lineClamp: z.number().default(5), + asLink: z.boolean().default(true), + asListItem: z.boolean().default(true), + noTrack: z.boolean().default(false), + }), + ), + predicate: result => result.type === 'techdocs', + component: async ({ config }) => { + const { TechDocsSearchResultListItem } = await import( + './search/components/TechDocsSearchResultListItem' + ); + return props => ; + }, + }); + +/** @alpha */ +export default createPlugin({ + id: 'techdocs', + extensions: [TechDocsSearchResultListItemExtension], +}); diff --git a/yarn.lock b/yarn.lock index 3dd3f6315b..655acc26ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9739,6 +9739,7 @@ __metadata: "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" "@backstage/errors": "workspace:^" + "@backstage/frontend-plugin-api": "workspace:^" "@backstage/integration": "workspace:^" "@backstage/integration-react": "workspace:^" "@backstage/plugin-catalog-react": "workspace:^" From 34e1d285bd4cd0f1cba9ef07e99e7d3561d27c41 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Fri, 29 Sep 2023 09:39:47 +0200 Subject: [PATCH 3/4] docs(techdocs): update api reports Signed-off-by: Camila Belo --- plugins/techdocs/alpha-api-report.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plugins/techdocs/alpha-api-report.md diff --git a/plugins/techdocs/alpha-api-report.md b/plugins/techdocs/alpha-api-report.md new file mode 100644 index 0000000000..30d208865c --- /dev/null +++ b/plugins/techdocs/alpha-api-report.md @@ -0,0 +1,23 @@ +## API Report File for "@backstage/plugin-techdocs" + +> 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 { Extension } from '@backstage/frontend-plugin-api'; + +// @alpha (undocumented) +const _default: BackstagePlugin; +export default _default; + +// @alpha (undocumented) +export const TechDocsSearchResultListItemExtension: Extension<{ + lineClamp: number; + noTrack: boolean; + asListItem: boolean; + asLink: boolean; + title?: string | undefined; +}>; + +// (No @packageDocumentation comment for this package) +``` From 4918f65ab23a949d42e39157ebd5129cbbb86121 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Fri, 29 Sep 2023 09:41:45 +0200 Subject: [PATCH 4/4] chore: add changeset file Signed-off-by: Camila Belo --- .changeset/fair-frogs-enjoy.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fair-frogs-enjoy.md diff --git a/.changeset/fair-frogs-enjoy.md b/.changeset/fair-frogs-enjoy.md new file mode 100644 index 0000000000..12eb57489e --- /dev/null +++ b/.changeset/fair-frogs-enjoy.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Create an experimental `TechDocsSearchResultItemExtension` for declarative integration with Backstage; it can be accessed via the `/alpha` import.