From 0549587ebfd7e5d5f51af77a96fe0a744dd79947 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Wed, 29 Sep 2021 14:24:13 +0200 Subject: [PATCH] TechDocsPage to accept children and withSearch prop Signed-off-by: Emma Indal --- .../src/reader/components/TechDocsPage.tsx | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/plugins/techdocs/src/reader/components/TechDocsPage.tsx b/plugins/techdocs/src/reader/components/TechDocsPage.tsx index 568fca7330..c6ae7f17aa 100644 --- a/plugins/techdocs/src/reader/components/TechDocsPage.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsPage.tsx @@ -21,11 +21,26 @@ import { techdocsApiRef } from '../../api'; import { Reader } from './Reader'; import { TechDocsNotFound } from './TechDocsNotFound'; import { TechDocsPageHeader } from './TechDocsPageHeader'; +import { TechDocsEntityMetadata, TechDocsMetadata } from '../../types'; import { Content, Page } from '@backstage/core-components'; +import { EntityName } from '@backstage/catalog-model'; import { useApi } from '@backstage/core-plugin-api'; -export const TechDocsPage = () => { +type Props = { + withSearch?: boolean; + children?: ({ + techdocsMetadataValue, + entityMetadataValue, + entityId, + }: { + techdocsMetadataValue?: TechDocsMetadata | undefined; + entityMetadataValue?: TechDocsEntityMetadata | undefined; + entityId?: EntityName; + }) => JSX.Element; +}; + +export const TechDocsPage = ({ children, withSearch = true }: Props) => { const [documentReady, setDocumentReady] = useState(false); const { namespace, kind, name } = useParams(); @@ -54,17 +69,22 @@ export const TechDocsPage = () => { return ( - + {children ? ( + children({ + techdocsMetadataValue, + entityMetadataValue, + entityId: { kind, namespace, name }, + }) + ) : ( + + )}