From 308efff0ac09d9255786edbac15b218f85165ea9 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Fri, 4 Feb 2022 15:11:40 +0100 Subject: [PATCH] add optional supportUrl property Signed-off-by: Emma Indal --- .../src/layout/ErrorPage/ErrorPage.test.tsx | 22 +++++++++++++++++++ .../src/layout/ErrorPage/ErrorPage.tsx | 5 +++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx b/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx index 12ac0927ed..d6ef392f76 100644 --- a/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx +++ b/packages/core-components/src/layout/ErrorPage/ErrorPage.test.tsx @@ -42,4 +42,26 @@ describe('', () => { expect(getByText(/a link/i)).toBeInTheDocument(); expect(getByText(/a link/i)).toHaveAttribute('href', '/test'); }); + + it('should render with default support url if supportUrl is not provided', async () => { + const { getByText } = await renderInTestApp( + , + ); + expect( + getByText(/looks like someone dropped the mic!/i), + ).toBeInTheDocument(); + expect(getByText(/contact support/i)).toBeInTheDocument(); + expect(getByText(/contact support/i)).toHaveAttribute('href', 'https://github.com/backstage/backstage/issues'); + }); + + it('should override support url if supportUrl property is provided', async () => { + const { getByText } = await renderInTestApp( + , + ); + expect( + getByText(/looks like someone dropped the mic!/i), + ).toBeInTheDocument(); + expect(getByText(/contact support/i)).toBeInTheDocument(); + expect(getByText(/contact support/i)).toHaveAttribute('href', 'https://error-page-test-support-url.com'); + }); }); diff --git a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx index b8e0193bcf..cae8f95ec8 100644 --- a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx +++ b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx @@ -28,6 +28,7 @@ interface IErrorPageProps { status: string; statusMessage: string; additionalInfo?: string | JSX.Element; + supportUrl?: string; } /** @public */ @@ -62,7 +63,7 @@ const useStyles = makeStyles( * */ export function ErrorPage(props: IErrorPageProps) { - const { status, statusMessage, additionalInfo } = props; + const { status, statusMessage, additionalInfo, supportUrl } = props; const classes = useStyles(); const navigate = useNavigate(); const support = useSupportConfig(); @@ -88,7 +89,7 @@ export function ErrorPage(props: IErrorPageProps) { navigate(-1)}> Go back - ... or please contact support if you + ... or please contact support if you think this is a bug.