From 8abf084211a05056315d25689e71e398d7ec8503 Mon Sep 17 00:00:00 2001
From: Ryan Petrello
Date: Mon, 20 Feb 2017 12:09:06 -0500
Subject: [PATCH] disable the on/off toggle button for hosts from dynamic
inventory.
see: #5420
---
.../hosts/dashboard-hosts-edit.controller.js | 3 +++
.../hosts/dashboard-hosts-list.controller.js | 3 +++
.../src/dashboard/hosts/dashboard-hosts.form.js | 2 +-
.../src/dashboard/hosts/dashboard-hosts.list.js | 1 +
awx/ui/client/src/forms/Hosts.js | 1 +
.../inventories/manage/hosts/hosts-add.controller.js | 3 +++
.../manage/hosts/hosts-edit.controller.js | 3 +++
.../client/src/scheduler/scheduleToggle.block.less | 12 +++++++++++-
awx/ui/client/src/shared/form-generator.js | 2 ++
awx/ui/client/src/shared/generator-helpers.js | 1 +
10 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/awx/ui/client/src/dashboard/hosts/dashboard-hosts-edit.controller.js b/awx/ui/client/src/dashboard/hosts/dashboard-hosts-edit.controller.js
index 3edbe6de90..2426a2bed8 100644
--- a/awx/ui/client/src/dashboard/hosts/dashboard-hosts-edit.controller.js
+++ b/awx/ui/client/src/dashboard/hosts/dashboard-hosts-edit.controller.js
@@ -12,6 +12,9 @@
$state.go('^', null, {reload: true});
};
$scope.toggleHostEnabled = function(){
+ if ($scope.host.has_inventory_sources){
+ return;
+ }
$scope.host.enabled = !$scope.host.enabled;
};
$scope.toggleEnabled = function(){
diff --git a/awx/ui/client/src/dashboard/hosts/dashboard-hosts-list.controller.js b/awx/ui/client/src/dashboard/hosts/dashboard-hosts-list.controller.js
index 3ebf7dd370..b4ce108167 100644
--- a/awx/ui/client/src/dashboard/hosts/dashboard-hosts-list.controller.js
+++ b/awx/ui/client/src/dashboard/hosts/dashboard-hosts-list.controller.js
@@ -43,6 +43,9 @@ export default ['$scope', '$state', '$stateParams', 'GetBasePath', 'DashboardHos
};
$scope.toggleHostEnabled = function(host) {
+ if (host.has_inventory_sources){
+ return;
+ }
DashboardHostService.setHostStatus(host, !host.enabled)
.then(function(res) {
var index = _.findIndex($scope.hosts, function(o) {
diff --git a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.form.js b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.form.js
index e12d61c340..1344786990 100644
--- a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.form.js
+++ b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.form.js
@@ -19,7 +19,6 @@ export default ['i18n', function(i18n){
class: 'Form-header-field',
ngClick: 'toggleHostEnabled()',
type: 'toggle',
-
awToolTip: "" +
i18n._("Indicates if a host is available and should be included in running jobs.") +
"
" +
@@ -28,6 +27,7 @@ export default ['i18n', function(i18n){
" sync process.") +
"
",
dataTitle: i18n._('Host Enabled'),
+ ngDisabled: 'host.has_inventory_sources'
}
},
fields: {
diff --git a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js
index 9449600c67..b9162dccac 100644
--- a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js
+++ b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js
@@ -52,6 +52,7 @@ export default [ 'i18n', function(i18n){
nosort: true,
awToolTip: "" + i18n._("Indicates if a host is available and should be included in running jobs.") + "
" + i18n._("For hosts that are part of an external inventory, this flag cannot be changed. It will be set by the inventory sync process.") + "
",
dataTitle: i18n._('Host Enabled'),
+ ngDisabled: 'host.has_inventory_sources'
}
},
diff --git a/awx/ui/client/src/forms/Hosts.js b/awx/ui/client/src/forms/Hosts.js
index d378993b2a..ef9c7d62d0 100644
--- a/awx/ui/client/src/forms/Hosts.js
+++ b/awx/ui/client/src/forms/Hosts.js
@@ -36,6 +36,7 @@ export default
" set by the inventory sync process.") +
"
",
dataTitle: i18n._('Host Enabled'),
+ ngDisabled: 'host.has_inventory_sources'
}
},
fields: {
diff --git a/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js b/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js
index 503baaf584..7042800ee2 100644
--- a/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js
+++ b/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js
@@ -34,6 +34,9 @@ export default ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange
$state.go('^');
};
$scope.toggleHostEnabled = function() {
+ if ($scope.host.has_inventory_sources){
+ return;
+ }
$scope.host.enabled = !$scope.host.enabled;
};
$scope.formSave = function(){
diff --git a/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js b/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js
index ec825bf510..47ac724664 100644
--- a/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js
+++ b/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js
@@ -63,6 +63,9 @@
$state.go('^');
};
$scope.toggleHostEnabled = function(){
+ if ($scope.host.has_inventory_sources){
+ return;
+ }
$scope.host.enabled = !$scope.host.enabled;
};
$scope.formSave = function(){
diff --git a/awx/ui/client/src/scheduler/scheduleToggle.block.less b/awx/ui/client/src/scheduler/scheduleToggle.block.less
index 9733274bfe..8beac5b45c 100644
--- a/awx/ui/client/src/scheduler/scheduleToggle.block.less
+++ b/awx/ui/client/src/scheduler/scheduleToggle.block.less
@@ -11,12 +11,21 @@
cursor: pointer;
display: flex;
height: 18px;
+
+ &.ScheduleToggle--disabled {
+ cursor: not-allowed;
+ border-color: @b7grey !important;
+ .ScheduleToggle-switch {
+ background-color: @b7grey !important;
+ cursor: not-allowed;
+ }
+ }
}
.ScheduleToggle-switch {
color: @default-interface-txt;
background-color: @default-bg;
- margin-left: 4px;
+ margin-left: 7px;
border-left: 1px solid @default-icon;
margin-right: 0px;
text-align: center;
@@ -28,6 +37,7 @@
margin-top: 0px;
border-top: 0px;
border-bottom: 0px;
+ border-right: 0px;
}
.ScheduleToggle.is-on {
diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js
index 90abc6c119..09988733ee 100644
--- a/awx/ui/client/src/shared/form-generator.js
+++ b/awx/ui/client/src/shared/form-generator.js
@@ -545,6 +545,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += " " + field.columnClass;
html += "\">