[pve-devel] [PATCH manager 2/2] use split button for shutdown/stop for vm/ct

Dominik Csapak d.csapak at proxmox.com
Mon Apr 4 12:35:24 CEST 2016


uses the new split button for the shutdown action
to reduse the number of buttons, and reduce confusion

also make the stop button 'dangerous'
(shows just a different symbol on the confirm dialog)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/lxc/Config.js  | 14 +++++++++-----
 www/manager6/qemu/Config.js | 25 +++++++++++++------------
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 8bf9078..f3a7430 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -55,21 +55,25 @@ Ext.define('PVE.lxc.Config', {
 	    }
 	});
 
-	var stopBtn = Ext.create('PVE.button.Button', {
+	var stopBtn = Ext.create('Ext.menu.Item',{
 	    text: gettext('Stop'),
 	    disabled: !caps.vms['VM.PowerMgmt'],
+	    dangerous: true,
 	    confirmMsg: Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid),
 	    handler: function() {
 		vm_command("stop");
 	    }
 	});
 
-	var shutdownBtn = Ext.create('PVE.button.Button', {
+	var shutdownBtn = Ext.create('PVE.button.Split', {
 	    text: gettext('Shutdown'),
 	    disabled: !caps.vms['VM.PowerMgmt'],
 	    confirmMsg: Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid),
 	    handler: function() {
 		vm_command('shutdown');
+	    },
+	    menu: {
+		items:[stopBtn]
 	    }
 	});
 
@@ -112,7 +116,7 @@ Ext.define('PVE.lxc.Config', {
 	Ext.apply(me, {
 	    title: Ext.String.format(gettext("Container {0} on node {1}"), descr, "'" + nodename + "'"),
 	    hstateid: 'lxctab',
-	    tbar: [ startBtn, shutdownBtn, umountBtn, stopBtn, removeBtn,
+	    tbar: [ startBtn, shutdownBtn, umountBtn, removeBtn,
 		    migrateBtn, consoleBtn ],
 	    defaults: { statusStore: me.statusStore },
 	    items: [
@@ -228,11 +232,11 @@ Ext.define('PVE.lxc.Config', {
 	    if (status === 'mounted') {
 		umountBtn.setDisabled(false);
 		umountBtn.setVisible(true);
-		stopBtn.setVisible(false);
+		stopBtn.setDisabled(true);
 	    } else {
 		umountBtn.setDisabled(true);
 		umountBtn.setVisible(false);
-		stopBtn.setVisible(true);
+		stopBtn.setDisabled(false);
 	    }
 	});
 
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 603b4c2..667b617 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -55,15 +55,6 @@ Ext.define('PVE.qemu.Config', {
 	    }
 	});
 
-	var stopBtn = Ext.create('PVE.button.Button', {
-	    text: gettext('Stop'),
-	    disabled: !caps.vms['VM.PowerMgmt'],
-	    confirmMsg: Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid),
-	    handler: function() {
-		vm_command("stop", { timeout: 30 });
-	    }
-	});
-
 	var migrateBtn = Ext.create('Ext.Button', {
 	    text: gettext('Migrate'),
 	    disabled: !caps.vms['VM.Migrate'],
@@ -86,12 +77,23 @@ Ext.define('PVE.qemu.Config', {
 	    }
 	});
 
-	var shutdownBtn = Ext.create('PVE.button.Button', {
+	var shutdownBtn = Ext.create('PVE.button.Split', {
 	    text: gettext('Shutdown'),
 	    disabled: !caps.vms['VM.PowerMgmt'],
 	    confirmMsg: Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid),
 	    handler: function() {
 		vm_command('shutdown');
+	    },
+	    menu: {
+		items: [{
+		    text: gettext('Stop'),
+		    disabled: !caps.vms['VM.PowerMgmt'],
+		    dangerous: true,
+		    confirmMsg: Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid),
+		    handler: function() {
+			vm_command("stop", { timeout: 30 });
+		    }
+		}]
 	    }
 	});
 
@@ -121,7 +123,7 @@ Ext.define('PVE.qemu.Config', {
 	Ext.apply(me, {
 	    title: Ext.String.format(gettext("Virtual Machine {0} on node {1}"), descr, "'" + nodename + "'"),
 	    hstateid: 'kvmtab',
-	    tbar: [ resumeBtn, startBtn, shutdownBtn, stopBtn, resetBtn,
+	    tbar: [ resumeBtn, startBtn, shutdownBtn, resetBtn,
 		    removeBtn, migrateBtn, consoleBtn],
 	    defaults: { statusStore: me.statusStore },
 	    items: [
@@ -241,7 +243,6 @@ Ext.define('PVE.qemu.Config', {
 	    startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
 	    resetBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running' || template);
 	    shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
-	    stopBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'stopped');
 	    removeBtn.setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
 	    consoleBtn.setDisabled(template);
 	});
-- 
2.1.4





More information about the pve-devel mailing list