diff --git a/awx/ui_next/src/components/ContentError/ContentError.jsx b/awx/ui_next/src/components/ContentError/ContentError.jsx
index 0b6572ff6d..7b0e6c8f75 100644
--- a/awx/ui_next/src/components/ContentError/ContentError.jsx
+++ b/awx/ui_next/src/components/ContentError/ContentError.jsx
@@ -1,6 +1,7 @@
import React from 'react';
-import { t } from '@lingui/macro';
import styled from 'styled-components';
+import { bool, instanceOf } from 'prop-types';
+import { t } from '@lingui/macro';
import { withI18n } from '@lingui/react';
import {
Title,
@@ -11,7 +12,6 @@ import {
import { ExclamationTriangleIcon } from '@patternfly/react-icons';
import { RootAPI } from '@api';
import ErrorDetail from '@components/ErrorDetail';
-import NotFoundError from './NotFoundError';
const EmptyState = styled(PFEmptyState)`
width: var(--pf-c-empty-state--m-lg--MaxWidth);
@@ -22,33 +22,41 @@ async function logout() {
window.location.replace('/#/login');
}
-class ContentError extends React.Component {
- render() {
- const { error, children, i18n } = this.props;
- if (error && error.response && error.response.status === 401) {
- if (!error.response.headers['session-timeout']) {
- logout();
- return null;
- }
+function ContentError({ error, children, isNotFound, i18n }) {
+ if (error && error.response && error.response.status === 401) {
+ if (!error.response.headers['session-timeout']) {
+ logout();
+ return null;
}
- if (error && error.response && error.response.status === 404) {
- return {children};
- }
- return (
-
-
- {i18n._(t`Something went wrong...`)}
-
- {children ||
- i18n._(
+ }
+ const is404 =
+ isNotFound || (error && error.response && error.response.status === 404);
+ return (
+
+
+
+ {is404 ? i18n._(t`Not Found`) : i18n._(t`Something went wrong...`)}
+
+
+ {is404
+ ? i18n._(t`The page you requested could not be found.`)
+ : i18n._(
t`There was an error loading this content. Please reload the page.`
)}
-
- {error && }
-
- );
- }
+ {children}
+
+ {error && }
+
+ );
}
+ContentError.propTypes = {
+ error: instanceOf(Error),
+ isNotFound: bool,
+};
+ContentError.defaultProps = {
+ error: null,
+ isNotFound: false,
+};
export { ContentError as _ContentError };
export default withI18n()(ContentError);
diff --git a/awx/ui_next/src/components/ContentError/NotFoundError.jsx b/awx/ui_next/src/components/ContentError/NotFoundError.jsx
deleted file mode 100644
index a8ae056ec6..0000000000
--- a/awx/ui_next/src/components/ContentError/NotFoundError.jsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import React from 'react';
-import { t } from '@lingui/macro';
-import styled from 'styled-components';
-import { withI18n } from '@lingui/react';
-import {
- Title,
- EmptyState as PFEmptyState,
- EmptyStateIcon,
- EmptyStateBody,
-} from '@patternfly/react-core';
-import { ExclamationTriangleIcon } from '@patternfly/react-icons';
-import ErrorDetail from '@components/ErrorDetail';
-
-const EmptyState = styled(PFEmptyState)`
- width: var(--pf-c-empty-state--m-lg--MaxWidth);
-`;
-
-function NotFoundError({ i18n, error, children }) {
- return (
-
-
- {i18n._(t`Not Found`)}
-
- {children || i18n._(`The page you requested could not be found.`)}
-
- {error && }
-
- );
-}
-
-export { NotFoundError as _NotFoundError };
-export default withI18n()(NotFoundError);
diff --git a/awx/ui_next/src/components/ContentError/index.js b/awx/ui_next/src/components/ContentError/index.js
index 8f0d6fcf9c..14587f410d 100644
--- a/awx/ui_next/src/components/ContentError/index.js
+++ b/awx/ui_next/src/components/ContentError/index.js
@@ -1,2 +1 @@
export { default } from './ContentError';
-export { default as NotFoundError } from './NotFoundError';
diff --git a/awx/ui_next/src/screens/Job/Job.jsx b/awx/ui_next/src/screens/Job/Job.jsx
index 95e084c409..c3150ab15a 100644
--- a/awx/ui_next/src/screens/Job/Job.jsx
+++ b/awx/ui_next/src/screens/Job/Job.jsx
@@ -9,7 +9,7 @@ import {
PageSection,
} from '@patternfly/react-core';
import { JobsAPI } from '@api';
-import ContentError, { NotFoundError } from '@components/ContentError';
+import ContentError from '@components/ContentError';
import CardCloseButton from '@components/CardCloseButton';
import RoutedTabs from '@components/RoutedTabs';
@@ -150,14 +150,13 @@ class Job extends Component {
key="not-found"
path="*"
render={() => (
-
- {i18n._(`The page you requested could not be found.`)}{' '}
+
{i18n._(`View Job Details`)}
-
+
)}
/>,
]}
diff --git a/awx/ui_next/src/screens/Job/JobTypeRedirect.jsx b/awx/ui_next/src/screens/Job/JobTypeRedirect.jsx
index 48d89385d2..e2eeb57725 100644
--- a/awx/ui_next/src/screens/Job/JobTypeRedirect.jsx
+++ b/awx/ui_next/src/screens/Job/JobTypeRedirect.jsx
@@ -1,8 +1,9 @@
import React, { Component } from 'react';
import { Redirect, Link } from 'react-router-dom';
import { PageSection, Card } from '@patternfly/react-core';
+import { withI18n } from '@lingui/react';
import { UnifiedJobsAPI } from '@api';
-import ContentError, { NotFoundError } from '@components/ContentError';
+import ContentError from '@components/ContentError';
import { JOB_TYPE_URL_SEGMENTS } from '../../constants';
const NOT_FOUND = 'not found';
@@ -47,7 +48,7 @@ class JobTypeRedirect extends Component {
}
render() {
- const { path, view } = this.props;
+ const { path, view, i18n } = this.props;
const { error, job, isLoading } = this.state;
if (error) {
@@ -55,10 +56,9 @@ class JobTypeRedirect extends Component {
{error === NOT_FOUND ? (
-
- The requested job could not be found.{' '}
- View all Jobs.
-
+
+ {i18n._(`View all Jobs`)}
+
) : (
)}
@@ -75,4 +75,4 @@ class JobTypeRedirect extends Component {
}
}
-export default JobTypeRedirect;
+export default withI18n()(JobTypeRedirect);
diff --git a/awx/ui_next/src/screens/NotFound.jsx b/awx/ui_next/src/screens/NotFound.jsx
index a50ed2e05e..f09a8fdba9 100644
--- a/awx/ui_next/src/screens/NotFound.jsx
+++ b/awx/ui_next/src/screens/NotFound.jsx
@@ -1,12 +1,12 @@
import React from 'react';
import { PageSection, Card } from '@patternfly/react-core';
-import { NotFoundError } from '@components/ContentError';
+import ContentError from '@components/ContentError';
function NotFound() {
return (
-
+
);
diff --git a/awx/ui_next/src/screens/Organization/Organization.jsx b/awx/ui_next/src/screens/Organization/Organization.jsx
index 47086b79d1..69e08354dd 100644
--- a/awx/ui_next/src/screens/Organization/Organization.jsx
+++ b/awx/ui_next/src/screens/Organization/Organization.jsx
@@ -10,7 +10,7 @@ import {
import styled from 'styled-components';
import CardCloseButton from '@components/CardCloseButton';
import RoutedTabs from '@components/RoutedTabs';
-import ContentError, { NotFoundError } from '@components/ContentError';
+import ContentError from '@components/ContentError';
import { OrganizationAccess } from './OrganizationAccess';
import OrganizationDetail from './OrganizationDetail';
import OrganizationEdit from './OrganizationEdit';
@@ -239,14 +239,13 @@ class Organization extends Component {
key="not-found"
path="*"
render={() => (
-
- {i18n._(`The page you requested could not be found.`)}{' '}
+
{match.params.id && (
{i18n._(`View Organization Details`)}
)}
-
+
)}
/>
,
diff --git a/awx/ui_next/src/screens/Template/Template.jsx b/awx/ui_next/src/screens/Template/Template.jsx
index 67848f2bde..062ba9e0c3 100644
--- a/awx/ui_next/src/screens/Template/Template.jsx
+++ b/awx/ui_next/src/screens/Template/Template.jsx
@@ -4,7 +4,7 @@ import { withI18n } from '@lingui/react';
import { Card, CardHeader, PageSection } from '@patternfly/react-core';
import { Switch, Route, Redirect, withRouter, Link } from 'react-router-dom';
import CardCloseButton from '@components/CardCloseButton';
-import ContentError, { NotFoundError } from '@components/ContentError';
+import ContentError from '@components/ContentError';
import RoutedTabs from '@components/RoutedTabs';
import JobTemplateDetail from './JobTemplateDetail';
import { JobTemplatesAPI } from '@api';
@@ -120,8 +120,7 @@ class Template extends Component {
key="not-found"
path="*"
render={() => (
-
- {i18n._(`The page you requested could not be found.`)}{' '}
+
{match.params.id && (
)}
-
+
)}
/>,
]}