diff --git a/awx/ui/client/legacy/styles/lists.less b/awx/ui/client/legacy/styles/lists.less index d1a8f0c853..28f9440438 100644 --- a/awx/ui/client/legacy/styles/lists.less +++ b/awx/ui/client/legacy/styles/lists.less @@ -147,6 +147,14 @@ table, tbody { color: @list-actn-icn-hov; } +.List-actionButton + .btn-disabled { + &:hover { + color: @default-icon-hov; + background-color: @list-actn-bg !important; + } + color: @default-icon-hov; +} + .List-actionButton--delete:hover { background-color: @list-actn-del-bg-hov !important; } @@ -217,7 +225,7 @@ table, tbody { margin-left: 52%; justify-content: flex-start; button { - height: 34px; + height: 34px; } } diff --git a/awx/ui/client/src/inventories-hosts/inventories/inventory.list.js b/awx/ui/client/src/inventories-hosts/inventories/inventory.list.js index c9fdb09755..5dadf977c6 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/inventory.list.js +++ b/awx/ui/client/src/inventories-hosts/inventories/inventory.list.js @@ -104,10 +104,11 @@ export default ['i18n', 'awxNetStrings' , function(i18n, awxNetStrings) { copy: { label: i18n._('Copy'), ngClick: 'copyInventory(inventory)', - "class": 'btn-danger btn-xs', - awToolTip: i18n._('Copy inventory'), + awToolTip: "{{ inventory.copyTip }}", + dataTipWatch: "inventory.copyTip", dataPlacement: 'top', - ngShow: '!inventory.pending_deletion && inventory.summary_fields.user_capabilities.copy' + ngShow: '!inventory.pending_deletion && inventory.summary_fields.user_capabilities.copy', + ngClass: 'inventory.copyClass' }, view: { label: i18n._('View'), diff --git a/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js index 6b5eb6b040..4a4b5d3e7f 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/list/inventory-list.controller.js @@ -40,6 +40,8 @@ function InventoriesList($scope, inventory.host_status_class = "Inventories-hostStatus"; if (inventory.has_inventory_sources) { + inventory.copyTip = i18n._('Inventories with sources cannot be copied'); + inventory.copyClass = "btn-disabled"; if (inventory.inventory_sources_with_failures > 0) { inventory.syncStatus = 'error'; inventory.syncTip = inventory.inventory_sources_with_failures + i18n._(' sources with sync failures. Click for details'); @@ -50,6 +52,8 @@ function InventoriesList($scope, } } else { + inventory.copyTip = i18n._('Copy Inventory'); + inventory.copyClass = ""; inventory.syncStatus = 'na'; inventory.syncTip = i18n._('Not configured for inventory sync.'); inventory.launch_class = "btn-disabled"; @@ -74,15 +78,17 @@ function InventoriesList($scope, } $scope.copyInventory = inventory => { - Wait('start'); - new Inventory('get', inventory.id) - .then(model => model.copy()) - .then(copy => $scope.editInventory(copy, true)) - .catch(({ data, status }) => { - const params = { hdr: 'Error!', msg: `Call to copy failed. Return status: ${status}` }; - ProcessErrors($scope, data, status, null, params); - }) - .finally(() => Wait('stop')); + if (!inventory.has_inventory_sources) { + Wait('start'); + new Inventory('get', inventory.id) + .then(model => model.copy()) + .then(copy => $scope.editInventory(copy, true)) + .catch(({ data, status }) => { + const params = { hdr: 'Error!', msg: `Call to copy failed. Return status: ${status}` }; + ProcessErrors($scope, data, status, null, params); + }) + .finally(() => Wait('stop')); + } }; $scope.goToGraph = function(inventory){