diff --git a/awx/ui_next/src/screens/Host/Host.jsx b/awx/ui_next/src/screens/Host/Host.jsx index 2a8f286bd2..173f3540e8 100644 --- a/awx/ui_next/src/screens/Host/Host.jsx +++ b/awx/ui_next/src/screens/Host/Host.jsx @@ -9,7 +9,7 @@ import { useRouteMatch, useLocation, } from 'react-router-dom'; -import { Card, CardActions } from '@patternfly/react-core'; +import { Card, CardActions, PageSection } from '@patternfly/react-core'; import { TabbedCardHeader } from '@components/Card'; import CardCloseButton from '@components/CardCloseButton'; @@ -34,11 +34,8 @@ function Host({ i18n, setBreadcrumb }) { useEffect(() => { (async () => { setContentError(null); - setHasContentLoading(true); - try { const { data } = await HostsAPI.readDetail(match.params.id); - setHost(data); setBreadcrumb(data); } catch (error) { @@ -47,7 +44,7 @@ function Host({ i18n, setBreadcrumb }) { setHasContentLoading(false); } })(); - }, [location]); // eslint-disable-line react-hooks/exhaustive-deps + }, [match.params.id, location, setBreadcrumb]); const tabsArray = [ { @@ -72,75 +69,73 @@ function Host({ i18n, setBreadcrumb }) { }, ]; - let cardHeader = ( - - - - - - - ); - - if (location.pathname.endsWith('edit')) { - cardHeader = null; - } - if (hasContentLoading) { - return ; + return ( + + + + + + ); } - if (!hasContentLoading && contentError) { + if (contentError) { return ( - - - {contentError.response && contentError.response.status === 404 && ( - - {i18n._(`Host not found.`)}{' '} - {i18n._(`View all Hosts.`)} - - )} - - + + + + {contentError?.response?.status === 404 && ( + + {i18n._(`Host not found.`)}{' '} + {i18n._(`View all Hosts.`)} + + )} + + + ); } return ( - - {cardHeader} - - - {host && [ - - - , - - - , - - - , - - - , - - - , - ]} - - !hasContentLoading && ( - - - {i18n._(`View Host Details`)} - - - ) - } - /> - - + + + {location.pathname.endsWith('edit') ? null : ( + + + + + + + )} + + + {host && [ + + + , + + + , + + + , + + + , + + + , + ]} + + + + {i18n._(`View Host Details`)} + + + + + + ); } diff --git a/awx/ui_next/src/screens/Host/HostList/HostList.jsx b/awx/ui_next/src/screens/Host/HostList/HostList.jsx index 36d831bb7a..b183d402c5 100644 --- a/awx/ui_next/src/screens/Host/HostList/HostList.jsx +++ b/awx/ui_next/src/screens/Host/HostList/HostList.jsx @@ -1,8 +1,8 @@ -import React, { Fragment, useState, useEffect, useCallback } from 'react'; +import React, { useState, useEffect, useCallback } from 'react'; import { useLocation, useRouteMatch } from 'react-router-dom'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; -import { Card } from '@patternfly/react-core'; +import { Card, PageSection } from '@patternfly/react-core'; import { HostsAPI } from '@api'; import AlertModal from '@components/AlertModal'; @@ -95,7 +95,7 @@ function HostList({ i18n }) { actions && Object.prototype.hasOwnProperty.call(actions, 'POST'); return ( - + )} - + ); } diff --git a/awx/ui_next/src/screens/Host/Hosts.jsx b/awx/ui_next/src/screens/Host/Hosts.jsx index a590e2c42c..b6ec6cd62d 100644 --- a/awx/ui_next/src/screens/Host/Hosts.jsx +++ b/awx/ui_next/src/screens/Host/Hosts.jsx @@ -4,7 +4,6 @@ import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { Config } from '@contexts/Config'; -import { PageSection, Card } from '@patternfly/react-core'; import Breadcrumbs from '@components/Breadcrumbs/Breadcrumbs'; import HostList from './HostList'; @@ -39,25 +38,21 @@ function Hosts({ i18n }) { return ( <> - - - - - - - - - {({ me }) => ( - - )} - - - - - - - - + + + + + + + {({ me }) => ( + + )} + + + + + + ); } diff --git a/awx/ui_next/src/screens/Inventory/Inventories.jsx b/awx/ui_next/src/screens/Inventory/Inventories.jsx index d6bfa12f74..87f8add4a3 100644 --- a/awx/ui_next/src/screens/Inventory/Inventories.jsx +++ b/awx/ui_next/src/screens/Inventory/Inventories.jsx @@ -1,4 +1,4 @@ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { Route, withRouter, Switch } from 'react-router-dom'; @@ -95,7 +95,7 @@ class Inventories extends Component { const { match, history, location } = this.props; const { breadcrumbConfig } = this.state; return ( - + <> } /> - + ); } } diff --git a/awx/ui_next/src/screens/Inventory/Inventory.jsx b/awx/ui_next/src/screens/Inventory/Inventory.jsx index 4056a418b2..ac246aa604 100644 --- a/awx/ui_next/src/screens/Inventory/Inventory.jsx +++ b/awx/ui_next/src/screens/Inventory/Inventory.jsx @@ -63,24 +63,6 @@ function Inventory({ i18n, setBreadcrumb }) { }, ]; - let cardHeader = hasContentLoading ? null : ( - - - - - - - ); - - if ( - location.pathname.endsWith('edit') || - location.pathname.endsWith('add') || - location.pathname.includes('groups/') || - location.pathname.includes('hosts/') - ) { - cardHeader = null; - } - if (hasContentLoading) { return ( @@ -91,12 +73,12 @@ function Inventory({ i18n, setBreadcrumb }) { ); } - if (!hasContentLoading && contentError) { + if (contentError) { return ( - {contentError.response.status === 404 && ( + {contentError.response?.status === 404 && ( {i18n._(`Inventory not found.`)}{' '} {i18n._(`View all Inventories.`)} @@ -111,7 +93,16 @@ function Inventory({ i18n, setBreadcrumb }) { return ( - {cardHeader} + {['edit', 'add', 'groups/', 'hosts/'].some(name => + location.pathname.includes(name) + ) ? null : ( + + + + + + + )} {inventory && [ + + + , + + + , + + + , + + + , + + + , + + + , ( - - )} - />, - } - />, - ( - - )} - />, - ( - - )} - />, - ( - - )} - />, - } - />, - , - - !hasContentLoading && ( - - {match.params.id && ( - - {i18n._(`View Inventory Details`)} - - )} - - ) - } - />, + + + {match.params.id && ( + + {i18n._(`View Inventory Details`)} + + )} + + , ]}