From 2b27e49eb1bba6f2d02ef6d729e7d6d89791188b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 15 Jan 2022 16:47:39 +0100 Subject: [PATCH] catalog,catalog-backend: update to catalog-model status change Signed-off-by: Patrik Oldsberg --- .changeset/wicked-bobcats-pull.md | 6 ++++++ plugins/catalog-backend/src/stitching/Stitcher.ts | 8 ++++---- .../EntityProcessingErrorsPanel.test.tsx | 8 ++++---- .../EntityProcessingErrorsPanel.tsx | 7 ++++--- 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 .changeset/wicked-bobcats-pull.md diff --git a/.changeset/wicked-bobcats-pull.md b/.changeset/wicked-bobcats-pull.md new file mode 100644 index 0000000000..a2af286044 --- /dev/null +++ b/.changeset/wicked-bobcats-pull.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog': patch +'@backstage/plugin-catalog-backend': patch +--- + +Internal update to match status field changes in `@backstage/catalog-model`. diff --git a/plugins/catalog-backend/src/stitching/Stitcher.ts b/plugins/catalog-backend/src/stitching/Stitcher.ts index b4a693a4fa..9ec028ed35 100644 --- a/plugins/catalog-backend/src/stitching/Stitcher.ts +++ b/plugins/catalog-backend/src/stitching/Stitcher.ts @@ -16,9 +16,9 @@ import { ENTITY_STATUS_CATALOG_PROCESSING_TYPE } from '@backstage/catalog-client'; import { - Entity, + AlphaEntity, parseEntityRef, - UNSTABLE_EntityStatusItem, + EntityStatusItem, } from '@backstage/catalog-model'; import { SerializedError, stringifyError } from '@backstage/errors'; import { Knex } from 'knex'; @@ -152,9 +152,9 @@ export class Stitcher { // Grab the processed entity and stitch all of the relevant data into // it - const entity = JSON.parse(processedEntity) as Entity; + const entity = JSON.parse(processedEntity) as AlphaEntity; const isOrphan = Number(incomingReferenceCount) === 0; - let statusItems: UNSTABLE_EntityStatusItem[] = []; + let statusItems: EntityStatusItem[] = []; if (isOrphan) { this.logger.debug(`${entityRef} is an orphan`); diff --git a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx index fcc4475f6a..ae5a4684b1 100644 --- a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx +++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx @@ -24,7 +24,7 @@ import { import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils'; import React from 'react'; import { EntityProcessingErrorsPanel } from './EntityProcessingErrorsPanel'; -import { Entity, getEntityName } from '@backstage/catalog-model'; +import { AlphaEntity, getEntityName } from '@backstage/catalog-model'; import { ApiProvider } from '@backstage/core-app-api'; describe('', () => { @@ -34,7 +34,7 @@ describe('', () => { const apis = TestApiRegistry.from([catalogApiRef, { getEntityAncestors }]); it('renders EntityProcessErrors if the entity has errors', async () => { - const entity: Entity = { + const entity: AlphaEntity = { apiVersion: 'v1', kind: 'Component', metadata: { @@ -122,7 +122,7 @@ describe('', () => { }); it('renders EntityProcessErrors if the parent entity has errors', async () => { - const entity: Entity = { + const entity: AlphaEntity = { apiVersion: 'v1', kind: 'Component', metadata: { @@ -136,7 +136,7 @@ describe('', () => { }, }; - const parent: Entity = { + const parent: AlphaEntity = { apiVersion: 'v1', kind: 'Component', metadata: { diff --git a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx index 8469c7d4e4..e4df011b38 100644 --- a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx +++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx @@ -16,8 +16,9 @@ import { Entity, + AlphaEntity, stringifyEntityRef, - UNSTABLE_EntityStatusItem, + EntityStatusItem, compareEntityToRef, } from '@backstage/catalog-model'; import { @@ -36,7 +37,7 @@ import { useApi, ApiHolder } from '@backstage/core-plugin-api'; import useAsync from 'react-use/lib/useAsync'; import { SerializedError } from '@backstage/errors'; -const errorFilter = (i: UNSTABLE_EntityStatusItem) => +const errorFilter = (i: EntityStatusItem) => i.error && i.level === 'error' && i.type === ENTITY_STATUS_CATALOG_PROCESSING_TYPE; @@ -55,7 +56,7 @@ async function getOwnAndAncestorsErrors( const ancestors = await catalogApi.getEntityAncestors({ entityRef }); const items = ancestors.items .map(item => { - const statuses = item.entity.status?.items ?? []; + const statuses = (item.entity as AlphaEntity).status?.items ?? []; const errors = statuses .filter(errorFilter) .map(e => e.error)