From f37cf4599c6c1e1feafd0d814104a0b2e2f75600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Tue, 4 May 2021 23:17:45 +0200 Subject: [PATCH] Use formatEntityRefTitle to format node titles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Gomez --- .../OrganizationDiagram.tsx | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/plugins/explore/src/components/OrganizationExplorerContent/OrganizationDiagram.tsx b/plugins/explore/src/components/OrganizationExplorerContent/OrganizationDiagram.tsx index 4e0d3710f3..e3a6826835 100644 --- a/plugins/explore/src/components/OrganizationExplorerContent/OrganizationDiagram.tsx +++ b/plugins/explore/src/components/OrganizationExplorerContent/OrganizationDiagram.tsx @@ -15,16 +15,15 @@ */ import { - Entity, RELATION_CHILD_OF, stringifyEntityRef, - ENTITY_DEFAULT_NAMESPACE, parseEntityRef, } from '@backstage/catalog-model'; import { catalogApiRef, entityRouteRef, getEntityRelations, + formatEntityRefTitle, } from '@backstage/plugin-catalog-react'; import { DependencyGraph, @@ -53,22 +52,6 @@ const useStyles = makeStyles((theme: BackstageTheme) => ({ }, })); -// Simplifies the diagram output by hiding the default namespace and kind -function readableEntityName( - ref: - | Entity - | { - kind: string; - namespace?: string; - name: string; - }, -): string { - return stringifyEntityRef(ref) - .toLocaleLowerCase('en-US') - .replace(`:${ENTITY_DEFAULT_NAMESPACE}/`, ':') - .split(':')[1]; -} - function RenderNode(props: DependencyGraphTypes.RenderNodeProps) { const classes = useStyles(); const catalogEntityRoute = useRouteRef(entityRouteRef); @@ -159,7 +142,7 @@ export function OrganizationDiagram() { nodes.push({ id: stringifyEntityRef(catalogItem), kind: catalogItem.kind, - name: readableEntityName(catalogItem), + name: formatEntityRefTitle(catalogItem, { defaultKind: 'Group' }), }); // Edge to parent