From 208976022b21f5fcafbaa98cde0f648211c454e9 Mon Sep 17 00:00:00 2001 From: "roylisto.pradana" Date: Tue, 29 Jun 2021 17:52:38 +0700 Subject: [PATCH 1/6] add displayName option for Groups diagram Signed-off-by: roylisto.pradana --- .../GroupsExplorerContent/GroupsDiagram.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx index 53e55b96bf..27be0dae7e 100644 --- a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx +++ b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx @@ -96,7 +96,9 @@ function RenderNode(props: DependencyGraphTypes.RenderNodeProps) { alignmentBaseline="baseline" style={{ fontWeight: 'bold' }} > - {props.node.name} + {props.node.profile?.displayName + ? props.node.profile?.displayName + : props.node.name} @@ -107,7 +109,12 @@ function RenderNode(props: DependencyGraphTypes.RenderNodeProps) { * Dynamically generates a diagram of groups registered in the catalog. */ export function GroupsDiagram() { - const nodes = new Array<{ id: string; kind: string; name: string }>(); + const nodes = new Array<{ + id: string; + kind: string; + name: string; + profile?: any; + }>(); const edges = new Array<{ from: string; to: string; label: string }>(); const configApi = useApi(configApiRef); @@ -142,6 +149,7 @@ export function GroupsDiagram() { id: stringifyEntityRef(catalogItem), kind: catalogItem.kind, name: formatEntityRefTitle(catalogItem, { defaultKind: 'Group' }), + profile: catalogItem.spec?.profile, }); // Edge to parent From c0bd924ebb2e22ad0ab829cfc79422f24efe1877 Mon Sep 17 00:00:00 2001 From: "roylisto.pradana" Date: Tue, 29 Jun 2021 18:35:46 +0700 Subject: [PATCH 2/6] Fix the test file Signed-off-by: roylisto.pradana --- .../components/GroupsExplorerContent/GroupsDiagram.test.tsx | 5 ++++- .../src/components/GroupsExplorerContent/GroupsDiagram.tsx | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.test.tsx b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.test.tsx index 5044b09f83..3b9b523b02 100644 --- a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.test.tsx +++ b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.test.tsx @@ -46,6 +46,9 @@ describe('', () => { namespace: 'my-namespace', }, spec: { + profile: { + displayName: 'Group A', + }, type: 'organization', }, }, @@ -64,6 +67,6 @@ describe('', () => { }, ); - expect(getByText('my-namespace/group-a')).toBeInTheDocument(); + expect(getByText('Group A')).toBeInTheDocument(); }); }); diff --git a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx index 27be0dae7e..32931e8f3a 100644 --- a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx +++ b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx @@ -96,9 +96,7 @@ function RenderNode(props: DependencyGraphTypes.RenderNodeProps) { alignmentBaseline="baseline" style={{ fontWeight: 'bold' }} > - {props.node.profile?.displayName - ? props.node.profile?.displayName - : props.node.name} + {props.node.profile?.displayName ?? props.node.name} From dd91185744c8b7765712b10dd812840290c577e2 Mon Sep 17 00:00:00 2001 From: "roylisto.pradana" Date: Tue, 29 Jun 2021 18:45:45 +0700 Subject: [PATCH 3/6] Add changeset Signed-off-by: roylisto.pradana --- .changeset/pretty-needles-peel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pretty-needles-peel.md diff --git a/.changeset/pretty-needles-peel.md b/.changeset/pretty-needles-peel.md new file mode 100644 index 0000000000..00dcc63a7d --- /dev/null +++ b/.changeset/pretty-needles-peel.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-explore': minor +--- + +Using displayName as default value when loading Groups Diagram From 64c7561dc857c93dcb57ba011b70ce15e774e261 Mon Sep 17 00:00:00 2001 From: "roylisto.pradana" Date: Tue, 29 Jun 2021 19:14:04 +0700 Subject: [PATCH 4/6] change minor to patch for changeset Signed-off-by: roylisto.pradana --- .changeset/pretty-needles-peel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pretty-needles-peel.md b/.changeset/pretty-needles-peel.md index 00dcc63a7d..4e77ef7cd3 100644 --- a/.changeset/pretty-needles-peel.md +++ b/.changeset/pretty-needles-peel.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-explore': minor +'@backstage/plugin-explore': patch --- Using displayName as default value when loading Groups Diagram From c991df871f8b24544f82a58160746f90a4f6ce04 Mon Sep 17 00:00:00 2001 From: "roylisto.pradana" Date: Wed, 30 Jun 2021 10:27:16 +0700 Subject: [PATCH 5/6] use GroupEntity as casting to catalogItem Signed-off-by: roylisto.pradana --- .../components/GroupsExplorerContent/GroupsDiagram.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx index 32931e8f3a..28de4e4661 100644 --- a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx +++ b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx @@ -18,6 +18,7 @@ import { RELATION_CHILD_OF, stringifyEntityRef, parseEntityRef, + GroupEntity, } from '@backstage/catalog-model'; import { catalogApiRef, @@ -96,7 +97,7 @@ function RenderNode(props: DependencyGraphTypes.RenderNodeProps) { alignmentBaseline="baseline" style={{ fontWeight: 'bold' }} > - {props.node.profile?.displayName ?? props.node.name} + {props.node.name} @@ -146,8 +147,9 @@ export function GroupsDiagram() { nodes.push({ id: stringifyEntityRef(catalogItem), kind: catalogItem.kind, - name: formatEntityRefTitle(catalogItem, { defaultKind: 'Group' }), - profile: catalogItem.spec?.profile, + name: + (catalogItem as GroupEntity).spec?.profile?.displayName || + formatEntityRefTitle(catalogItem, { defaultKind: 'Group' }), }); // Edge to parent From 3fb229ec6339572ea0f11a529142224b445ceb7e Mon Sep 17 00:00:00 2001 From: "roylisto.pradana" Date: Wed, 30 Jun 2021 15:25:16 +0700 Subject: [PATCH 6/6] Remove profile var Signed-off-by: roylisto.pradana --- .../src/components/GroupsExplorerContent/GroupsDiagram.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx index 28de4e4661..ce09f0d268 100644 --- a/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx +++ b/plugins/explore/src/components/GroupsExplorerContent/GroupsDiagram.tsx @@ -112,7 +112,6 @@ export function GroupsDiagram() { id: string; kind: string; name: string; - profile?: any; }>(); const edges = new Array<{ from: string; to: string; label: string }>();