From 5479e4eef0d82efbc348a901d17a6c50f6a09aa3 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Tue, 2 Feb 2021 23:27:20 -0500 Subject: [PATCH 1/7] Improve display of errors --- .../components/ApiExplorerTable/ApiExplorerTable.tsx | 10 ++++------ .../src/components/CatalogTable/CatalogTable.tsx | 12 +++++++----- .../lighthouse/src/components/AuditList/index.tsx | 6 +++--- .../techdocs/src/reader/components/TechDocsHome.tsx | 8 +++++++- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx index 101c28332a..743366bdcd 100644 --- a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx +++ b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx @@ -27,6 +27,7 @@ import { TableFilter, TableState, useQueryParamState, + WarningPanel, } from '@backstage/core'; import { EntityRefLink, @@ -35,7 +36,6 @@ import { getEntityRelations, } from '@backstage/plugin-catalog-react'; import { Chip } from '@material-ui/core'; -import { Alert } from '@material-ui/lab'; import React from 'react'; import { ApiTypeTitle } from '../ApiDefinitionCard'; @@ -151,11 +151,9 @@ export const ApiExplorerTable = ({ if (error) { return ( -
- - Error encountered while fetching catalog entities. {error.toString()} - -
+ + {error.toString()} + ); } diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index 30a19145f2..97c7ccfa18 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -19,7 +19,7 @@ import { RELATION_OWNED_BY, RELATION_PART_OF, } from '@backstage/catalog-model'; -import { Table, TableColumn, TableProps } from '@backstage/core'; +import { Table, TableColumn, TableProps, WarningPanel } from '@backstage/core'; import { EntityRefLink, EntityRefLinks, @@ -29,7 +29,6 @@ import { import { Chip } from '@material-ui/core'; import Edit from '@material-ui/icons/Edit'; import OpenInNew from '@material-ui/icons/OpenInNew'; -import { Alert } from '@material-ui/lab'; import React from 'react'; import { findLocationForEntityMeta } from '../../data/utils'; import { useStarredEntities } from '../../hooks/useStarredEntities'; @@ -128,9 +127,12 @@ export const CatalogTable = ({ if (error) { return (
- - Error encountered while fetching catalog entities. {error.toString()} - + + {error.toString()} +
); } diff --git a/plugins/lighthouse/src/components/AuditList/index.tsx b/plugins/lighthouse/src/components/AuditList/index.tsx index ce0fcdb46e..8d7f769909 100644 --- a/plugins/lighthouse/src/components/AuditList/index.tsx +++ b/plugins/lighthouse/src/components/AuditList/index.tsx @@ -17,7 +17,6 @@ import React, { useState, useMemo, ReactNode } from 'react'; import { useLocalStorage, useAsync } from 'react-use'; import { useNavigate } from 'react-router-dom'; import { Grid, Button } from '@material-ui/core'; -import Alert from '@material-ui/lab/Alert'; import Pagination from '@material-ui/lab/Pagination'; import { InfoCard, @@ -28,6 +27,7 @@ import { HeaderLabel, Progress, useApi, + WarningPanel, } from '@backstage/core'; import { lighthouseApiRef } from '../../api'; @@ -85,9 +85,9 @@ const AuditList = () => { content = ; } else if (error) { content = ( - + {error.message} - + ); } diff --git a/plugins/techdocs/src/reader/components/TechDocsHome.tsx b/plugins/techdocs/src/reader/components/TechDocsHome.tsx index 2d8b5c7dcc..f2317f0b43 100644 --- a/plugins/techdocs/src/reader/components/TechDocsHome.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsHome.tsx @@ -21,6 +21,7 @@ import { Page, Progress, useApi, + WarningPanel, } from '@backstage/core'; import { catalogApiRef } from '@backstage/plugin-catalog-react'; import { Grid } from '@material-ui/core'; @@ -62,7 +63,12 @@ export const TechDocsHome = () => { subtitle="Documentation available in Backstage" /> -

{error.message}

+ + {error.message} +
); From f5e564cd67239fdbc187f1e05402ea9df66f02f8 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Tue, 2 Feb 2021 23:28:06 -0500 Subject: [PATCH 2/7] Add changeset --- .changeset/hot-pants-taste.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/hot-pants-taste.md diff --git a/.changeset/hot-pants-taste.md b/.changeset/hot-pants-taste.md new file mode 100644 index 0000000000..5cce26c5bf --- /dev/null +++ b/.changeset/hot-pants-taste.md @@ -0,0 +1,8 @@ +--- +'@backstage/plugin-api-docs': patch +'@backstage/plugin-catalog': patch +'@backstage/plugin-lighthouse': patch +'@backstage/plugin-techdocs': patch +--- + +Improve display of error messages From 2b9d16b39772d9d11972916a92ee8a2255346ee7 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Tue, 2 Feb 2021 23:32:06 -0500 Subject: [PATCH 3/7] Add period for consistency in error msg --- plugins/techdocs/src/reader/components/TechDocsHome.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs/src/reader/components/TechDocsHome.tsx b/plugins/techdocs/src/reader/components/TechDocsHome.tsx index f2317f0b43..d5d3af67cb 100644 --- a/plugins/techdocs/src/reader/components/TechDocsHome.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsHome.tsx @@ -65,7 +65,7 @@ export const TechDocsHome = () => { {error.message} From 81a039cc9fcaefdc9723815f1a4e41dfd76df10e Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Tue, 2 Feb 2021 23:49:15 -0500 Subject: [PATCH 4/7] Fix test --- .../catalog/src/components/CatalogTable/CatalogTable.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx index 46d6010f2f..16c91c0d6c 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx @@ -50,7 +50,7 @@ describe('CatalogTable component', () => { ), ); const errorMessage = await rendered.findByText( - /Error encountered while fetching catalog entities./, + /Could not fetch catalog entities./, ); expect(errorMessage).toBeInTheDocument(); }); From c0ddb3256339ffad3657fb509a9e3b8c1646fdaa Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Wed, 3 Feb 2021 00:02:50 -0500 Subject: [PATCH 5/7] Fix tests --- .../src/components/ApiExplorerTable/ApiExplorerTable.test.tsx | 2 +- plugins/lighthouse/src/components/AuditList/index.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.test.tsx b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.test.tsx index 494695e277..bcb310be46 100644 --- a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.test.tsx +++ b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.test.tsx @@ -61,7 +61,7 @@ describe('ApiCatalogTable component', () => { ), ); const errorMessage = await rendered.findByText( - /Error encountered while fetching catalog entities./, + /Could not fetch catalog entities./, ); expect(errorMessage).toBeInTheDocument(); }); diff --git a/plugins/lighthouse/src/components/AuditList/index.test.tsx b/plugins/lighthouse/src/components/AuditList/index.test.tsx index 5fdc4781ce..4657066249 100644 --- a/plugins/lighthouse/src/components/AuditList/index.test.tsx +++ b/plugins/lighthouse/src/components/AuditList/index.test.tsx @@ -162,7 +162,7 @@ describe('AuditList', () => { , ), ); - const element = await rendered.findByTestId('error-message'); + const element = await rendered.findByText(/Could not load audit list./); expect(element).toBeInTheDocument(); }); }); From e73f35b1ea82125acc1120a861536b4218619027 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Wed, 3 Feb 2021 21:46:54 -0500 Subject: [PATCH 6/7] Wrap in code fence --- .../src/components/ApiExplorerTable/ApiExplorerTable.tsx | 2 +- plugins/catalog/src/components/CatalogTable/CatalogTable.tsx | 2 +- plugins/techdocs/src/reader/components/TechDocsHome.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx index 743366bdcd..506a2dcc30 100644 --- a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx +++ b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx @@ -152,7 +152,7 @@ export const ApiExplorerTable = ({ if (error) { return ( - {error.toString()} + {error.toString()} ); } diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index 97c7ccfa18..7477127aaf 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -131,7 +131,7 @@ export const CatalogTable = ({ severity="error" title="Could not fetch catalog entities." > - {error.toString()} + {error.toString()} ); diff --git a/plugins/techdocs/src/reader/components/TechDocsHome.tsx b/plugins/techdocs/src/reader/components/TechDocsHome.tsx index d5d3af67cb..f64c946702 100644 --- a/plugins/techdocs/src/reader/components/TechDocsHome.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsHome.tsx @@ -67,7 +67,7 @@ export const TechDocsHome = () => { severity="error" title="Could not load available documentation." > - {error.message} + {error.message} From d84cb8199d9676d22d70268630d28339e3f91d65 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Mon, 8 Feb 2021 10:54:48 -0500 Subject: [PATCH 7/7] Switch to CodeSnippet component --- .../components/ApiExplorerTable/ApiExplorerTable.tsx | 3 ++- .../src/components/CatalogTable/CatalogTable.tsx | 10 ++++++++-- .../techdocs/src/reader/components/TechDocsHome.tsx | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx index 506a2dcc30..701ca457df 100644 --- a/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx +++ b/plugins/api-docs/src/components/ApiExplorerTable/ApiExplorerTable.tsx @@ -22,6 +22,7 @@ import { RELATION_PART_OF, } from '@backstage/catalog-model'; import { + CodeSnippet, Table, TableColumn, TableFilter, @@ -152,7 +153,7 @@ export const ApiExplorerTable = ({ if (error) { return ( - {error.toString()} + ); } diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index 7477127aaf..cdc7451601 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -19,7 +19,13 @@ import { RELATION_OWNED_BY, RELATION_PART_OF, } from '@backstage/catalog-model'; -import { Table, TableColumn, TableProps, WarningPanel } from '@backstage/core'; +import { + CodeSnippet, + Table, + TableColumn, + TableProps, + WarningPanel, +} from '@backstage/core'; import { EntityRefLink, EntityRefLinks, @@ -131,7 +137,7 @@ export const CatalogTable = ({ severity="error" title="Could not fetch catalog entities." > - {error.toString()} + ); diff --git a/plugins/techdocs/src/reader/components/TechDocsHome.tsx b/plugins/techdocs/src/reader/components/TechDocsHome.tsx index f64c946702..ed0eb68ebc 100644 --- a/plugins/techdocs/src/reader/components/TechDocsHome.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsHome.tsx @@ -15,6 +15,7 @@ */ import { + CodeSnippet, Content, Header, ItemCard, @@ -67,7 +68,7 @@ export const TechDocsHome = () => { severity="error" title="Could not load available documentation." > - {error.message} +