From 708d0698bccce0710b2733f6002b4a9310cca3c8 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Fri, 30 Jun 2017 18:56:03 -0400 Subject: [PATCH] Hide disassociate host from group when the host is not directly associated with the currently viewed group --- .../nested-hosts/group-nested-hosts-list.controller.js | 9 ++++++--- .../related/nested-hosts/group-nested-hosts.list.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) 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 54d090a181..a4e449f88b 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 @@ -29,8 +29,11 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat $scope.$watchCollection(list.name, function() { $scope[list.name] = _.map($scope.nested_hosts, function(value) { - value.inventory_name = value.summary_fields.inventory.name; - value.inventory_id = value.summary_fields.inventory.id; + angular.forEach(value.summary_fields.groups.results, function(directParentGroup) { + if(directParentGroup.id === parseInt($state.params.group_id)) { + value.can_disassociate = true; + } + }); return value; }); setJobStatus(); @@ -72,7 +75,7 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat } function setJobStatus(){ - _.forEach($scope.hosts, function(value) { + _.forEach($scope.nested_hosts, function(value) { SetStatus({ scope: $scope, host: value diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts.list.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts.list.js index 63afcd758e..ee7048f11d 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts.list.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts.list.js @@ -89,7 +89,7 @@ export default { icon: 'icon-trash', awToolTip: 'Disassociate host', dataPlacement: 'top', - ngShow: 'nested_host.summary_fields.user_capabilities.delete' + ngShow: 'nested_host.summary_fields.user_capabilities.delete && nested_host.can_disassociate' } },