Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions packages/ui-patterns/src/UnexpectedErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ import { ErrorPage } from "./ErrorPage";
import { uiPatternsMessage } from "./messages";

export interface UnexpectedErrorPageProps {
/** Where "raising a support request" links to. */
supportUrl: string;
/**
* Where "raising a support request" links to. Omit it and the page does
* not mention support, for deployments without a support site.
*/
supportUrl?: string;
/**
* Identifies the error report, typically the Sentry event id, so a support
* request quoting it can be matched to the report. Omit when the error was
Expand Down Expand Up @@ -57,18 +60,20 @@ export const UnexpectedErrorPage = ({
/>
}
>
<Text>
<FormattedMessage
{...uiPatternsMessage("ui-patterns.support-request")}
values={{
link: (chunks: ReactNode) => (
<ExternalLink href={supportUrl} color="brand.600">
{chunks}
</ExternalLink>
),
}}
/>
</Text>
{supportUrl && (
<Text>
<FormattedMessage
{...uiPatternsMessage("ui-patterns.support-request")}
values={{
link: (chunks: ReactNode) => (
<ExternalLink href={supportUrl} color="brand.600">
{chunks}
</ExternalLink>
),
}}
/>
</Text>
)}
{reference && <ErrorReference reference={reference} />}
{children}
<Box mt={2}>
Expand Down
8 changes: 8 additions & 0 deletions packages/ui-patterns/stories/UnexpectedErrorPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ export const WithRecoveryAction: Story = {
),
},
};

/** A deployment with no support site of its own. */
export const WithoutSupportSite: Story = {
args: {
supportUrl: undefined,
reference: "5f1e7a2c9b3d4e6f8a0b1c2d3e4f5a6b",
},
};
7 changes: 7 additions & 0 deletions packages/ui-patterns/tests/ErrorPages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ describe("UnexpectedErrorPage", () => {
expect(onReload).toHaveBeenCalledOnce();
});

it("omits the support text when there is no support site", () => {
render(<UnexpectedErrorPage reference="abc123" />, { wrapper: Providers });
expect(screen.queryByRole("link")).toBeNull();
expect(screen.queryByText(/support request/)).toBeNull();
expect(screen.getByText(/Error reference/)).toBeDefined();
});

it("focuses the heading on mount", () => {
render(<UnexpectedErrorPage supportUrl={supportUrl} />, {
wrapper: Providers,
Expand Down