diff --git a/awx/ui_next/src/app.scss b/awx/ui_next/src/app.scss
index edf29254b3..f0ba17e429 100644
--- a/awx/ui_next/src/app.scss
+++ b/awx/ui_next/src/app.scss
@@ -183,10 +183,6 @@
z-index: 20;
}
-.at-u-textRight {
- text-align: right;
-}
-
//
// AlertModal styles
//
diff --git a/awx/ui_next/src/screens/Inventory/Inventories.jsx b/awx/ui_next/src/screens/Inventory/Inventories.jsx
index 4253078486..aa58a7a0b2 100644
--- a/awx/ui_next/src/screens/Inventory/Inventories.jsx
+++ b/awx/ui_next/src/screens/Inventory/Inventories.jsx
@@ -85,22 +85,16 @@ class Inventories extends Component {
path={`${match.path}/smart_inventory/add`}
render={() => }
/>
- (
-
- {({ me }) => (
-
- )}
-
- )}
- />
+
+
+ {({ me }) => (
+
+ )}
+
+
(
diff --git a/awx/ui_next/src/screens/Inventory/Inventory.jsx b/awx/ui_next/src/screens/Inventory/Inventory.jsx
index e632610660..8c7efe089f 100644
--- a/awx/ui_next/src/screens/Inventory/Inventory.jsx
+++ b/awx/ui_next/src/screens/Inventory/Inventory.jsx
@@ -2,7 +2,15 @@ import React, { useEffect, useState } from 'react';
import { t } from '@lingui/macro';
import { withI18n } from '@lingui/react';
import { Card, PageSection } from '@patternfly/react-core';
-import { Switch, Route, Redirect, withRouter, Link } from 'react-router-dom';
+import {
+ Switch,
+ Route,
+ Redirect,
+ Link,
+ useHistory,
+ useLocation,
+ useRouteMatch,
+} from 'react-router-dom';
import { TabbedCardHeader } from '@components/Card';
import CardCloseButton from '@components/CardCloseButton';
import ContentError from '@components/ContentError';
@@ -17,10 +25,15 @@ import InventorySources from './InventorySources';
import { InventoriesAPI } from '@api';
import InventoryEdit from './InventoryEdit';
-function Inventory({ history, i18n, location, match, setBreadcrumb }) {
+function Inventory({ i18n, setBreadcrumb }) {
const [contentError, setContentError] = useState(null);
const [hasContentLoading, setHasContentLoading] = useState(true);
const [inventory, setInventory] = useState(null);
+ const history = useHistory();
+ const location = useLocation();
+ const match = useRouteMatch({
+ path: '/inventories/inventory/:id',
+ });
useEffect(() => {
async function fetchData() {
@@ -36,7 +49,7 @@ function Inventory({ history, i18n, location, match, setBreadcrumb }) {
}
fetchData();
- }, [match.params.id, setBreadcrumb]);
+ }, [match.params.id, location.pathname, setBreadcrumb]);
const tabsArray = [
{ name: i18n._(t`Details`), link: `${match.url}/details`, id: 0 },
@@ -132,7 +145,6 @@ function Inventory({ history, i18n, location, match, setBreadcrumb }) {
@@ -178,4 +190,4 @@ function Inventory({ history, i18n, location, match, setBreadcrumb }) {
}
export { Inventory as _Inventory };
-export default withI18n()(withRouter(Inventory));
+export default withI18n()(Inventory);
diff --git a/awx/ui_next/src/screens/Inventory/Inventory.test.jsx b/awx/ui_next/src/screens/Inventory/Inventory.test.jsx
index f242b01a7d..2ec0aa040e 100644
--- a/awx/ui_next/src/screens/Inventory/Inventory.test.jsx
+++ b/awx/ui_next/src/screens/Inventory/Inventory.test.jsx
@@ -7,6 +7,13 @@ import mockInventory from './shared/data.inventory.json';
import Inventory from './Inventory';
jest.mock('@api');
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useRouteMatch: () => ({
+ url: '/inventories/1',
+ params: { id: 1 },
+ }),
+}));
InventoriesAPI.readDetail.mockResolvedValue({
data: mockInventory,
@@ -17,9 +24,7 @@ describe('', () => {
test('initially renders succesfully', async () => {
await act(async () => {
- wrapper = mountWithContexts(
- {}} match={{ params: { id: 1 } }} />
- );
+ wrapper = mountWithContexts( {}} />);
});
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
await waitForElement(wrapper, '.pf-c-tabs__item', el => el.length === 6);
diff --git a/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx b/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx
index f5ec4bd931..0dfa05ae2e 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryEdit/InventoryEdit.jsx
@@ -90,12 +90,15 @@ function InventoryEdit({ inventory }) {
setError(err);
}
};
+
if (contentLoading) {
return ;
}
+
if (error) {
return ;
}
+
return (
this.handleSelect(inventory)}
isSelected={selected.some(row => row.id === inventory.id)}