From 1263b9cc42a8f4f7c1f383966c6843e3aca69a86 Mon Sep 17 00:00:00 2001 From: Stephen Cprek Date: Fri, 17 Feb 2023 16:33:07 -0500 Subject: [PATCH 1/3] Add ADR type to search page and result cast Signed-off-by: Stephen Cprek --- plugins/adr/README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/adr/README.md b/plugins/adr/README.md index a669762dad..4860406229 100644 --- a/plugins/adr/README.md +++ b/plugins/adr/README.md @@ -71,16 +71,32 @@ Afterwards, add the following code snippet to use `AdrSearchResultListItem` when import { AdrSearchResultListItem } from '@backstage/plugin-adr'; ... +, + }, + ]} +/> -case 'adr': +... + +case 'adrs': return ( ); ``` +> Note the `AdrDocument` might not be needed in newer versions https://github.com/backstage/backstage/issues/13723 + ## Custom ADR formats By default, this plugin will parse ADRs according to the format specified by the [Markdown Architecture Decision Record (MADR) v2.x template](https://github.com/adr/madr/tree/2.1.2). If your ADRs are written using a different format, you can apply the following customizations to correctly identify and parse your documents: From 7650bdf40875c71e5ace5b9940bd9d2a10f1fdff Mon Sep 17 00:00:00 2001 From: Steve Cprek Date: Tue, 21 Feb 2023 16:15:21 -0600 Subject: [PATCH 2/3] Fix adrs typo and add ADR specific Entity filter Signed-off-by: Steve Cprek --- plugins/.changeset/dull-adults-drum.md | 5 +++ plugins/adr/README.md | 53 +++++++++++++++++++++----- 2 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 plugins/.changeset/dull-adults-drum.md diff --git a/plugins/.changeset/dull-adults-drum.md b/plugins/.changeset/dull-adults-drum.md new file mode 100644 index 0000000000..088eb1539e --- /dev/null +++ b/plugins/.changeset/dull-adults-drum.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-adr': patch +--- + +Updated readme instructions diff --git a/plugins/adr/README.md b/plugins/adr/README.md index 4860406229..2e2b82b3fd 100644 --- a/plugins/adr/README.md +++ b/plugins/adr/README.md @@ -69,33 +69,68 @@ Afterwards, add the following code snippet to use `AdrSearchResultListItem` when ```tsx // In packages/app/src/components/search/SearchPage.tsx import { AdrSearchResultListItem } from '@backstage/plugin-adr'; +import { AdrDocument } from '@backstage/plugin-adr-common'; ... + , }, ]} /> - + ... -case 'adrs': - return ( - + +... + // ADR specific type + {types.includes('adr') && ( + { + // Return a list of entities which have ADRs. + const { items } = await catalogApi.getEntities({ + fields: ['metadata.name'], + filter: { + 'metadata.annotations.backstage.io/adr-location': + CATALOG_FILTER_EXISTS, + }, + }); + + const names = items.map(entity => entity.metadata.name); + names.sort(); + return names; + }} /> - ); + )} + +... + +// In results + + + {({ results }) => ( + case 'adr': + return ( + + ); ``` -> Note the `AdrDocument` might not be needed in newer versions https://github.com/backstage/backstage/issues/13723 ## Custom ADR formats From 77fa1b6c228eb1a7da5102dc21b71bc31580d22a Mon Sep 17 00:00:00 2001 From: Steve Cprek Date: Thu, 23 Feb 2023 14:40:37 -0600 Subject: [PATCH 3/3] Remove searchfilter select and mention according as optional Signed-off-by: Steve Cprek --- plugins/adr/README.md | 67 +++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/plugins/adr/README.md b/plugins/adr/README.md index 2e2b82b3fd..7feb9b03b0 100644 --- a/plugins/adr/README.md +++ b/plugins/adr/README.md @@ -28,7 +28,7 @@ yarn --cwd packages/app add @backstage/plugin-adr import { EntityAdrContent, isAdrAvailable } from '@backstage/plugin-adr'; ... - +// Note: Add to any other Pages as well (e.g. defaultEntityPage and websiteEntityPage) const serviceEntityPage = ( {/* other tabs... */} @@ -72,7 +72,7 @@ import { AdrSearchResultListItem } from '@backstage/plugin-adr'; import { AdrDocument } from '@backstage/plugin-adr-common'; ... - +// Optional - Add type to side pane - ... -// In filters - - -... - // ADR specific type - {types.includes('adr') && ( - { - // Return a list of entities which have ADRs. - const { items } = await catalogApi.getEntities({ - fields: ['metadata.name'], - filter: { - 'metadata.annotations.backstage.io/adr-location': - CATALOG_FILTER_EXISTS, - }, - }); - - const names = items.map(entity => entity.metadata.name); - names.sort(); - return names; - }} - /> - )} - -... - // In results - - - {({ results }) => ( - case 'adr': - return ( - - ); + + {({ results }) => ( + + {results.map(({ type, document, highlight, rank }) => { + switch (type) { + ... + case 'adr': + return ( + + ); + ... + } + })} + + )} + ``` - ## Custom ADR formats By default, this plugin will parse ADRs according to the format specified by the [Markdown Architecture Decision Record (MADR) v2.x template](https://github.com/adr/madr/tree/2.1.2). If your ADRs are written using a different format, you can apply the following customizations to correctly identify and parse your documents: