diff --git a/plugins/catalog/src/components/EntityProcessErrors/EntityProcessErrors.test.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx
similarity index 72%
rename from plugins/catalog/src/components/EntityProcessErrors/EntityProcessErrors.test.tsx
rename to plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx
index 28f4f92a27..a4e284a0eb 100644
--- a/plugins/catalog/src/components/EntityProcessErrors/EntityProcessErrors.test.tsx
+++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx
@@ -18,9 +18,8 @@ import { EntityProvider } from '@backstage/plugin-catalog-react';
import { renderInTestApp } from '@backstage/test-utils';
import React from 'react';
-import { EntityProcessErrors } from './EntityProcessErrors';
+import { EntityProcessingErrorsPanel } from './EntityProcessingErrorsPanel';
import { Entity } from '@backstage/catalog-model';
-import { waitFor } from '@testing-library/react';
describe('', () => {
it('renders EntityProcessErrors if the entity has errors', async () => {
@@ -55,6 +54,20 @@ describe('', () => {
},
},
},
+ {
+ type: 'foo',
+ level: 'error',
+ message: 'InputError: This should not be rendered',
+ error: {
+ name: 'InputError',
+ message: 'Foo',
+ cause: {
+ name: 'Error',
+ message:
+ 'Malformed envelope, /metadata/labels should be object',
+ },
+ },
+ },
{
type: 'backstage.io/catalog-processing',
level: 'error',
@@ -73,19 +86,18 @@ describe('', () => {
},
};
- const { getByText } = await renderInTestApp(
+ const { getByText, queryByText } = await renderInTestApp(
-
+
,
);
- await waitFor(() => {
- expect(
- getByText(
- 'Error: Policy check failed; caused by Error: Malformed envelope, /metadata/labels should be object',
- ),
- ).toBeInTheDocument();
- expect(getByText('Error: Foo')).toBeInTheDocument();
- });
+ expect(
+ getByText(
+ 'Error: Policy check failed; caused by Error: Malformed envelope, /metadata/labels should be object',
+ ),
+ ).toBeInTheDocument();
+ expect(getByText('Error: Foo')).toBeInTheDocument();
+ expect(queryByText('Error: This should not be rendered')).toBeNull();
});
});
diff --git a/plugins/catalog/src/components/EntityProcessErrors/EntityProcessErrors.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx
similarity index 53%
rename from plugins/catalog/src/components/EntityProcessErrors/EntityProcessErrors.tsx
rename to plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx
index 3d1210290a..565ffc30e3 100644
--- a/plugins/catalog/src/components/EntityProcessErrors/EntityProcessErrors.tsx
+++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx
@@ -14,30 +14,38 @@
* limitations under the License.
*/
-import { Entity } from '@backstage/catalog-model';
+import { Entity, UNSTABLE_EntityStatusItem } from '@backstage/catalog-model';
import { useEntity } from '@backstage/plugin-catalog-react';
import { Box } from '@material-ui/core';
import React from 'react';
import { ResponseErrorPanel } from '@backstage/core-components';
+import { ENTITY_STATUS_CATALOG_PROCESSING_TYPE } from '../../../../../packages/catalog-client/src';
-export const hasErrors = (entity: Entity) => entity?.status?.items?.length! > 0;
+const errorfilter = (i: UNSTABLE_EntityStatusItem) =>
+ i.error &&
+ i.level === 'error' &&
+ i.type === ENTITY_STATUS_CATALOG_PROCESSING_TYPE;
+
+export const hasCatalogProcessingErrors = (entity: Entity) =>
+ entity?.status?.items?.filter(errorfilter).length! > 0;
/**
* Displays a list of errors if the entity is invalid.
*/
-export const EntityProcessErrors = () => {
+export const EntityProcessingErrorsPanel = () => {
const { entity } = useEntity();
+ const catalogProcessingErrors =
+ (entity?.status?.items?.filter(
+ errorfilter,
+ ) as Required[]) || [];
return (
<>
- {entity?.status?.items?.map(
- ({ error }, index) =>
- error && (
-
-
-
- ),
- )}
+ {catalogProcessingErrors.map(({ error }, index) => (
+
+
+
+ ))}
>
);
};
diff --git a/plugins/catalog/src/components/EntityProcessErrors/index.ts b/plugins/catalog/src/components/EntityProcessingErrorsPanel/index.ts
similarity index 84%
rename from plugins/catalog/src/components/EntityProcessErrors/index.ts
rename to plugins/catalog/src/components/EntityProcessingErrorsPanel/index.ts
index 10d6d04ed2..1af2c80484 100644
--- a/plugins/catalog/src/components/EntityProcessErrors/index.ts
+++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/index.ts
@@ -14,4 +14,7 @@
* limitations under the License.
*/
-export { EntityProcessErrors, hasErrors } from './EntityProcessErrors';
+export {
+ EntityProcessingErrorsPanel,
+ hasCatalogProcessingErrors,
+} from './EntityProcessingErrorsPanel';
diff --git a/plugins/catalog/src/index.ts b/plugins/catalog/src/index.ts
index 6934843228..fd542fafa3 100644
--- a/plugins/catalog/src/index.ts
+++ b/plugins/catalog/src/index.ts
@@ -23,7 +23,7 @@ export * from './components/CatalogTable/columns';
export * from './components/CreateComponentButton';
export * from './components/EntityLayout';
export * from './components/EntityOrphanWarning';
-export * from './components/EntityProcessErrors';
+export * from './components/EntityProcessingErrorsPanel';
export * from './components/EntityPageLayout';
export * from './components/EntitySwitch';
export * from './components/FilteredEntityLayout';