add optional supportUrl property
Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
@@ -42,4 +42,26 @@ describe('<ErrorPage/>', () => {
|
||||
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(
|
||||
<ErrorPage status="404" statusMessage="PAGE NOT FOUND" />,
|
||||
);
|
||||
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(
|
||||
<ErrorPage status="404" statusMessage="PAGE NOT FOUND" supportUrl='https://error-page-test-support-url.com' />,
|
||||
);
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,6 +28,7 @@ interface IErrorPageProps {
|
||||
status: string;
|
||||
statusMessage: string;
|
||||
additionalInfo?: string | JSX.Element;
|
||||
supportUrl?: string;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
@@ -62,7 +63,7 @@ const useStyles = makeStyles<BackstageTheme>(
|
||||
*
|
||||
*/
|
||||
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) {
|
||||
<Link to="#" data-testid="go-back-link" onClick={() => navigate(-1)}>
|
||||
Go back
|
||||
</Link>
|
||||
... or please <Link to={support.url}>contact support</Link> if you
|
||||
... or please <Link to={supportUrl || support.url}>contact support</Link> if you
|
||||
think this is a bug.
|
||||
</Typography>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user