fix(OwnershipCard): correctly link to owner filtered catalog respecting namespaces
Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-org': patch
|
||||
---
|
||||
|
||||
Fix linking ownership card to catalog owner filter when namespaces are used
|
||||
@@ -265,6 +265,10 @@ describe('OwnershipCard', () => {
|
||||
type: 'memberOf',
|
||||
targetRef: 'group:default/my-team',
|
||||
},
|
||||
{
|
||||
type: 'memberOf',
|
||||
targetRef: 'group:custom/some-team',
|
||||
},
|
||||
],
|
||||
};
|
||||
const catalogApi: jest.Mocked<CatalogApi> = {
|
||||
@@ -288,7 +292,7 @@ describe('OwnershipCard', () => {
|
||||
|
||||
expect(getByText('OPENAPI').closest('a')).toHaveAttribute(
|
||||
'href',
|
||||
'/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=the-user&filters%5Bowners%5D=my-team&filters%5Buser%5D=all',
|
||||
'/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=user%3Athe-user&filters%5Bowners%5D=my-team&filters%5Bowners%5D=custom%2Fsome-team&filters%5Buser%5D=all',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -18,12 +18,14 @@ import {
|
||||
Entity,
|
||||
RELATION_MEMBER_OF,
|
||||
RELATION_PARENT_OF,
|
||||
parseEntityRef,
|
||||
stringifyEntityRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
getEntityRelations,
|
||||
humanizeEntityRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import limiterFactory from 'p-limit';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
@@ -43,7 +45,9 @@ const getQueryParams = (
|
||||
selectedEntity: EntityTypeProps,
|
||||
): string => {
|
||||
const { kind, type } = selectedEntity;
|
||||
const owners = ownersEntityRef.map(owner => owner.split('/')[1]);
|
||||
const owners = ownersEntityRef.map(owner =>
|
||||
humanizeEntityRef(parseEntityRef(owner), { defaultKind: 'group' }),
|
||||
);
|
||||
const filters = {
|
||||
kind,
|
||||
type,
|
||||
|
||||
Reference in New Issue
Block a user