From c3fc889d1221d99d47fe252b15aa3179a1a7f7bc Mon Sep 17 00:00:00 2001 From: David Sykes Date: Thu, 30 Jul 2020 11:17:24 +0100 Subject: [PATCH 1/8] Exported ErrorPage and reordered exports --- packages/core/src/layout/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/layout/index.ts b/packages/core/src/layout/index.ts index e8245119f3..d97d30982e 100644 --- a/packages/core/src/layout/index.ts +++ b/packages/core/src/layout/index.ts @@ -17,13 +17,14 @@ export * from './Content'; export * from './ContentHeader'; export * from './ErrorBoundary'; +export * from './ErrorPage'; export * from './Header'; export * from './HeaderLabel'; +export * from './HeaderTabs'; export * from './HomepageTimer'; export * from './InfoCard'; +export * from './ItemCard'; export * from './Page'; export * from './Sidebar'; export * from './SignInPage'; export * from './TabbedCard'; -export * from './HeaderTabs'; -export * from './ItemCard'; From 5ae8479e39a8c5a36a2c728c0f2186e50315d86f Mon Sep 17 00:00:00 2001 From: David Sykes Date: Thu, 30 Jul 2020 11:18:20 +0100 Subject: [PATCH 2/8] Added optional docPath parameter to ErrorPage and used it to display docPath for missing TechDocs --- packages/core/src/layout/ErrorPage/ErrorPage.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/src/layout/ErrorPage/ErrorPage.tsx b/packages/core/src/layout/ErrorPage/ErrorPage.tsx index d6620295c1..b382997da3 100644 --- a/packages/core/src/layout/ErrorPage/ErrorPage.tsx +++ b/packages/core/src/layout/ErrorPage/ErrorPage.tsx @@ -24,6 +24,7 @@ import { useNavigate } from 'react-router'; interface IErrorPageProps { status: string; statusMessage: string; + docPath?: string; } const useStyles = makeStyles(theme => ({ @@ -38,7 +39,11 @@ const useStyles = makeStyles(theme => ({ }, })); -export const ErrorPage = ({ status, statusMessage }: IErrorPageProps) => { +export const ErrorPage = ({ + status, + statusMessage, + docPath, +}: IErrorPageProps) => { const classes = useStyles(); const navigate = useNavigate(); @@ -48,6 +53,8 @@ export const ErrorPage = ({ status, statusMessage }: IErrorPageProps) => { ERROR {status}: {statusMessage} +
+ {docPath}
Looks like someone dropped the mic! From fa708d6572098446e277c3ed2e1b5d3c372090df Mon Sep 17 00:00:00 2001 From: David Sykes Date: Thu, 30 Jul 2020 11:19:12 +0100 Subject: [PATCH 3/8] TechDocsNotFound now uses ErrorPage from core with an optional docPath parameter --- .../reader/components/TechDocsNotFound.tsx | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx index 2a961b5bc0..7f50a2861e 100644 --- a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx @@ -15,20 +15,16 @@ */ import React from 'react'; -import { Typography, Button } from '@material-ui/core'; -import { TechDocsPageWrapper } from './TechDocsPageWrapper'; +import { ErrorPage } from '@backstage/core'; export const TechDocsNotFound = () => { return ( - - Error: Documentation not found - Path: {window.location.pathname} - - +
+ +
); }; From ea57820c62da7308abccfb8c3fda4394503b170c Mon Sep 17 00:00:00 2001 From: David Sykes Date: Thu, 30 Jul 2020 11:30:01 +0100 Subject: [PATCH 4/8] Removed a div that was no longer needed --- .../src/reader/components/TechDocsNotFound.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx index 7f50a2861e..cbb038c0ce 100644 --- a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx @@ -19,12 +19,10 @@ import { ErrorPage } from '@backstage/core'; export const TechDocsNotFound = () => { return ( -
- -
+ ); }; From 4f54f062feb7db40a60636916bbc0a2b816bbb1f Mon Sep 17 00:00:00 2001 From: David Sykes Date: Thu, 30 Jul 2020 11:31:26 +0100 Subject: [PATCH 5/8] Updated test --- .../techdocs/src/reader/components/TechDocsNotFound.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx b/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx index 7792164b14..70504561ef 100644 --- a/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx @@ -21,6 +21,8 @@ import { wrapInTestApp } from '@backstage/test-utils'; describe('TechDocs Not Found', () => { it('should render a Documentation not found page', async () => { const { queryByText } = render(wrapInTestApp()); - expect(queryByText(/error: documentation not found/i)).toBeInTheDocument(); + expect( + queryByText(/Error 404: Documentation not found/i), + ).toBeInTheDocument(); }); }); From 58fa8ce5fbc12471a1728dbd73379df5881930ed Mon Sep 17 00:00:00 2001 From: David Sykes Date: Thu, 30 Jul 2020 11:35:01 +0100 Subject: [PATCH 6/8] Updated test --- .../src/reader/components/TechDocsNotFound.test.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx b/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx index 70504561ef..7b0ec80619 100644 --- a/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx @@ -18,11 +18,12 @@ import React from 'react'; import { render } from '@testing-library/react'; import { wrapInTestApp } from '@backstage/test-utils'; -describe('TechDocs Not Found', () => { - it('should render a Documentation not found page', async () => { - const { queryByText } = render(wrapInTestApp()); - expect( - queryByText(/Error 404: Documentation not found/i), - ).toBeInTheDocument(); +describe('', () => { + it('should render with status code, status message and go back link', () => { + const rendered = render(wrapInTestApp()); + rendered.getByText(/Documentation not found/i); + rendered.getByText(/404/i); + rendered.getByText(/Looks like someone dropped the mic!/i); + expect(rendered.getByTestId('go-back-link')).toBeDefined(); }); }); From 343b922e8f4d77e8f16972dded0b18f9d079c600 Mon Sep 17 00:00:00 2001 From: David J Sykes Date: Thu, 30 Jul 2020 15:17:38 +0100 Subject: [PATCH 7/8] Removed
using seperate Typography element instead --- packages/core/src/layout/ErrorPage/ErrorPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/src/layout/ErrorPage/ErrorPage.tsx b/packages/core/src/layout/ErrorPage/ErrorPage.tsx index b382997da3..df8323ef46 100644 --- a/packages/core/src/layout/ErrorPage/ErrorPage.tsx +++ b/packages/core/src/layout/ErrorPage/ErrorPage.tsx @@ -53,7 +53,8 @@ export const ErrorPage = ({ ERROR {status}: {statusMessage} -
+
+ {docPath} From cc905069d10566c80c2875a24d082abc9d1703ee Mon Sep 17 00:00:00 2001 From: David J Sykes Date: Thu, 30 Jul 2020 16:57:38 +0100 Subject: [PATCH 8/8] Changed optional parameter name to allow for more generic uses --- packages/core/src/layout/ErrorPage/ErrorPage.tsx | 6 +++--- plugins/techdocs/src/reader/components/TechDocsNotFound.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/layout/ErrorPage/ErrorPage.tsx b/packages/core/src/layout/ErrorPage/ErrorPage.tsx index df8323ef46..71a24652ba 100644 --- a/packages/core/src/layout/ErrorPage/ErrorPage.tsx +++ b/packages/core/src/layout/ErrorPage/ErrorPage.tsx @@ -24,7 +24,7 @@ import { useNavigate } from 'react-router'; interface IErrorPageProps { status: string; statusMessage: string; - docPath?: string; + additionalInfo?: string; } const useStyles = makeStyles(theme => ({ @@ -42,7 +42,7 @@ const useStyles = makeStyles(theme => ({ export const ErrorPage = ({ status, statusMessage, - docPath, + additionalInfo, }: IErrorPageProps) => { const classes = useStyles(); const navigate = useNavigate(); @@ -55,7 +55,7 @@ export const ErrorPage = ({ ERROR {status}: {statusMessage} - {docPath} + {additionalInfo} Looks like someone dropped the mic! diff --git a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx index cbb038c0ce..c774000bd5 100644 --- a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx @@ -22,7 +22,7 @@ export const TechDocsNotFound = () => { ); };