TechDocsPage to accept children and withSearch prop

Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
Emma Indal
2021-09-29 14:24:13 +02:00
parent 9bf6fe97cb
commit 0549587ebf
@@ -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<boolean>(false);
const { namespace, kind, name } = useParams();
@@ -54,17 +69,22 @@ export const TechDocsPage = () => {
return (
<Page themeId="documentation">
<TechDocsPageHeader
techDocsMetadata={techdocsMetadataValue}
entityMetadata={entityMetadataValue}
entityId={{
kind,
namespace,
name,
}}
/>
{children ? (
children({
techdocsMetadataValue,
entityMetadataValue,
entityId: { kind, namespace, name },
})
) : (
<TechDocsPageHeader
techDocsMetadata={techdocsMetadataValue}
entityMetadata={entityMetadataValue}
entityId={{ kind, namespace, name }}
/>
)}
<Content data-testid="techdocs-content">
<Reader
withSearch={withSearch}
onReady={onReady}
entityId={{
kind,