diff --git a/awx/ui/client/src/inventories/hosts/host.list.js b/awx/ui/client/src/inventories/hosts/host.list.js index cc1a1aa613..ef6c19212e 100644 --- a/awx/ui/client/src/inventories/hosts/host.list.js +++ b/awx/ui/client/src/inventories/hosts/host.list.js @@ -103,11 +103,12 @@ export default ['i18n', function(i18n) { smart_inventory: { mode: 'all', ngClick: "smartInventory()", - awToolTip: "Create a new Smart Inventory from results.", + awToolTip: "Create a new Smart Inventory from search results.", actionClass: 'btn List-buttonDefault', buttonContent: 'SMART INVENTORY', ngShow: 'canAdd', dataPlacement: "top", + ngDisabled: '!activeHostSearch' } } }; diff --git a/awx/ui/client/src/inventories/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories/hosts/list/host-list.controller.js index eb3df91631..398a18a549 100644 --- a/awx/ui/client/src/inventories/hosts/list/host-list.controller.js +++ b/awx/ui/client/src/inventories/hosts/list/host-list.controller.js @@ -15,6 +15,7 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath, function init(){ $scope.canAdd = false; + $scope.activeHostSearch = false; rbacUiControlService.canAdd('hosts') .then(function(canAdd) { @@ -37,6 +38,21 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath, setJobStatus(); }); + $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams) { + if(toParams && toParams.host_search) { + let hasMoreThanDefaultKeys = false; + angular.forEach(toParams.host_search, function(value, key) { + if(key !== 'order_by' && key !== 'page_size') { + hasMoreThanDefaultKeys = true; + } + }); + $scope.activeHostSearch = hasMoreThanDefaultKeys ? true : false; + } + else { + $scope.activeHostSearch = false; + } + }); + } function setJobStatus(){