mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
add NotFound screen/route handling
This commit is contained in:
@@ -9,8 +9,8 @@ import {
|
|||||||
EmptyStateBody,
|
EmptyStateBody,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import { ExclamationTriangleIcon } from '@patternfly/react-icons';
|
import { ExclamationTriangleIcon } from '@patternfly/react-icons';
|
||||||
|
|
||||||
import ErrorDetail from '@components/ErrorDetail';
|
import ErrorDetail from '@components/ErrorDetail';
|
||||||
|
import NotFoundError from './NotFoundError';
|
||||||
|
|
||||||
const EmptyState = styled(PFEmptyState)`
|
const EmptyState = styled(PFEmptyState)`
|
||||||
width: var(--pf-c-empty-state--m-lg--MaxWidth);
|
width: var(--pf-c-empty-state--m-lg--MaxWidth);
|
||||||
@@ -19,6 +19,12 @@ const EmptyState = styled(PFEmptyState)`
|
|||||||
class ContentError extends React.Component {
|
class ContentError extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { error, i18n } = this.props;
|
const { error, i18n } = this.props;
|
||||||
|
if (error && error.response && error.response.status === 401) {
|
||||||
|
// TODO: check for session timeout & redirect to /login
|
||||||
|
}
|
||||||
|
if (error && error.response && error.response.status === 404) {
|
||||||
|
return <NotFoundError error={error} />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<EmptyState>
|
<EmptyState>
|
||||||
<EmptyStateIcon icon={ExclamationTriangleIcon} />
|
<EmptyStateIcon icon={ExclamationTriangleIcon} />
|
||||||
|
|||||||
34
awx/ui_next/src/components/ContentError/NotFoundError.jsx
Normal file
34
awx/ui_next/src/components/ContentError/NotFoundError.jsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
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 }) {
|
||||||
|
return (
|
||||||
|
<EmptyState>
|
||||||
|
<EmptyStateIcon icon={ExclamationTriangleIcon} />
|
||||||
|
<Title size="lg">
|
||||||
|
{i18n._(t`Not Found`)}
|
||||||
|
</Title>
|
||||||
|
<EmptyStateBody>
|
||||||
|
{i18n._(`The page you requested could not be found.`)}
|
||||||
|
</EmptyStateBody>
|
||||||
|
{error && <ErrorDetail error={error} />}
|
||||||
|
</EmptyState>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { NotFoundError as _NotFoundError };
|
||||||
|
export default withI18n()(NotFoundError);
|
||||||
@@ -1 +1,2 @@
|
|||||||
export { default } from './ContentError';
|
export { default } from './ContentError';
|
||||||
|
export { default as NotFoundError } from './NotFoundError';
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import License from '@screens/License';
|
|||||||
import Teams from '@screens/Team';
|
import Teams from '@screens/Team';
|
||||||
import Templates from '@screens/Template';
|
import Templates from '@screens/Template';
|
||||||
import Users from '@screens/User';
|
import Users from '@screens/User';
|
||||||
|
import NotFound from '@screens/NotFound';
|
||||||
|
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import RootProvider from './RootProvider';
|
import RootProvider from './RootProvider';
|
||||||
@@ -224,8 +225,8 @@ export function main(render) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
render={({ routeGroups }) =>
|
render={({ routeGroups }) => {
|
||||||
routeGroups
|
const routeList = routeGroups
|
||||||
.reduce(
|
.reduce(
|
||||||
(allRoutes, { routes }) => allRoutes.concat(routes),
|
(allRoutes, { routes }) => allRoutes.concat(routes),
|
||||||
[]
|
[]
|
||||||
@@ -238,8 +239,16 @@ export function main(render) {
|
|||||||
<PageComponent match={match} />
|
<PageComponent match={match} />
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
))
|
));
|
||||||
}
|
routeList.push(
|
||||||
|
<Route
|
||||||
|
key="not-found"
|
||||||
|
path="*"
|
||||||
|
component={NotFound}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
return <Switch>{routeList}</Switch>;
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
15
awx/ui_next/src/screens/NotFound.jsx
Normal file
15
awx/ui_next/src/screens/NotFound.jsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { PageSection, Card } from '@patternfly/react-core';
|
||||||
|
import { NotFoundError } from '@components/ContentError';
|
||||||
|
|
||||||
|
function NotFound() {
|
||||||
|
return (
|
||||||
|
<PageSection>
|
||||||
|
<Card className="awx-c-card">
|
||||||
|
<NotFoundError />
|
||||||
|
</Card>
|
||||||
|
</PageSection>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NotFound;
|
||||||
Reference in New Issue
Block a user