From 1942be7dc3c5afa0eebc1ddb627eb1bc36498f0c Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Thu, 12 Dec 2019 11:26:35 -0500 Subject: [PATCH] Checks for modified and create in Inv Group Deets Also includes refactoring for css over style prop and removed some unnecessary loading checks --- .../InventoryGroup/InventoryGroup.jsx | 16 +++-- .../InventoryGroupDetail.jsx | 60 +++++++++++-------- .../InventoryGroups/InventoryGroupsList.jsx | 2 +- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroup/InventoryGroup.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroup/InventoryGroup.jsx index b205182c04..db03a1ecf2 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroup/InventoryGroup.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroup/InventoryGroup.jsx @@ -121,15 +121,13 @@ function InventoryGroups({ i18n, match, setBreadcrumb, inventory, history }) { path="*" render={() => { return ( - !hasContentLoading && ( - - {inventory && ( - - {i18n._(t`View Inventory Details`)} - - )} - - ) + + {inventory && ( + + {i18n._(t`View Inventory Details`)} + + )} + ); }} /> diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupDetail/InventoryGroupDetail.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupDetail/InventoryGroupDetail.jsx index 7b383e986f..20d99538b8 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupDetail/InventoryGroupDetail.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupDetail/InventoryGroupDetail.jsx @@ -31,6 +31,8 @@ const ActionButtonWrapper = styled.div` function InventoryGroupDetail({ i18n, history, match, inventoryGroup }) { const { summary_fields: { created_by, modified_by }, + created, + modified, } = inventoryGroup; const [error, setError] = useState(false); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); @@ -45,8 +47,36 @@ function InventoryGroupDetail({ i18n, history, match, inventoryGroup }) { } }; + let createdBy = ''; + if (created) { + if (created_by && created_by.username) { + createdBy = ( + + {i18n._(t`${formatDateString(inventoryGroup.created)} by`)}{' '} + {created_by.username} + + ); + } else { + createdBy = i18n._(t`${formatDateString(inventoryGroup.created)} by`); + } + } + + let modifiedBy = ''; + if (modified) { + if (modified_by && modified_by.username) { + modifiedBy = ( + + {i18n._(t`${formatDateString(inventoryGroup.modified)} by`)}{' '} + {modified_by.username} + + ); + } else { + modifiedBy = i18n._(t`${formatDateString(inventoryGroup.modified)} by`); + } + } + return ( - + - {created_by && created_by.username && ( - - {i18n._(t`${formatDateString(inventoryGroup.created)} by`)}{' '} - - {created_by.username} - - - } - /> - )} - {modified_by && modified_by.username && ( - - {i18n._(t`${formatDateString(inventoryGroup.modified)} by`)}{' '} - - {modified_by.username} - - - } - /> + {createdBy && } + {modifiedBy && ( + )} diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx index 20f2578afe..1840c3815c 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroups/InventoryGroupsList.jsx @@ -16,7 +16,7 @@ import styled from 'styled-components'; import InventoryGroupItem from './InventoryGroupItem'; import InventoryGroupsDeleteModal from '../shared/InventoryGroupsDeleteModal'; -const QS_CONFIG = getQSConfig('host', { +const QS_CONFIG = getQSConfig('group', { page: 1, page_size: 20, order_by: 'name',