diff --git a/.changeset/shiny-turkeys-doubt.md b/.changeset/shiny-turkeys-doubt.md new file mode 100644 index 0000000000..0f663a4c74 --- /dev/null +++ b/.changeset/shiny-turkeys-doubt.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-org': patch +--- + +Render namespaced teams within dropdown items in `MyGroupsSidebarItem` diff --git a/plugins/org/src/components/MyGroupsSidebarItem/MyGroupsSidebarItem.tsx b/plugins/org/src/components/MyGroupsSidebarItem/MyGroupsSidebarItem.tsx index fa8f8405ff..445bf8e6fe 100644 --- a/plugins/org/src/components/MyGroupsSidebarItem/MyGroupsSidebarItem.tsx +++ b/plugins/org/src/components/MyGroupsSidebarItem/MyGroupsSidebarItem.tsx @@ -15,7 +15,11 @@ */ import React from 'react'; -import { stringifyEntityRef } from '@backstage/catalog-model'; +import { + DEFAULT_NAMESPACE, + Entity, + stringifyEntityRef, +} from '@backstage/catalog-model'; import { SidebarItem, SidebarSubmenu, @@ -32,7 +36,6 @@ import { catalogApiRef, CatalogApi, entityRouteRef, - humanizeEntityRef, } from '@backstage/plugin-catalog-react'; import { getCompoundEntityRef } from '@backstage/catalog-model'; @@ -87,23 +90,42 @@ export const MyGroupsSidebarItem = (props: { ); } + const namespacedGroupsMap: { [namespace: string]: Entity[] } = {}; + groups.forEach(group => { + namespacedGroupsMap[group.metadata.namespace!] = + namespacedGroupsMap[group.metadata.namespace!] ?? []; + namespacedGroupsMap[group.metadata.namespace!].push(group); + }); + // Member of more than one group return ( - {groups?.map(function groupsMap(group) { + {namespacedGroupsMap[DEFAULT_NAMESPACE]?.map(group => { return ( ); })} + {Object.entries(namespacedGroupsMap) + .filter(([n]) => n !== DEFAULT_NAMESPACE) + .map(([namespace, namespacedGroups]) => { + return ( + ({ + title: group.metadata.title || group.metadata.name, + to: catalogEntityRoute(getCompoundEntityRef(group)), + }))} + /> + ); + })} );