fix(techdocs): entity page links

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2022-03-31 08:45:15 +02:00
committed by Emma Indal
parent e0dc1e8ccd
commit 5ad229a24b
4 changed files with 29 additions and 37 deletions
+1
View File
@@ -38,6 +38,7 @@
"@backstage/catalog-model": "^1.0.1-next.1",
"@backstage/config": "^1.0.0",
"@backstage/core-components": "^0.9.3-next.1",
"@backstage/core-app-api": "^1.0.0",
"@backstage/core-plugin-api": "^1.0.0",
"@backstage/errors": "^1.0.0",
"@backstage/integration": "^1.1.0-next.1",
+2 -13
View File
@@ -16,26 +16,15 @@
import React from 'react';
import { configApiRef, useApi } from '@backstage/core-plugin-api';
import { DEFAULT_NAMESPACE, Entity } from '@backstage/catalog-model';
import { Entity, getCompoundEntityRef } from '@backstage/catalog-model';
import { toLowerMaybe } from './helpers';
import { TechDocsReaderPage } from './plugin';
import { TechDocsReaderLayout } from './reader';
type EntityPageDocsProps = { entity: Entity };
export const EntityPageDocs = ({ entity }: EntityPageDocsProps) => {
const config = useApi(configApiRef);
const entityName = {
namespace: toLowerMaybe(
entity.metadata.namespace ?? DEFAULT_NAMESPACE,
config,
),
kind: toLowerMaybe(entity.kind, config),
name: toLowerMaybe(entity.metadata.name, config),
};
const entityName = getCompoundEntityRef(entity);
return (
<TechDocsReaderPage entityName={entityName}>
+9 -6
View File
@@ -15,13 +15,16 @@
*/
import React, { PropsWithChildren } from 'react';
import { Entity } from '@backstage/catalog-model';
import { useEntity } from '@backstage/plugin-catalog-react';
import { Route, Routes } from 'react-router-dom';
import { Entity } from '@backstage/catalog-model';
import { FlatRoutes } from '@backstage/core-app-api';
import { useEntity } from '@backstage/plugin-catalog-react';
import { MissingAnnotationEmptyState } from '@backstage/core-components';
import { EntityPageDocs } from './EntityPageDocs';
import { TechDocsIndexPage } from './home/components/TechDocsIndexPage';
import { TechDocsReaderPage } from './reader/components/TechDocsReaderPage';
import { EntityPageDocs } from './EntityPageDocs';
import { MissingAnnotationEmptyState } from '@backstage/core-components';
const TECHDOCS_ANNOTATION = 'backstage.io/techdocs-ref';
@@ -66,10 +69,10 @@ export const EmbeddedDocsRouter = (props: PropsWithChildren<{}>) => {
}
return (
<Routes>
<FlatRoutes>
<Route path="/*" element={<EntityPageDocs entity={entity} />}>
{children}
</Route>
</Routes>
</FlatRoutes>
);
};