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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user