From 3988751087f752fe7e03d7ff371ae439b49b9800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 23 Oct 2023 16:53:13 +0200 Subject: [PATCH] stop returning the entity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- plugins/catalog-react/api-report.md | 1 - .../EntityPresentationApi.ts | 11 -------- .../defaultEntityPresentation.test.ts | 18 ------------- .../defaultEntityPresentation.ts | 8 ------ .../DefaultEntityPresentationApi.test.ts | 26 ------------------- .../DefaultEntityPresentationApi.ts | 2 -- .../General/UserSettingsIdentityCard.tsx | 10 ++----- 7 files changed, 2 insertions(+), 74 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index a1ba49f580..abbf348848 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -416,7 +416,6 @@ export interface EntityRefPresentation { // @public export interface EntityRefPresentationSnapshot { - entity?: Entity | undefined; entityRef: string; Icon?: IconComponent | undefined; primaryTitle: string; diff --git a/plugins/catalog-react/src/apis/EntityPresentationApi/EntityPresentationApi.ts b/plugins/catalog-react/src/apis/EntityPresentationApi/EntityPresentationApi.ts index 17f16d69a4..532fdde9a3 100644 --- a/plugins/catalog-react/src/apis/EntityPresentationApi/EntityPresentationApi.ts +++ b/plugins/catalog-react/src/apis/EntityPresentationApi/EntityPresentationApi.ts @@ -49,17 +49,6 @@ export interface EntityRefPresentationSnapshot { * usable for example for forming a clickable link to the entity. */ entityRef: string; - /** - * The entity that this snapshot represents. - * - * @remarks - * - * Note that this may be a partial entity, i.e. it may not contain all of the - * fields that the kind at hand normally contains, since the input to the - * representation renderer might have been a partial entity. So be careful - * when accessing fields on this. - */ - entity?: Entity | undefined; /** * A string that can be used as a plain representation of the entity, for * example in a header or a link. diff --git a/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.test.ts b/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.test.ts index e875de6fd1..ea755dfebc 100644 --- a/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.test.ts +++ b/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.test.ts @@ -34,7 +34,6 @@ describe('defaultEntityPresentation', () => { }, }), ).toEqual({ - entity: expect.anything(), entityRef: 'component:default/test', primaryTitle: 'test', secondaryTitle: 'component:default/test | type | desc', @@ -56,7 +55,6 @@ describe('defaultEntityPresentation', () => { }, }), ).toEqual({ - entity: expect.anything(), entityRef: 'component:default/test', primaryTitle: 'title', secondaryTitle: 'component:default/test | type | desc', @@ -81,7 +79,6 @@ describe('defaultEntityPresentation', () => { }, }), ).toEqual({ - entity: expect.anything(), entityRef: 'component:default/test', primaryTitle: 'displayName', secondaryTitle: 'component:default/test | type | desc', @@ -96,7 +93,6 @@ describe('defaultEntityPresentation', () => { metadata: { name: 'test' }, } as Entity), ).toEqual({ - entity: expect.anything(), entityRef: 'component:default/test', primaryTitle: 'test', secondaryTitle: 'component:default/test', @@ -108,7 +104,6 @@ describe('defaultEntityPresentation', () => { expect( defaultEntityPresentation({ metadata: 7 } as unknown as Entity), ).toEqual({ - entity: expect.anything(), entityRef: 'unknown:default/unknown', primaryTitle: 'unknown', secondaryTitle: 'unknown:default/unknown', @@ -120,7 +115,6 @@ describe('defaultEntityPresentation', () => { describe('string ref given', () => { it('happy path', () => { expect(defaultEntityPresentation('component:default/test')).toEqual({ - entity: undefined, entityRef: 'component:default/test', primaryTitle: 'test', secondaryTitle: 'component:default/test', @@ -132,7 +126,6 @@ describe('defaultEntityPresentation', () => { defaultKind: 'X', }), ).toEqual({ - entity: undefined, entityRef: 'component:default/test', primaryTitle: 'component:test', secondaryTitle: 'component:default/test', @@ -144,7 +137,6 @@ describe('defaultEntityPresentation', () => { defaultNamespace: 'X', }), ).toEqual({ - entity: undefined, entityRef: 'component:default/test', primaryTitle: 'default/test', secondaryTitle: 'component:default/test', @@ -154,7 +146,6 @@ describe('defaultEntityPresentation', () => { it('works without throwing on malformed and shortened refs', () => { expect(defaultEntityPresentation('')).toEqual({ - entity: undefined, entityRef: 'unknown:default/unknown', primaryTitle: 'unknown', secondaryTitle: 'unknown:default/unknown', @@ -162,7 +153,6 @@ describe('defaultEntityPresentation', () => { }); expect(defaultEntityPresentation('name')).toEqual({ - entity: undefined, entityRef: 'unknown:default/name', primaryTitle: 'name', secondaryTitle: 'unknown:default/name', @@ -180,7 +170,6 @@ describe('defaultEntityPresentation', () => { name: 'test', }), ).toEqual({ - entity: undefined, entityRef: 'component:default/test', primaryTitle: 'test', secondaryTitle: 'component:default/test', @@ -195,7 +184,6 @@ describe('defaultEntityPresentation', () => { }, ), ).toEqual({ - entity: undefined, entityRef: 'component:default/test', primaryTitle: 'component:test', secondaryTitle: 'component:default/test', @@ -210,7 +198,6 @@ describe('defaultEntityPresentation', () => { }, ), ).toEqual({ - entity: undefined, entityRef: 'component:default/test', primaryTitle: 'default/test', secondaryTitle: 'component:default/test', @@ -227,7 +214,6 @@ describe('defaultEntityPresentation', () => { }, ), ).toEqual({ - entity: undefined, entityRef: 'component:default/test', primaryTitle: 'default/test', secondaryTitle: 'component:default/test', @@ -235,7 +221,6 @@ describe('defaultEntityPresentation', () => { }); expect(defaultEntityPresentation('')).toEqual({ - entity: undefined, entityRef: 'unknown:default/unknown', primaryTitle: 'unknown', secondaryTitle: 'unknown:default/unknown', @@ -247,7 +232,6 @@ describe('defaultEntityPresentation', () => { describe('entirely invalid input type given', () => { it('sad path', () => { expect(defaultEntityPresentation(null as unknown as Entity)).toEqual({ - entity: undefined, entityRef: 'unknown:default/unknown', primaryTitle: 'unknown', secondaryTitle: 'unknown:default/unknown', @@ -256,7 +240,6 @@ describe('defaultEntityPresentation', () => { expect(defaultEntityPresentation(undefined as unknown as Entity)).toEqual( { - entity: undefined, entityRef: 'unknown:default/unknown', primaryTitle: 'unknown', secondaryTitle: 'unknown:default/unknown', @@ -267,7 +250,6 @@ describe('defaultEntityPresentation', () => { expect( defaultEntityPresentation(Symbol.for('Prince') as unknown as Entity), ).toEqual({ - entity: undefined, entityRef: 'unknown:default/unknown', primaryTitle: 'unknown', secondaryTitle: 'unknown:default/unknown', diff --git a/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.ts b/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.ts index ab9ea68060..eacb659062 100644 --- a/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.ts +++ b/plugins/catalog-react/src/apis/EntityPresentationApi/defaultEntityPresentation.ts @@ -70,13 +70,6 @@ export function defaultEntityPresentation( (kind && DEFAULT_ICONS[kind.toLocaleLowerCase('en-US')]) || UNKNOWN_KIND_ICON; - const entity: Entity | undefined = - typeof entityOrRef === 'object' && - entityOrRef !== null && - 'metadata' in entityOrRef - ? entityOrRef - : undefined; - const entityRef: string = stringifyEntityRef({ kind: kind || 'unknown', namespace: namespace || DEFAULT_NAMESPACE, @@ -98,7 +91,6 @@ export function defaultEntityPresentation( .join(' | '); return { - entity, entityRef, primaryTitle: primary, secondaryTitle: secondary || undefined, diff --git a/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.test.ts b/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.test.ts index eb20b20f9f..42ff777cbd 100644 --- a/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.test.ts +++ b/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.test.ts @@ -80,7 +80,6 @@ describe('DefaultEntityPresentationApi', () => { expect(api.forEntity(entity)).toEqual({ snapshot: { entityRef: 'component:default/test', - entity: entity, primaryTitle: 'test', secondaryTitle: 'component:default/test | service', Icon: expect.anything(), @@ -120,25 +119,12 @@ describe('DefaultEntityPresentationApi', () => { ).resolves.toEqual([ { entityRef: 'component:default/test', - entity: undefined, primaryTitle: 'test', secondaryTitle: 'component:default/test', Icon: expect.anything(), }, { entityRef: 'component:default/test', - entity: { - apiVersion: 'backstage.io/v1alpha1', - kind: 'Component', - metadata: { - etag: 'something', - name: 'test', - namespace: 'default', - }, - spec: { - type: 'service', - }, - }, primaryTitle: 'test', secondaryTitle: 'component:default/test | service', Icon: expect.anything(), @@ -151,18 +137,6 @@ describe('DefaultEntityPresentationApi', () => { ).resolves.toEqual([ { entityRef: 'component:default/test', - entity: { - apiVersion: 'backstage.io/v1alpha1', - kind: 'Component', - metadata: { - etag: 'something', - name: 'test', - namespace: 'default', - }, - spec: { - type: 'service', - }, - }, primaryTitle: 'test', secondaryTitle: 'component:default/test | service', Icon: expect.anything(), diff --git a/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts b/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts index 24b9b744a0..91e5b575ff 100644 --- a/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts +++ b/plugins/catalog/src/apis/EntityPresentationApi/DefaultEntityPresentationApi.ts @@ -240,7 +240,6 @@ export class DefaultEntityPresentationApi implements EntityPresentationApi { subscriber.next({ ...output.snapshot, entityRef: entityRef, - entity: newEntity, }); } }) @@ -265,7 +264,6 @@ export class DefaultEntityPresentationApi implements EntityPresentationApi { snapshot: { ...rendered, entityRef: entityRef, - entity: entity, }, update$: observable, }; diff --git a/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx b/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx index a398877ce9..d8d3f677aa 100644 --- a/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx +++ b/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx @@ -33,19 +33,13 @@ const Contents = () => { User Entity:{' '} - ref} - /> + Ownership Entities:{' '} - ref} - /> +