mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 02:17:37 -02:30
Merge pull request #8963 from marshmalien/8962-fix-output-navigation
Fix navigation bug in job output Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -14,15 +14,15 @@ import { CaretLeftIcon } from '@patternfly/react-icons';
|
|||||||
import { Card, PageSection } from '@patternfly/react-core';
|
import { Card, PageSection } from '@patternfly/react-core';
|
||||||
import { JobsAPI } from '../../api';
|
import { JobsAPI } from '../../api';
|
||||||
import ContentError from '../../components/ContentError';
|
import ContentError from '../../components/ContentError';
|
||||||
|
import ContentLoading from '../../components/ContentLoading';
|
||||||
import RoutedTabs from '../../components/RoutedTabs';
|
import RoutedTabs from '../../components/RoutedTabs';
|
||||||
import useRequest from '../../util/useRequest';
|
import useRequest from '../../util/useRequest';
|
||||||
import JobDetail from './JobDetail';
|
import JobDetail from './JobDetail';
|
||||||
import JobOutput from './JobOutput';
|
import JobOutput from './JobOutput';
|
||||||
import { WorkflowOutput } from './WorkflowOutput';
|
import { WorkflowOutput } from './WorkflowOutput';
|
||||||
import useWsJob from './useWsJob';
|
import useWsJob from './useWsJob';
|
||||||
import { JOB_TYPE_URL_SEGMENTS } from '../../constants';
|
|
||||||
|
|
||||||
function Job({ i18n, lookup, setBreadcrumb }) {
|
function Job({ i18n, setBreadcrumb }) {
|
||||||
const { id, type } = useParams();
|
const { id, type } = useParams();
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
|
|
||||||
@@ -41,11 +41,6 @@ function Job({ i18n, lookup, setBreadcrumb }) {
|
|||||||
|
|
||||||
const job = useWsJob(result);
|
const job = useWsJob(result);
|
||||||
|
|
||||||
let jobType;
|
|
||||||
if (job) {
|
|
||||||
jobType = JOB_TYPE_URL_SEGMENTS[job.type];
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabsArray = [
|
const tabsArray = [
|
||||||
{
|
{
|
||||||
name: (
|
name: (
|
||||||
@@ -61,7 +56,17 @@ function Job({ i18n, lookup, setBreadcrumb }) {
|
|||||||
{ name: i18n._(t`Output`), link: `${match.url}/output`, id: 1 },
|
{ name: i18n._(t`Output`), link: `${match.url}/output`, id: 1 },
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!isLoading && error) {
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<PageSection>
|
||||||
|
<Card>
|
||||||
|
<ContentLoading />
|
||||||
|
</Card>
|
||||||
|
</PageSection>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card>
|
||||||
@@ -78,20 +83,10 @@ function Job({ i18n, lookup, setBreadcrumb }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lookup && job) {
|
|
||||||
return (
|
|
||||||
<Switch>
|
|
||||||
<Redirect from="jobs/:id" to={`/jobs/${jobType}/:id/output`} />
|
|
||||||
<Redirect from="jobs/:id/details" to={`/jobs/${jobType}/:id/details`} />
|
|
||||||
<Redirect from="jobs/:id/output" to={`/jobs/${jobType}/:id/output`} />
|
|
||||||
</Switch>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card>
|
||||||
{!isLoading && <RoutedTabs tabsArray={tabsArray} />}
|
<RoutedTabs tabsArray={tabsArray} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Redirect from="/jobs/:type/:id" to="/jobs/:type/:id/output" exact />
|
<Redirect from="/jobs/:type/:id" to="/jobs/:type/:id/output" exact />
|
||||||
{job &&
|
{job &&
|
||||||
@@ -112,13 +107,11 @@ function Job({ i18n, lookup, setBreadcrumb }) {
|
|||||||
<JobOutput type={type} job={job} />
|
<JobOutput type={type} job={job} />
|
||||||
</Route>,
|
</Route>,
|
||||||
<Route key="not-found" path="*">
|
<Route key="not-found" path="*">
|
||||||
{!isLoading && (
|
<ContentError isNotFound>
|
||||||
<ContentError isNotFound>
|
<Link to={`/jobs/${type}/${id}/details`}>
|
||||||
<Link to={`/jobs/${type}/${id}/details`}>
|
{i18n._(t`View Job Details`)}
|
||||||
{i18n._(t`View Job Details`)}
|
</Link>
|
||||||
</Link>
|
</ContentError>
|
||||||
</ContentError>
|
|
||||||
)}
|
|
||||||
</Route>,
|
</Route>,
|
||||||
]}
|
]}
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
import React, { useState, useCallback } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import {
|
import { Route, Switch, useParams, useRouteMatch } from 'react-router-dom';
|
||||||
Route,
|
|
||||||
Switch,
|
|
||||||
useHistory,
|
|
||||||
useLocation,
|
|
||||||
useParams,
|
|
||||||
useRouteMatch,
|
|
||||||
} from 'react-router-dom';
|
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { PageSection } from '@patternfly/react-core';
|
import { PageSection } from '@patternfly/react-core';
|
||||||
@@ -17,8 +10,6 @@ import JobList from '../../components/JobList';
|
|||||||
import { JOB_TYPE_URL_SEGMENTS } from '../../constants';
|
import { JOB_TYPE_URL_SEGMENTS } from '../../constants';
|
||||||
|
|
||||||
function Jobs({ i18n }) {
|
function Jobs({ i18n }) {
|
||||||
const history = useHistory();
|
|
||||||
const location = useLocation();
|
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
const [breadcrumbConfig, setBreadcrumbConfig] = useState({
|
const [breadcrumbConfig, setBreadcrumbConfig] = useState({
|
||||||
'/jobs': i18n._(t`Jobs`),
|
'/jobs': i18n._(t`Jobs`),
|
||||||
@@ -63,11 +54,7 @@ function Jobs({ i18n }) {
|
|||||||
<TypeRedirect view="output" />
|
<TypeRedirect view="output" />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path={`${match.path}/:type/:id`}>
|
<Route path={`${match.path}/:type/:id`}>
|
||||||
<Job
|
<Job setBreadcrumb={buildBreadcrumbConfig} />
|
||||||
history={history}
|
|
||||||
location={location}
|
|
||||||
setBreadcrumb={buildBreadcrumbConfig}
|
|
||||||
/>
|
|
||||||
</Route>
|
</Route>
|
||||||
<Route path={`${match.path}/:id`}>
|
<Route path={`${match.path}/:id`}>
|
||||||
<TypeRedirect />
|
<TypeRedirect />
|
||||||
|
|||||||
Reference in New Issue
Block a user