From b695f583dda54163d4c2181497bbafc225bfe843 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Mon, 21 Dec 2020 15:19:26 -0500 Subject: [PATCH] Fix job output loading state --- awx/ui_next/src/screens/Job/Job.jsx | 45 ++++++++++++---------------- awx/ui_next/src/screens/Job/Jobs.jsx | 17 ++--------- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/awx/ui_next/src/screens/Job/Job.jsx b/awx/ui_next/src/screens/Job/Job.jsx index e5692ad261..ce62e7338c 100644 --- a/awx/ui_next/src/screens/Job/Job.jsx +++ b/awx/ui_next/src/screens/Job/Job.jsx @@ -14,15 +14,15 @@ import { CaretLeftIcon } from '@patternfly/react-icons'; import { Card, PageSection } from '@patternfly/react-core'; import { JobsAPI } from '../../api'; import ContentError from '../../components/ContentError'; +import ContentLoading from '../../components/ContentLoading'; import RoutedTabs from '../../components/RoutedTabs'; import useRequest from '../../util/useRequest'; import JobDetail from './JobDetail'; import JobOutput from './JobOutput'; import { WorkflowOutput } from './WorkflowOutput'; 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 match = useRouteMatch(); @@ -41,11 +41,6 @@ function Job({ i18n, lookup, setBreadcrumb }) { const job = useWsJob(result); - let jobType; - if (job) { - jobType = JOB_TYPE_URL_SEGMENTS[job.type]; - } - const tabsArray = [ { name: ( @@ -61,7 +56,17 @@ function Job({ i18n, lookup, setBreadcrumb }) { { name: i18n._(t`Output`), link: `${match.url}/output`, id: 1 }, ]; - if (!isLoading && error) { + if (isLoading) { + return ( + + + + + + ); + } + + if (error) { return ( @@ -78,20 +83,10 @@ function Job({ i18n, lookup, setBreadcrumb }) { ); } - if (lookup && job) { - return ( - - - - - - ); - } - return ( - {!isLoading && } + {job && @@ -112,13 +107,11 @@ function Job({ i18n, lookup, setBreadcrumb }) { , - {!isLoading && ( - - - {i18n._(t`View Job Details`)} - - - )} + + + {i18n._(t`View Job Details`)} + + , ]} diff --git a/awx/ui_next/src/screens/Job/Jobs.jsx b/awx/ui_next/src/screens/Job/Jobs.jsx index 98890ccd12..83c8d0d11f 100644 --- a/awx/ui_next/src/screens/Job/Jobs.jsx +++ b/awx/ui_next/src/screens/Job/Jobs.jsx @@ -1,12 +1,5 @@ import React, { useState, useCallback } from 'react'; -import { - Route, - Switch, - useHistory, - useLocation, - useParams, - useRouteMatch, -} from 'react-router-dom'; +import { Route, Switch, useParams, useRouteMatch } from 'react-router-dom'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { PageSection } from '@patternfly/react-core'; @@ -17,8 +10,6 @@ import JobList from '../../components/JobList'; import { JOB_TYPE_URL_SEGMENTS } from '../../constants'; function Jobs({ i18n }) { - const history = useHistory(); - const location = useLocation(); const match = useRouteMatch(); const [breadcrumbConfig, setBreadcrumbConfig] = useState({ '/jobs': i18n._(t`Jobs`), @@ -63,11 +54,7 @@ function Jobs({ i18n }) { - +