diff --git a/.changeset/replace-humanize-entity-ref-org.md b/.changeset/replace-humanize-entity-ref-org.md new file mode 100644 index 0000000000..f2edfdf48a --- /dev/null +++ b/.changeset/replace-humanize-entity-ref-org.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-org': patch +--- + +Replaced deprecated `humanizeEntityRef` usage with the Catalog Presentation API. diff --git a/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.test.ts b/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.test.ts index d7ee61b714..caa657b16d 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.test.ts +++ b/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.test.ts @@ -50,7 +50,6 @@ jest.mock('@backstage/plugin-catalog-react', () => { return { catalogApiRef: {}, entityPresentationSnapshot: actual.entityPresentationSnapshot, - humanizeEntityRef: actual.humanizeEntityRef, getEntityRelations: jest.fn(entity => { return getEntityRelationsMock(entity); }) as any, @@ -291,6 +290,7 @@ describe('useGetEntities', () => { afterEach(() => { getEntityRelationsMock.mockRestore(); catalogApi.getEntities.mockRestore(); + catalogApi.getEntitiesByRefs.mockRestore(); }); it('should produce query params with humanized entity refs as owners', async () => { diff --git a/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts b/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts index 56c1e8cebd..9a98ad788e 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts +++ b/plugins/org/src/components/Cards/OwnershipCard/useGetEntities.ts @@ -16,7 +16,6 @@ import { Entity, - parseEntityRef, RELATION_MEMBER_OF, RELATION_PARENT_OF, stringifyEntityRef, @@ -24,8 +23,8 @@ import { import { CatalogApi, catalogApiRef, + entityPresentationSnapshot, getEntityRelations, - humanizeEntityRef, } from '@backstage/plugin-catalog-react'; import limiterFactory from 'p-limit'; import { useApi } from '@backstage/core-plugin-api'; @@ -47,8 +46,9 @@ const getQueryParams = ( selectedEntity: EntityTypeProps, ): string => { const { kind, type } = selectedEntity; - const owners = ownersEntityRef.map(owner => - humanizeEntityRef(parseEntityRef(owner), { defaultKind: 'group' }), + const owners = ownersEntityRef.map( + ref => + entityPresentationSnapshot(ref, { defaultKind: 'group' }).primaryTitle, ); const filters = { kind: kind.toLocaleLowerCase('en-US'),