Merge pull request #16435 from scprek/patch-1
Add ADR type to search page and result cast
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-adr': patch
|
||||
---
|
||||
|
||||
Updated readme instructions
|
||||
+38
-8
@@ -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 = (
|
||||
<EntityLayout>
|
||||
{/* other tabs... */}
|
||||
@@ -69,16 +69,46 @@ 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';
|
||||
|
||||
...
|
||||
// Optional - Add type to side pane
|
||||
<SearchType.Accordion
|
||||
name="Result Type"
|
||||
defaultValue="software-catalog"
|
||||
types={[
|
||||
...
|
||||
{
|
||||
value: 'adr',
|
||||
name: 'Architecture Decision Records',
|
||||
icon: <DocsIcon />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
...
|
||||
|
||||
case 'adr':
|
||||
return (
|
||||
<AdrSearchResultListItem
|
||||
key={document.location}
|
||||
result={document}
|
||||
/>
|
||||
);
|
||||
// In results
|
||||
<SearchResult>
|
||||
{({ results }) => (
|
||||
<List>
|
||||
{results.map(({ type, document, highlight, rank }) => {
|
||||
switch (type) {
|
||||
...
|
||||
case 'adr':
|
||||
return (
|
||||
<AdrSearchResultListItem
|
||||
key={document.location}
|
||||
// Not required if you're leveraging the new search results extensions available in v1.11+
|
||||
// https://backstage.io/docs/features/search/how-to-guides#2-using-an-extension-in-your-backstage-app
|
||||
result={document as AdrDocument}
|
||||
/>
|
||||
);
|
||||
...
|
||||
}
|
||||
})}
|
||||
</List>
|
||||
)}
|
||||
</SearchResult>
|
||||
```
|
||||
|
||||
## Custom ADR formats
|
||||
|
||||
Reference in New Issue
Block a user