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 <maratd@spotify.com>
Made-with: Cursor
Signed-off-by: Marat Dyatko <maratd@spotify.com>
Made-with: Cursor
Signed-off-by: Marat Dyatko <maratd@spotify.com>
Made-with: Cursor
This commit is contained in:
Marat Dyatko
2026-04-09 10:40:21 +02:00
parent 09e17c8a65
commit f1f59b13e1
3 changed files with 10 additions and 5 deletions
@@ -0,0 +1,5 @@
---
'@backstage/plugin-org': patch
---
Replaced deprecated `humanizeEntityRef` usage with the Catalog Presentation API.
@@ -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 () => {
@@ -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'),