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
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# Sidenav top-level section
# should be the same for all markdown files
section: extensions
subsection: Component groups
# Sidenav secondary level section
# should be the same for all markdown files
id: ErrorBoundaryPage
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
source: react
# If you use typescript, the name of the interface to display props for
# These are found through the sourceProps function provided in patternfly-docs.source.js
propComponents: ['ErrorBoundaryPage']
---

import { ErrorBoundaryPage } from "@patternfly/react-component-groups";

## Components Usage

This component reuses the ErrorState component for an app error boundary.

### ErrorBoundaryPage Component

```js file="./ErrorBoundaryPageExample.tsx"

```

### ErrorBoundaryPage Component without error

```js file="./ErrorBoundaryPageNoExample.tsx"

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { ErrorBoundaryPage } from '@patternfly/react-component-groups';

export const BasicExample: React.FunctionComponent = () => {
const Surprise = () => {
throw new Error('but a welcome one');
};

return (<ErrorBoundaryPage headerTitle="My app header" errorTitle="Something wrong happened">
<Surprise />
</ErrorBoundaryPage>);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import { ErrorBoundaryPage } from '@patternfly/react-component-groups';

export const BasicExample: React.FunctionComponent = () => (<ErrorBoundaryPage headerTitle={'My app header'}>
<div>My app content</div>
</ErrorBoundaryPage>);

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import { ErrorState } from "@patternfly/react-component-groups";

## Components Usage

### Error State Component
This component reuses the EmptyState component. Also most of its props is accepted.

### ErrorState Component

```js file="./ErrorStateExample.tsx"

Expand Down
1 change: 0 additions & 1 deletion packages/module/src/ErrorBoundary/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Text } from '@patternfly/react-core';
import { createUseStyles } from 'react-jss';

interface ErrorStackProps {
error: Error;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import ErrorBoundaryPage from '../ErrorBoundary';
import ErrorBoundaryPage from '../ErrorBoundaryPage';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

Expand Down
1 change: 1 addition & 0 deletions packages/module/src/ErrorBoundaryPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ErrorBoundaryPage } from './ErrorBoundaryPage';
15 changes: 0 additions & 15 deletions packages/module/src/ErrorState/DefaultErrorMessage.tsx

This file was deleted.

7 changes: 3 additions & 4 deletions packages/module/src/ErrorState/ErrorState.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { ExclamationCircleIcon } from '@patternfly/react-icons/';
import DefaultErrorMessage from './DefaultErrorMessage';
import {
Button,
EmptyState,
Expand All @@ -27,7 +26,7 @@ export interface ErrorStateProps extends Omit<EmptyStateProps, 'children'> {
errorDescription?: React.ReactNode;
}

const ErrorState: React.FunctionComponent<ErrorStateProps> = ({ errorTitle = 'Something went wrong', errorDescription, ...props }) => {
const ErrorState: React.FunctionComponent<ErrorStateProps> = ({ errorTitle = 'Something went wrong', errorDescription, ...props }: ErrorStateProps) => {
const classes = useStyles();
return (
<EmptyState variant={EmptyStateVariant.large} {...props}>
Expand All @@ -37,8 +36,8 @@ const ErrorState: React.FunctionComponent<ErrorStateProps> = ({ errorTitle = 'So
</Title>
<EmptyStateBody>
<Stack>
{!errorDescription && <StackItem>There was a problem processing the request. Please try again.</StackItem>}
<StackItem>{errorDescription || <DefaultErrorMessage />}</StackItem>
{errorDescription ? <StackItem>{errorDescription}</StackItem> : <><StackItem>There was a problem processing the request. Please try again.</StackItem>
<StackItem>If the problem persists, contact system support.</StackItem></>}
</Stack>
</EmptyStateBody>
{document.referrer ? (
Expand Down
1 change: 0 additions & 1 deletion packages/module/src/ErrorState/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ErrorState } from './ErrorState';
export { default as DefaultErrorMessage } from './DefaultErrorMessage';
2 changes: 1 addition & 1 deletion packages/module/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './DetailsPage';
export * from './DetailsPageHeader';
export * from './ErrorBoundary';
export * from './ErrorBoundaryPage';
export * from './ErrorState';
export * from './HorizontalNav';