diff --git a/awx/ui/client/src/inventories-hosts/hosts/host.list.js b/awx/ui/client/src/inventories-hosts/hosts/host.list.js index e91eebb30b..2422666878 100644 --- a/awx/ui/client/src/inventories-hosts/hosts/host.list.js +++ b/awx/ui/client/src/inventories-hosts/hosts/host.list.js @@ -104,12 +104,14 @@ export default ['i18n', function(i18n) { smart_inventory: { mode: 'all', ngClick: "smartInventory()", - awToolTip: i18n._("Create a new Smart Inventory from search results."), + awToolTip: "{{ smartInventoryButtonTooltip }}", + dataTipWatch: 'smartInventoryButtonTooltip', actionClass: 'btn List-buttonDefault', buttonContent: i18n._('SMART INVENTORY'), ngShow: 'canAdd && (hosts.length > 0 || !(searchTags | isEmpty))', dataPlacement: "top", - ngDisabled: '!enableSmartInventoryButton' + ngDisabled: '!enableSmartInventoryButton', + showTipWhenDisabled: true } } }; diff --git a/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js index 52a565b40c..693d403ea5 100644 --- a/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/hosts/list/host-list.controller.js @@ -7,7 +7,7 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath, rbacUiControlService, Dataset, $state, $filter, Prompt, Wait, - HostsService, SetStatus, canAdd) { + HostsService, SetStatus, canAdd, InventoryHostsStrings) { let list = HostsList; @@ -16,6 +16,7 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath, function init(){ $scope.canAdd = canAdd; $scope.enableSmartInventoryButton = false; + $scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); // Search init $scope.list = list; @@ -37,14 +38,16 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath, if(toParams && toParams.host_search) { let hasMoreThanDefaultKeys = false; angular.forEach(toParams.host_search, function(value, key) { - if(key !== 'order_by' && key !== 'page_size') { + if(key !== 'order_by' && key !== 'page_size' && key !== 'page') { hasMoreThanDefaultKeys = true; } }); $scope.enableSmartInventoryButton = hasMoreThanDefaultKeys ? true : false; + $scope.smartInventoryButtonTooltip = hasMoreThanDefaultKeys ? InventoryHostsStrings.get('smartinventorybutton.ENABLED_INSTRUCTIONS') : InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); } else { $scope.enableSmartInventoryButton = false; + $scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); } }); @@ -114,5 +117,5 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath, export default ['$scope', 'HostsList', '$rootScope', 'GetBasePath', 'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait', - 'HostsService', 'SetStatus', 'canAdd', HostsList + 'HostsService', 'SetStatus', 'canAdd', 'InventoryHostsStrings', HostsList ]; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js index f86a550218..056b61cf96 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js @@ -6,10 +6,10 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePath', 'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait', - 'HostsService', 'SetStatus', 'canAdd', 'GroupsService', 'ProcessErrors', 'groupData', 'inventoryData', + 'HostsService', 'SetStatus', 'canAdd', 'GroupsService', 'ProcessErrors', 'groupData', 'inventoryData', 'InventoryHostsStrings', function($scope, NestedHostsListDefinition, $rootScope, GetBasePath, rbacUiControlService, Dataset, $state, $filter, Prompt, Wait, - HostsService, SetStatus, canAdd, GroupsService, ProcessErrors, groupData, inventoryData) { + HostsService, SetStatus, canAdd, GroupsService, ProcessErrors, groupData, inventoryData, InventoryHostsStrings) { let list = NestedHostsListDefinition; @@ -19,6 +19,7 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat $scope.canAdd = canAdd; $scope.enableSmartInventoryButton = false; $scope.disassociateFrom = groupData; + $scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); // Search init $scope.list = list; @@ -50,14 +51,16 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat if(toParams && toParams.host_search) { let hasMoreThanDefaultKeys = false; angular.forEach(toParams.host_search, function(value, key) { - if(key !== 'order_by' && key !== 'page_size') { + if(key !== 'order_by' && key !== 'page_size' && key !== 'page') { hasMoreThanDefaultKeys = true; } }); $scope.enableSmartInventoryButton = hasMoreThanDefaultKeys ? true : false; + $scope.smartInventoryButtonTooltip = hasMoreThanDefaultKeys ? InventoryHostsStrings.get('smartinventorybutton.ENABLED_INSTRUCTIONS') : InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); } else { $scope.enableSmartInventoryButton = false; + $scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); } }); diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js index c19110b627..11507bb8c8 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js @@ -7,10 +7,10 @@ // import HostsService from './../hosts/host.service'; export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath', 'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait', - 'HostsService', 'SetStatus', 'canAdd', 'i18n', + 'HostsService', 'SetStatus', 'canAdd', 'i18n', 'InventoryHostsStrings', function($scope, ListDefinition, $rootScope, GetBasePath, rbacUiControlService, Dataset, $state, $filter, Prompt, Wait, - HostsService, SetStatus, canAdd, i18n) { + HostsService, SetStatus, canAdd, i18n, InventoryHostsStrings) { let list = ListDefinition; @@ -19,6 +19,7 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath', function init(){ $scope.canAdd = canAdd; $scope.enableSmartInventoryButton = false; + $scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); // Search init $scope.list = list; @@ -45,14 +46,16 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath', if(toParams && toParams.host_search) { let hasMoreThanDefaultKeys = false; angular.forEach(toParams.host_search, function(value, key) { - if(key !== 'order_by' && key !== 'page_size') { + if(key !== 'order_by' && key !== 'page_size' && key !== 'page') { hasMoreThanDefaultKeys = true; } }); $scope.enableSmartInventoryButton = hasMoreThanDefaultKeys ? true : false; + $scope.smartInventoryButtonTooltip = hasMoreThanDefaultKeys ? InventoryHostsStrings.get('smartinventorybutton.ENABLED_INSTRUCTIONS') : InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); } else { $scope.enableSmartInventoryButton = false; + $scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS'); } }); diff --git a/awx/ui/client/src/inventories-hosts/inventory-hosts.strings.js b/awx/ui/client/src/inventories-hosts/inventory-hosts.strings.js index c64b73a933..6c46f7c9d5 100644 --- a/awx/ui/client/src/inventories-hosts/inventory-hosts.strings.js +++ b/awx/ui/client/src/inventories-hosts/inventory-hosts.strings.js @@ -28,6 +28,11 @@ function InventoryHostsStrings (BaseString) { MISSING_PERMISSIONS: t.s('You do not have sufficient permissions to edit the host filter.') } }; + + ns.smartinventorybutton = { + DISABLED_INSTRUCTIONS: "Please enter at least one search term to create a new Smart Inventory.", + ENABLED_INSTRUCTIONS: "Create a new Smart Inventory from search results." + }; } InventoryHostsStrings.$inject = ['BaseStringService'];