[pve-devel] [RFC manager] disable shutdown button when suspended

Dominik Csapak d.csapak at proxmox.com
Mon Apr 11 14:56:22 CEST 2016


since shutdown of a vm when it is suspended is not really nice,
(it hangs until we run in a timeout, then shuts down on resume)
we disable the button in this case.

since you cannot disable only the button portion of a splitbutton,
we do nothing on a click event and tone down the content, to
show that the button is disabled

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
this does not really look nice, because
it is not really clear why you cannot shutdown

would it be better to have a popup saying:
'you cannot shutdown when vm is paused'
or something like this?

 www/css/ext6-pve.css         |  5 +++++
 www/manager6/button/Split.js | 17 +++++++++++++++++
 www/manager6/qemu/Config.js  |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/www/css/ext6-pve.css b/www/css/ext6-pve.css
index 4895623..ff0c269 100644
--- a/www/css/ext6-pve.css
+++ b/www/css/ext6-pve.css
@@ -345,3 +345,8 @@
 .x-form-display-field-default {
     min-height: 20px;
 }
+
+/* for disabling the main button of a split button */
+.x-split-maindisabled {
+    opacity:0.5;
+}
diff --git a/www/manager6/button/Split.js b/www/manager6/button/Split.js
index 8ea65d2..e4db99c 100644
--- a/www/manager6/button/Split.js
+++ b/www/manager6/button/Split.js
@@ -20,6 +20,8 @@ Ext.define('PVE.button.Split', {
     // take special care in confirm box (select no as default).
     dangerous: false,
 
+    mainDisabled: false,
+
     handlerWrapper: function(button, event) {
 	var me = this;
 	var rec, msg;
@@ -30,6 +32,10 @@ Ext.define('PVE.button.Split', {
 	    }
 	}
 
+	if (me.mainDisabled === true) {
+	    return;
+	}
+
 	if (me.confirmMsg) {
 	    msg = me.confirmMsg;
 	    if (Ext.isFunction(me.confirmMsg)) {
@@ -53,6 +59,17 @@ Ext.define('PVE.button.Split', {
 	}
     },
 
+    setMainDisabled: function(value) {
+	var me = this;
+	if (value === true) {
+	    me.mainDisabled = true;
+	    me.btnEl.addCls('x-split-maindisabled');
+	} else if (value === false) {
+	    me.mainDisabled = false;
+	    me.btnEl.removeCls('x-split-maindisabled');
+	}
+    },
+
     initComponent: function() {
 	/*jslint confusion: true */
 
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 303fdef..8186042 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -241,9 +241,11 @@ Ext.define('PVE.qemu.Config', {
 	    if (qmpstatus === 'prelaunch' || qmpstatus === 'paused') {
 		startBtn.setVisible(false);
 		resumeBtn.setVisible(true);
+		shutdownBtn.setMainDisabled(true);
 	    } else {
 		startBtn.setVisible(true);
 		resumeBtn.setVisible(false);
+		shutdownBtn.setMainDisabled(false);
 	    }
 
 	    consoleBtn.setEnableSpice(spice);
-- 
2.1.4




More information about the pve-devel mailing list