diff --git a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal.directive.js b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal.directive.js
index 56998865da..541214e5db 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal.directive.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal.directive.js
@@ -2,7 +2,8 @@ export default ['templateUrl', function(templateUrl) {
return {
restrict: 'E',
scope: {
- hostFilter: '='
+ hostFilter: '=',
+ organization: '='
},
templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal'),
link: function(scope, element) {
@@ -27,12 +28,14 @@ export default ['templateUrl', function(templateUrl) {
$scope.host_default_params = {
order_by: 'name',
- page_size: 5
+ page_size: 5,
+ inventory__organization: null
};
$scope.host_queryset = _.merge({
order_by: 'name',
- page_size: 5
+ page_size: 5,
+ inventory__organization: $scope.organization
}, $scope.hostFilter ? $scope.hostFilter : {});
// Fire off the initial search
diff --git a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js
index e9222f8b0c..1c28668deb 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js
@@ -8,7 +8,14 @@ export default ['$scope', 'QuerySet', 'InventoryHostsStrings',
function($scope, qs, InventoryHostsStrings) {
$scope.hostFilterTags = [];
- $scope.filterTooltip = $scope.fieldIsDisabled ? '' : InventoryHostsStrings.get('smartinventories.TOOLTIP');
+ $scope.$watch('organization', function(){
+ if($scope.hasEditPermissions) {
+ $scope.filterTooltip = $scope.organization ? InventoryHostsStrings.get('smartinventories.hostfilter.INSTRUCTIONS') : InventoryHostsStrings.get('smartinventories.hostfilter.MISSING_ORG');
+ }
+ else {
+ $scope.filterTooltip = InventoryHostsStrings.get('smartinventories.hostfilter.MISSING_PERMISSIONS');
+ }
+ });
$scope.$watch('hostFilter', function(){
$scope.hostFilterTags = [];
diff --git a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.directive.js b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.directive.js
index 2bfb654e3e..dd60d0e736 100644
--- a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.directive.js
+++ b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.directive.js
@@ -11,14 +11,15 @@ export default ['templateUrl', '$compile',
return {
scope: {
hostFilter: '=',
- fieldIsDisabled: '='
+ hasEditPermissions: '=',
+ organization: '='
},
restrict: 'E',
templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter'),
controller: smartInventoryHostFilterController,
link: function(scope) {
scope.openHostFilterModal = function() {
- $('#content-container').append($compile('
" + i18n._("Populate the hosts for this inventory by using a search filter.") + "
" + i18n._("Example: ansible_facts.ansible_distribution:\"RedHat\"") + "
" + i18n._("Refer to the Ansible Tower documentation for further syntax and examples.") + "
", dataTitle: i18n._('Smart Host Filter'), dataPlacement: 'right', 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 56cd3d9ba4..c64b73a933 100644 --- a/awx/ui/client/src/inventories-hosts/inventory-hosts.strings.js +++ b/awx/ui/client/src/inventories-hosts/inventory-hosts.strings.js @@ -22,7 +22,11 @@ function InventoryHostsStrings (BaseString) { }; ns.smartinventories = { - TOOLTIP: t.s('Please click the icon to edit the host filter.') + hostfilter: { + MISSING_ORG: t.s('Please select an organization before editing the host filter.'), + INSTRUCTIONS: t.s('Please click the icon to edit the host filter.'), + MISSING_PERMISSIONS: t.s('You do not have sufficient permissions to edit the host filter.') + } }; }