From f1f59b13e1cc1711b5790f02af106e128dd39417 Mon Sep 17 00:00:00 2001 From: Marat Dyatko Date: Thu, 9 Apr 2026 10:40:21 +0200 Subject: [PATCH] fix(org): replace deprecated humanizeEntityRef with Catalog Presentation API Replace `humanizeEntityRef(parseEntityRef(owner), { defaultKind: 'group' })` with `entityPresentationSnapshot(ref, { defaultKind: 'group' }).primaryTitle` in the OwnershipCard's `useGetEntities` hook. This was the last remaining usage of the deprecated function in the codebase. Signed-off-by: Marat Dyatko Made-with: Cursor Signed-off-by: Marat Dyatko Made-with: Cursor Signed-off-by: Marat Dyatko Made-with: Cursor --- .changeset/replace-humanize-entity-ref-org.md | 5 +++++ .../components/Cards/OwnershipCard/useGetEntities.test.ts | 2 +- .../src/components/Cards/OwnershipCard/useGetEntities.ts | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changeset/replace-humanize-entity-ref-org.md 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'),