feat(adrs): display associated entity in AdrSearchResultListItem

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2022-08-08 15:30:25 -04:00
parent af1e11b744
commit bfc7c50a09
7 changed files with 33 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
---
'@backstage/plugin-adr': minor
'@backstage/plugin-adr-backend': minor
'@backstage/plugin-adr-common': minor
---
Display associated entity as a chip in `AdrSearchResultListItem`
BREAKING: `AdrDocument` now includes a `entityRef` property, if you have a custom `AdrParser` you will have to supply this property in your returned documents
@@ -142,6 +142,7 @@ export class DefaultAdrCollatorFactory implements DocumentCollatorFactory {
'metadata.annotations',
'metadata.name',
'metadata.namespace',
'metadata.title',
],
},
{ token },
@@ -16,6 +16,7 @@
import { DateTime } from 'luxon';
import { marked } from 'marked';
import { stringifyEntityRef } from '@backstage/catalog-model';
import { MADR_DATE_FORMAT } from '@backstage/plugin-adr-common';
import { AdrParser } from './types';
@@ -101,6 +102,8 @@ export const createMadrParser = (
text: content,
status: adrStatus,
date: adrDate,
entityRef: stringifyEntityRef(entity),
entityTitle: entity.metadata.title,
location: applyArgsToFormat(locationTemplate, {
namespace: entity.metadata.namespace || 'default',
kind: entity.kind,
+2
View File
@@ -10,6 +10,8 @@ import { ScmIntegrationRegistry } from '@backstage/integration';
// @public
export interface AdrDocument extends IndexableDocument {
date?: string;
entityRef: string;
entityTitle?: string;
status?: string;
}
+8
View File
@@ -84,6 +84,14 @@ export const madrFilePathFilter: AdrFilePathFilterFn = (path: string) =>
* @public
*/
export interface AdrDocument extends IndexableDocument {
/**
* Ref of the entity associated with this ADR
*/
entityRef: string;
/**
* Title of the entity associated with this ADR
*/
entityTitle?: string;
/**
* ADR status label
*/
+1
View File
@@ -22,6 +22,7 @@
"postpack": "backstage-cli package postpack"
},
"dependencies": {
"@backstage/catalog-model": "^1.1.0",
"@backstage/core-components": "^0.11.0-next.2",
"@backstage/core-plugin-api": "^1.0.5-next.0",
"@backstage/integration-react": "^1.1.3-next.1",
@@ -23,9 +23,11 @@ import {
ListItemText,
makeStyles,
} from '@material-ui/core';
import { parseEntityRef } from '@backstage/catalog-model';
import { Link } from '@backstage/core-components';
import { useAnalytics } from '@backstage/core-plugin-api';
import { AdrDocument } from '@backstage/plugin-adr-common';
import { humanizeEntityRef } from '@backstage/plugin-catalog-react';
import { ResultHighlight } from '@backstage/plugin-search-common';
import { HighlightedSearchResultText } from '@backstage/plugin-search-react';
@@ -104,6 +106,13 @@ export const AdrSearchResultListItem = ({
}
/>
<Box>
<Chip
label={`Entity: ${
result.entityTitle ??
humanizeEntityRef(parseEntityRef(result.entityRef))
}`}
size="small"
/>
{result.status && (
<Chip label={`Status: ${result.status}`} size="small" />
)}