Skip to content

Commit 1240b0c

Browse files
committed
fix redirectUrl and custom example
1 parent 9c526ce commit 1240b0c

File tree

4 files changed

+41
-29
lines changed

4 files changed

+41
-29
lines changed

packages/module/patternfly-docs/content/extensions/component-groups/examples/Maintenance/Maintenance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ To provide users with basic information regarding maintenance. A basic maintenan
2828

2929
```
3030

31-
### Custom body and footer
31+
### Custom maintenance
3232

33-
To override the default bodyText and footer link, specify your own using `bodyText` and `customFooter`.
33+
To override the default bodyText and footer link, specify your own using `bodyText` and `customFooter`. You may add a `startTime`, `endTime` and `timeZone` that will be displayed as shown below. `timeZone` will be set to UTC by default.
3434

3535
```js file="./MaintenanceCustomExample.tsx"
3636

packages/module/patternfly-docs/content/extensions/component-groups/examples/Maintenance/MaintenanceCustomExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import React from 'react';
22
import Maintenance from '@patternfly/react-component-groups/dist/dynamic/Maintenance'
33

44
export const BasicExample: React.FunctionComponent = () => (
5-
<Maintenance bodyText='We are going to be down for maintenance starting now.' customFooter='Please visit' redirectUrl='http://patternfly.com' redirectUrlLinkText='here' utcStartTime='10am' utcEndTime='12am' startTime='6am' endTime='8am' timeZone='EST' />
5+
<Maintenance bodyText='We are currently undergoing scheduled maintenance and will be unavailable from' customFooter='Please visit' redirectLinkUrl='http://patternfly.com' redirectLinkText='here.' startTime='6am' endTime='8am' timeZone='EST' />
66
);

packages/module/patternfly-docs/content/extensions/component-groups/examples/Maintenance/MaintenanceExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import React from 'react';
22
import Maintenance from '@patternfly/react-component-groups/dist/dynamic/Maintenance'
33

44
export const BasicExample: React.FunctionComponent = () => (
5-
<Maintenance utcStartTime='10am' utcEndTime='12am' startTime='6am' endTime='8am' timeZone='EST' />
5+
<Maintenance />
66
);

packages/module/src/Maintenance/Maintenance.tsx

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,64 @@ export interface MaintenanceProps extends Omit<EmptyStateProps, 'children' | 'ti
1010
bodyText?: React.ReactNode;
1111
/** A default bodyText used if no bodyText is provided. */
1212
defaultBodyText?: React.ReactNode;
13-
/** start time for maintenance UTC */
14-
utcStartTime?: string;
15-
/** end time for maintenance UTC */
16-
utcEndTime?: string;
1713
/** start time in a specific time zone */
1814
startTime?: string;
1915
/** end time in a specific time zone */
2016
endTime?: string;
2117
/** specify time zone */
2218
timeZone?: string;
2319
/** Information link */
24-
redirectUrl?: string;
20+
redirectLinkUrl?: string;
2521
/** Information link title */
26-
redirectUrlLinkText?: string;
22+
redirectLinkText?: string;
2723
/** Custom footer content */
2824
customFooter?: React.ReactNode;
2925
/** Custom OUIA ID */
3026
ouiaId?: string | number; }
3127

3228
const Maintenance: React.FunctionComponent<MaintenanceProps> = ({
3329
titleText = 'Maintenance in progress',
34-
utcStartTime,
35-
utcEndTime,
30+
defaultBodyText = 'We are currently undergoing scheduled maintenance. Thank you for understanding.',
3631
startTime,
3732
endTime,
38-
timeZone,
39-
defaultBodyText = `We are currently undergoing scheduled maintenance and will be unavailable from ${utcStartTime} to ${utcEndTime} UTC (${startTime}-${endTime} ${timeZone}).`,
33+
timeZone = 'UTC',
4034
bodyText,
41-
redirectUrl = 'https://status.redhat.com',
42-
redirectUrlLinkText = 'status.redhat.com',
35+
redirectLinkUrl = 'https://status.redhat.com',
36+
redirectLinkText = 'status.redhat.com.',
4337
customFooter = 'For more information please visit',
4438
ouiaId = 'Maintenance',
4539
...props
46-
}: MaintenanceProps) => (
47-
<EmptyState headingLevel="h5" status={EmptyStateStatus.danger} icon={HourglassHalfIcon} titleText={titleText} variant={EmptyStateVariant.lg} data-ouia-component-id={ouiaId} {...props}>
48-
<EmptyStateBody data-ouia-component-id={`${ouiaId}-body`}>
49-
{bodyText ? bodyText : defaultBodyText}
50-
</EmptyStateBody>
51-
<EmptyStateFooter data-ouia-component-id={`${ouiaId}-footer`}>
52-
{ customFooter &&
53-
<Button variant='link' component='span' isInline href={redirectUrl} target="_blank" ouiaId={`${ouiaId}-link`}>
54-
{customFooter} {redirectUrlLinkText}
40+
}: MaintenanceProps) => {
41+
let formattedBodyText = bodyText;
42+
if (startTime && endTime && timeZone) {
43+
formattedBodyText += ` ${startTime} to ${endTime} ${timeZone}.`;
44+
}
45+
46+
return (
47+
<EmptyState headingLevel="h5" status={EmptyStateStatus.danger} icon={HourglassHalfIcon} titleText={titleText} variant={EmptyStateVariant.lg} data-ouia-component-id={ouiaId} {...props}>
48+
<EmptyStateBody data-ouia-component-id={`${ouiaId}-body`}>
49+
{bodyText ? formattedBodyText : defaultBodyText}
50+
</EmptyStateBody>
51+
<EmptyStateFooter data-ouia-component-id={`${ouiaId}-footer`}>
52+
{customFooter && (
53+
<span>
54+
{customFooter}{' '}
55+
<Button
56+
variant="link"
57+
component="span"
58+
isInline
59+
href={redirectLinkUrl}
60+
target="_blank"
61+
ouiaId={`${ouiaId}-link`}
62+
>
63+
{redirectLinkText}
5564
</Button>
56-
}
57-
</EmptyStateFooter>
58-
</EmptyState>
59-
);
65+
</span>
66+
)}
67+
</EmptyStateFooter>
68+
</EmptyState>
69+
)};
6070

6171
export default Maintenance;
72+
73+

0 commit comments

Comments
 (0)