Skip to content

Commit 8214bfe

Browse files
authored
Merge pull request patternfly#85 from dlabaj/localization
fix(i18n): i18n support, fixes issue patternfly#52
2 parents d0679ea + cea2386 commit 8214bfe

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed

packages/module/src/ErrorBoundary/ErrorBoundary.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import ErrorState from '../ErrorState';
44
import ErrorStack from '../ErrorStack';
55

66
export interface ErrorPageProps {
7-
/** Title to display on the error page */
7+
/** The title text to display on the error page */
88
headerTitle: string;
9-
/** Indicates if this is a silent error */
9+
/** Indicates if the error is silent */
1010
silent?: boolean;
11-
/** Title given to the error */
11+
/** The title text to display with the error */
1212
errorTitle?: string;
13-
/** A description of the error */
13+
/** The description text to display with the error */
1414
errorDescription?: React.ReactNode;
15-
/** A default description of the error used if no errorDescription is provided. */
15+
/** The text for the toggle link that users can select to view error details */
16+
errorToggleText?: string;
17+
/** The default description text to display with the error if no errorDescription is provided */
1618
defaultErrorDescription?: React.ReactNode;
17-
/** Children components */
19+
/** The component that the error boundary component is wrapped around, which should be returned if there is no error */
1820
children?: React.ReactNode;
1921
}
2022

@@ -28,7 +30,7 @@ export interface ErrorPageState {
2830
}
2931

3032
// As of time of writing, React only supports error boundaries in class components
31-
class ErrorBoundary extends React.Component<React.PropsWithChildren<ErrorPageProps>, ErrorPageState> {
33+
class ErrorBoundary extends React.Component<ErrorPageProps, ErrorPageState> {
3234
constructor(props: Readonly<ErrorPageProps>) {
3335
super(props);
3436
this.state = {
@@ -72,7 +74,7 @@ class ErrorBoundary extends React.Component<React.PropsWithChildren<ErrorPagePro
7274
<>
7375
<span>{this.props.errorDescription}</span>
7476
{this.state.error && (
75-
<ExpandableSection toggleText="Show details">
77+
<ExpandableSection toggleText={this.props.errorToggleText ? this.props.errorToggleText : "Show details"}>
7678
<ErrorStack error={this.state.error} />
7779
</ExpandableSection>
7880
)}

packages/module/src/InvalidObject/InvalidObject.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ import NotFoundIcon from '../NotFoundIcon/NotFoundIcon';
44
import React from 'react';
55

66
export interface InvalidObjectProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
7-
/** Custom landing page button URL */
7+
/** The URL that the landing page link points to */
88
toLandingPageUrl?: string;
9-
/** Custom return to landing page text */
9+
/** The text label for the link that points back to the landing page */
1010
toLandingPageText?: React.ReactNode;
11+
/** The title for the invalid object message */
12+
invalidObjectTitleText?: string;
13+
/** The body text for the invalid object message */
14+
invalidObjectBodyText?: string;
1115
}
1216

1317

1418
const InvalidObject: React.FunctionComponent<InvalidObjectProps> = ({
1519
toLandingPageUrl = window.location.origin,
16-
toLandingPageText = 'Return to homepage'
20+
toLandingPageText = 'Return to homepage',
21+
invalidObjectTitleText = 'We lost that page',
22+
invalidObjectBodyText = "Let's find you a new one. Try a new search or return home."
1723
}: InvalidObjectProps) => (
1824
<EmptyState variant={EmptyStateVariant.full}>
19-
<EmptyStateHeader titleText='We lost that page' icon={<NotFoundIcon />} headingLevel='h1' />
20-
<EmptyStateBody>Let&apos;s find you a new one. Try a new search or return home.</EmptyStateBody>
25+
<EmptyStateHeader titleText={invalidObjectTitleText}icon={<NotFoundIcon />} headingLevel='h1' />
26+
<EmptyStateBody>{invalidObjectBodyText}</EmptyStateBody>
2127
<EmptyStateFooter>
2228
<Button variant="link" component="a" href={toLandingPageUrl}>
2329
{toLandingPageText}

packages/module/src/UnavailableContent/UnavailableContent.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,34 @@ const useStyles = createUseStyles({
1515
});
1616

1717
export interface UnavailableContentProps {
18-
/** Page to open when user clicks on status page link */
18+
/** The URL that the status page link points to */
1919
statusPageUrl?: string;
20+
/** The text label for the link that points to the status page */
21+
statusPageLinkText?: string;
22+
/** The title for the unavailable content message */
23+
unavailableTitleText?: string;
24+
/** The body text for the unavailable content message that appears before the status page link */
25+
unavailableBodyPreStatusLinkText?: string;
26+
/** The body text for the unavailable content message that appears after the status page link */
27+
unavailableBodyPostStatusLinkText?: string;
2028
}
2129

22-
const UnavailableContent: React.FunctionComponent<UnavailableContentProps> = ({ statusPageUrl = '' }: UnavailableContentProps) => {
30+
const UnavailableContent: React.FunctionComponent<UnavailableContentProps> = (
31+
{ statusPageUrl = '',
32+
statusPageLinkText = 'status page',
33+
unavailableTitleText = 'This page is temporarily unavailable',
34+
unavailableBodyPreStatusLinkText = 'Try refreshing the page. If the problem persists, contact your organization administrator or visit our',
35+
unavailableBodyPostStatusLinkText = 'for known outages.' }: UnavailableContentProps) => {
2336
const classes = useStyles();
2437
return (
2538
<EmptyState variant={EmptyStateVariant.lg} className={clsx(classes.emptyStateUnavailable)}>
26-
<EmptyStateHeader titleText="This page is temporarily unavailable" icon={<EmptyStateIcon icon={ExclamationCircleIcon} />} headingLevel="h5" />
39+
<EmptyStateHeader titleText={unavailableTitleText} icon={<EmptyStateIcon icon={ExclamationCircleIcon} />} headingLevel="h5" />
2740
<EmptyStateBody>
28-
Try refreshing the page. If the problem persists, contact your organization administrator or visit our{' '}
41+
{unavailableBodyPreStatusLinkText}{' '}
2942
<Button component='a' className={clsx(classes.emptyStateLinkButton)} variant='link' href={statusPageUrl} target="_blank" rel="noopener noreferrer">
30-
status page
43+
{statusPageLinkText}
3144
</Button>{' '}
32-
for known outages.
45+
{unavailableBodyPostStatusLinkText}
3346
</EmptyStateBody>
3447
</EmptyState>
3548
);

0 commit comments

Comments
 (0)