From 9192829de2c8850e5affef9669b69b5a1e5471ac Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Wed, 25 Apr 2018 12:54:08 -0400 Subject: [PATCH] [UI] Org Admin permissions for Instance Groups --- .../capacity-adjuster/capacity-adjuster.directive.js | 4 ++-- .../capacity-adjuster/capacity-adjuster.partial.html | 1 + .../instances/instances-list.partial.html | 12 ++++++++---- .../instances/instances.controller.js | 10 ++++++++++ .../list/instance-groups-list.controller.js | 7 +++++++ .../list/instance-groups-list.partial.html | 3 ++- .../client/src/scheduler/scheduleToggle.block.less | 3 ++- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.directive.js b/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.directive.js index 5600502578..e36916aca8 100644 --- a/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.directive.js +++ b/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.directive.js @@ -1,7 +1,8 @@ function CapacityAdjuster (templateUrl, ProcessErrors, Wait) { return { scope: { - state: '=' + state: '=', + disabled: '@' }, templateUrl: templateUrl('instance-groups/capacity-adjuster/capacity-adjuster'), restrict: 'E', @@ -17,7 +18,6 @@ function CapacityAdjuster (templateUrl, ProcessErrors, Wait) { scope.min_capacity = _.min(adjustment_values, 'value'); scope.max_capacity = _.max(adjustment_values, 'value'); - }, controller: function($http) { const vm = this || {}; diff --git a/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.partial.html b/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.partial.html index c6a5bca81b..f486745fae 100644 --- a/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.partial.html +++ b/awx/ui/client/src/instance-groups/capacity-adjuster/capacity-adjuster.partial.html @@ -8,6 +8,7 @@ min="0" max="1" step="0.1" + ng-disabled="{{disabled}}" ng-change="vm.slide(state)"/>

{{max_capacity.label}} {{max_capacity.value}}

diff --git a/awx/ui/client/src/instance-groups/instances/instances-list.partial.html b/awx/ui/client/src/instance-groups/instances/instances-list.partial.html index 59d459a70b..5a7a26021d 100644 --- a/awx/ui/client/src/instance-groups/instances/instances-list.partial.html +++ b/awx/ui/client/src/instance-groups/instances/instances-list.partial.html @@ -27,6 +27,7 @@ type="button" ng-click="$state.go('instanceGroups.instances.modal.add')" class="at-Button--add" + ng-show="vm.isSuperuser" aria-expanded="false">
@@ -37,15 +38,18 @@ ng-class="{'at-Row--active': (instance.id === vm.activeId)}">
+ ng-class="{'is-on': instance.enabled, + 'ScheduleToggle--disabled': vm.rowAction.toggle._disabled}">
@@ -63,7 +67,7 @@
- +
diff --git a/awx/ui/client/src/instance-groups/instances/instances.controller.js b/awx/ui/client/src/instance-groups/instances/instances.controller.js index 26d6ef3e71..87281efae1 100644 --- a/awx/ui/client/src/instance-groups/instances/instances.controller.js +++ b/awx/ui/client/src/instance-groups/instances/instances.controller.js @@ -5,6 +5,7 @@ function InstancesController ($scope, $state, $http, models, Instance, strings, vm.panelTitle = instanceGroup.get('name'); vm.instances = instanceGroup.get('related.instances.results'); vm.instance_group_id = instanceGroup.get('id'); + vm.isSuperuser = $scope.$root.user_is_superuser; init(); @@ -47,6 +48,15 @@ function InstancesController ($scope, $state, $http, models, Instance, strings, } }; + vm.rowAction = { + toggle: { + _disabled: !vm.isSuperuser + }, + capacity_adjustment: { + _disabled: !vm.isSuperuser + } + }; + vm.toggle = (toggled) => { const instance = _.find(vm.instances, 'id', toggled.id); instance.enabled = !instance.enabled; diff --git a/awx/ui/client/src/instance-groups/list/instance-groups-list.controller.js b/awx/ui/client/src/instance-groups/list/instance-groups-list.controller.js index 97990c8679..b3eccaffab 100644 --- a/awx/ui/client/src/instance-groups/list/instance-groups-list.controller.js +++ b/awx/ui/client/src/instance-groups/list/instance-groups-list.controller.js @@ -4,6 +4,7 @@ export default ['$scope', '$filter', '$state', 'Alert', 'resolvedModels', 'Datas const { instanceGroup } = resolvedModels; vm.strings = strings; + vm.isSuperuser = $scope.$root.user_is_superuser; init(); @@ -32,6 +33,12 @@ export default ['$scope', '$filter', '$state', 'Alert', 'resolvedModels', 'Datas vm.activeId = parseInt($state.params.instance_group_id); }); + vm.rowAction = { + trash: instance_group => { + return vm.isSuperuser && instance_group.name !== 'tower'; + } + }; + vm.deleteInstanceGroup = instance_group => { if (!instance_group) { Alert(strings.get('error.DELETE'), strings.get('alert.MISSING_PARAMETER')); diff --git a/awx/ui/client/src/instance-groups/list/instance-groups-list.partial.html b/awx/ui/client/src/instance-groups/list/instance-groups-list.partial.html index e09f28cbe5..8d75d6bc72 100644 --- a/awx/ui/client/src/instance-groups/list/instance-groups-list.partial.html +++ b/awx/ui/client/src/instance-groups/list/instance-groups-list.partial.html @@ -23,6 +23,7 @@ type="button" ui-sref="instanceGroups.add" class="at-Button--add" + ng-show="vm.isSuperuser" aria-haspopup="true" aria-expanded="false"> @@ -60,7 +61,7 @@
- +
diff --git a/awx/ui/client/src/scheduler/scheduleToggle.block.less b/awx/ui/client/src/scheduler/scheduleToggle.block.less index 49bcc954f7..b234a0b5f2 100644 --- a/awx/ui/client/src/scheduler/scheduleToggle.block.less +++ b/awx/ui/client/src/scheduler/scheduleToggle.block.less @@ -20,7 +20,8 @@ &.ScheduleToggle--disabled { cursor: not-allowed; - border-color: @default-link !important; + background-color: none; + border-color: @d7grey !important; .ScheduleToggle-switch { background-color: @d7grey !important; cursor: not-allowed;