{addSmartInventory}
,
+
+ {addConstructedInventory}
+ ,
]}
/>
);
@@ -261,11 +271,6 @@ function InventoryList() {
inventory={inventory}
rowIndex={index}
fetchInventories={fetchInventories}
- detailUrl={
- inventory.kind === 'smart'
- ? `${match.url}/smart_inventory/${inventory.id}/details`
- : `${match.url}/inventory/${inventory.id}/details`
- }
onSelect={() => {
if (!inventory.pending_deletion) {
handleSelect(inventory);
diff --git a/awx/ui/src/screens/Inventory/InventoryList/InventoryListItem.js b/awx/ui/src/screens/Inventory/InventoryList/InventoryListItem.js
index c692c32f51..3828401045 100644
--- a/awx/ui/src/screens/Inventory/InventoryList/InventoryListItem.js
+++ b/awx/ui/src/screens/Inventory/InventoryList/InventoryListItem.js
@@ -1,5 +1,5 @@
import React, { useState, useCallback } from 'react';
-import { string, bool, func } from 'prop-types';
+import { bool, func } from 'prop-types';
import { Button, Label } from '@patternfly/react-core';
import { Tr, Td } from '@patternfly/react-table';
@@ -12,6 +12,7 @@ import { Inventory } from 'types';
import { ActionsTd, ActionItem, TdBreakWord } from 'components/PaginatedTable';
import CopyButton from 'components/CopyButton';
import StatusLabel from 'components/StatusLabel';
+import { getInventoryPath } from '../shared/utils';
function InventoryListItem({
inventory,
@@ -19,12 +20,10 @@ function InventoryListItem({
isSelected,
onSelect,
onCopy,
- detailUrl,
fetchInventories,
}) {
InventoryListItem.propTypes = {
inventory: Inventory.isRequired,
- detailUrl: string.isRequired,
isSelected: bool.isRequired,
onSelect: func.isRequired,
};
@@ -50,6 +49,12 @@ function InventoryListItem({
const labelId = `check-action-${inventory.id}`;
+ const typeLabel = {
+ '': t`Inventory`,
+ smart: t`Smart Inventory`,
+ constructed: t`Constructed Inventory`,
+ };
+
let syncStatus = 'disabled';
if (inventory.isSourceSyncRunning) {
syncStatus = 'syncing';
@@ -93,16 +98,20 @@ function InventoryListItem({
{inventory.pending_deletion ? (
{inventory.name}
) : (
-
+
{inventory.name}
)}
|
- {inventory.kind !== 'smart' &&
+ {inventory.kind === '' &&
(inventory.has_inventory_sources ? (
))}
|
-
- {inventory.kind === 'smart' ? t`Smart Inventory` : t`Inventory`}
- |
+ {typeLabel[inventory.kind]} |
diff --git a/awx/ui/src/screens/Inventory/SmartInventory.js b/awx/ui/src/screens/Inventory/SmartInventory.js
index 952cf5dc31..b91d253dc6 100644
--- a/awx/ui/src/screens/Inventory/SmartInventory.js
+++ b/awx/ui/src/screens/Inventory/SmartInventory.js
@@ -23,6 +23,7 @@ import RelatedTemplateList from 'components/RelatedTemplateList';
import SmartInventoryDetail from './SmartInventoryDetail';
import SmartInventoryEdit from './SmartInventoryEdit';
import SmartInventoryHosts from './SmartInventoryHosts';
+import { getInventoryPath } from './shared/utils';
function SmartInventory({ setBreadcrumb }) {
const location = useLocation();
@@ -101,8 +102,8 @@ function SmartInventory({ setBreadcrumb }) {
);
}
- if (inventory?.kind === '') {
- return ;
+ if (inventory && inventory?.kind !== 'smart') {
+ return ;
}
let showCardHeader = true;
diff --git a/awx/ui/src/screens/Inventory/shared/utils.js b/awx/ui/src/screens/Inventory/shared/utils.js
index c08710327f..5e335beeed 100644
--- a/awx/ui/src/screens/Inventory/shared/utils.js
+++ b/awx/ui/src/screens/Inventory/shared/utils.js
@@ -8,3 +8,12 @@ const parseHostFilter = (value) => {
return value;
};
export default parseHostFilter;
+
+export function getInventoryPath(inventory) {
+ const url = {
+ '': `/inventories/inventory/${inventory.id}`,
+ smart: `/inventories/smart_inventory/${inventory.id}`,
+ constructed: `/inventories/constructed_inventory/${inventory.id}`,
+ };
+ return url[inventory.kind];
+}
diff --git a/awx/ui/src/screens/Inventory/shared/utils.test.js b/awx/ui/src/screens/Inventory/shared/utils.test.js
index 4d659932f7..ccbf44aff1 100644
--- a/awx/ui/src/screens/Inventory/shared/utils.test.js
+++ b/awx/ui/src/screens/Inventory/shared/utils.test.js
@@ -1,4 +1,4 @@
-import parseHostFilter from './utils';
+import parseHostFilter, { getInventoryPath } from './utils';
describe('parseHostFilter', () => {
test('parse host filter', () => {
@@ -19,3 +19,21 @@ describe('parseHostFilter', () => {
});
});
});
+
+describe('getInventoryPath', () => {
+ test('should return inventory path', () => {
+ expect(getInventoryPath({ id: 1, kind: '' })).toMatch(
+ '/inventories/inventory/1'
+ );
+ });
+ test('should return smart inventory path', () => {
+ expect(getInventoryPath({ id: 2, kind: 'smart' })).toMatch(
+ '/inventories/smart_inventory/2'
+ );
+ });
+ test('should return constructed inventory path', () => {
+ expect(getInventoryPath({ id: 3, kind: 'constructed' })).toMatch(
+ '/inventories/constructed_inventory/3'
+ );
+ });
+});