Skip to content

Commit 0e604a3

Browse files
authored
Merge pull request #57 from dlabaj/unavailable
feat(unavailable): Added the unavailable page.
2 parents 0f610d9 + bcda586 commit 0e604a3

7 files changed

Lines changed: 419 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# Sidenav top-level section
3+
# should be the same for all markdown files
4+
section: extensions
5+
subsection: Component groups
6+
# Sidenav secondary level section
7+
# should be the same for all markdown files
8+
id: Unavailable content
9+
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
10+
source: react
11+
# If you use typescript, the name of the interface to display props for
12+
# These are found through the sourceProps function provided in patternfly-docs.source.js
13+
propComponents: ['UnavailableContent']
14+
---
15+
16+
import UnavailableContent from '@patternfly/react-component-groups/dist/dynamic/UnavailableContent';
17+
18+
An **unavailable content** component displays a screen to users when they attempt to view a page that is currently unavailable to view.
19+
20+
## Examples
21+
22+
### Basic unavailable content
23+
24+
A basic unavailable content component provides users with instructions, including a link to check a status page for known issues.
25+
The status page link can be specified using `statusPageUrl`.
26+
27+
```js file="./UnavailableContentExample.tsx"
28+
29+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import UnavailableContent from '@patternfly/react-component-groups/dist/dynamic/UnavailableContent';
3+
4+
export const BasicExample: React.FunctionComponent = () => (
5+
<UnavailableContent statusPageUrl="https://www.patternfly.org"/>
6+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import UnavailableContent from './UnavailableContent';
4+
5+
describe('Unavailable component', () => {
6+
it('should render with no link', () => {
7+
expect(render(<UnavailableContent />)).toMatchSnapshot();
8+
});
9+
10+
it('should render with a link', () => {
11+
expect(render(<UnavailableContent statusPageUrl="https://www.patternfly.org" />)).toMatchSnapshot();
12+
});
13+
14+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import { Button, EmptyState, EmptyStateBody, EmptyStateHeader, EmptyStateIcon, EmptyStateVariant } from '@patternfly/react-core';
3+
import { ExclamationCircleIcon } from '@patternfly/react-icons';
4+
import { createUseStyles } from 'react-jss';
5+
import clsx from 'clsx';
6+
7+
const useStyles = createUseStyles({
8+
emptyStateUnavailable: {
9+
color: 'var(--pf-global--danger-color--100)',
10+
'& svg': { color: 'var(--pf-global--danger-color--100)' }
11+
},
12+
emptyStateLinkButton: {
13+
padding: '0',
14+
}
15+
});
16+
17+
export interface UnavailableContentProps {
18+
/** Page to open when user clicks on status page link */
19+
statusPageUrl?: string;
20+
}
21+
22+
const UnavailableContent: React.FunctionComponent<UnavailableContentProps> = ({ statusPageUrl = '' }: UnavailableContentProps) => {
23+
const classes = useStyles();
24+
return (
25+
<EmptyState variant={EmptyStateVariant.lg} className={clsx(classes.emptyStateUnavailable)}>
26+
<EmptyStateHeader title="This page is temporarily unavailable" icon={<EmptyStateIcon icon={ExclamationCircleIcon} />} />
27+
<EmptyStateBody>
28+
Try refreshing the page. If the problem persists, contact your organization administrator or visit our{' '}
29+
<Button component='a' className={clsx(classes.emptyStateLinkButton)} variant='link' href={statusPageUrl} target="_blank" rel="noopener noreferrer">
30+
status page
31+
</Button>{' '}
32+
for known outages.
33+
</EmptyStateBody>
34+
</EmptyState>
35+
);
36+
};
37+
38+
export default UnavailableContent;

0 commit comments

Comments
 (0)