fix(#20232): load relations to get children of children and fix the display of OwnershipCard with aggregated relations.

Signed-off-by: vdizengremel <victor.dizengremel@octo.com>
This commit is contained in:
vdizengremel
2023-09-29 13:10:02 +02:00
parent b5b00b3af1
commit dc5b6b971b
3 changed files with 15 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-org': patch
---
Fixed the display of OwnershipCard with aggregated relations by loading relations when getting children of entity.
This allows the already existing recursive method to work properly when children of entity have children themselves.
@@ -110,6 +110,14 @@ describe('useGetEntities', () => {
);
});
it('given group entity should retrieve child with their relations', async () => {
await whenHookIsCalledWith(givenParentGroupEntity);
expect(catalogApiMock.getEntitiesByRefs).toHaveBeenCalledWith({
entityRefs: [`group:default/${givenLeafGroup}`],
fields: ['kind', 'metadata.namespace', 'metadata.name', 'relations'],
});
});
it('given user entity should aggregate parent ownership and direct', async () => {
await whenHookIsCalledWith(givenUserEntity);
expect(catalogApiMock.getEntities).toHaveBeenCalledWith(
@@ -90,7 +90,7 @@ const getChildOwnershipEntityRefs = async (
if (hasChildGroups) {
const entityRefs = childGroups.map(r => stringifyEntityRef(r));
const childGroupResponse = await catalogApi.getEntitiesByRefs({
fields: ['kind', 'metadata.namespace', 'metadata.name'],
fields: ['kind', 'metadata.namespace', 'metadata.name', 'relations'],
entityRefs,
});
const childGroupEntities = childGroupResponse.items.filter(isEntity);