[pve-devel] [PATCH widget-toolkit 08/11] disk list: move title bar initialization to initComponent

Fabian Ebner f.ebner at proxmox.com
Fri Apr 23 12:14:58 CEST 2021


to conditionally add more buttons later on.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/panel/DiskList.js | 80 ++++++++++++++++++++++++-------------------
 1 file changed, 44 insertions(+), 36 deletions(-)

diff --git a/src/panel/DiskList.js b/src/panel/DiskList.js
index 10cf840..c6f1638 100644
--- a/src/panel/DiskList.js
+++ b/src/panel/DiskList.js
@@ -206,42 +206,6 @@ Ext.define('Proxmox.DiskList', {
 	return v ? `${v}${extendedInfo}` : Proxmox.Utils.noText;
     },
 
-    tbar: [
-	{
-	    text: gettext('Reload'),
-	    handler: 'reload',
-	},
-	{
-	    xtype: 'proxmoxButton',
-	    text: gettext('Show S.M.A.R.T. values'),
-	    parentXType: 'treepanel',
-	    disabled: true,
-	    enableFn: function(rec) {
-		if (!rec || rec.data.parent) {
-		    return false;
-		} else {
-		    return true;
-		}
-	    },
-	    handler: 'openSmartWindow',
-	},
-	{
-	    xtype: 'proxmoxButton',
-	    text: gettext('Initialize Disk with GPT'),
-	    parentXType: 'treepanel',
-	    disabled: true,
-	    enableFn: function(rec) {
-		if (!rec || rec.data.parent ||
-		    (rec.data.used && rec.data.used !== 'unused')) {
-		    return false;
-		} else {
-		    return true;
-		}
-	    },
-	    handler: 'initGPT',
-	},
-    ],
-
     columns: [
 	{
 	    xtype: 'treecolumn',
@@ -332,4 +296,48 @@ Ext.define('Proxmox.DiskList', {
     listeners: {
 	itemdblclick: 'openSmartWindow',
     },
+
+    initComponent: function() {
+	let me = this;
+
+	let tbar = [
+	    {
+		text: gettext('Reload'),
+		handler: 'reload',
+	    },
+	    {
+		xtype: 'proxmoxButton',
+		text: gettext('Show S.M.A.R.T. values'),
+		parentXType: 'treepanel',
+		disabled: true,
+		enableFn: function(rec) {
+		    if (!rec || rec.data.parent) {
+			return false;
+		    } else {
+			return true;
+		    }
+		},
+		handler: 'openSmartWindow',
+	    },
+	    {
+		xtype: 'proxmoxButton',
+		text: gettext('Initialize Disk with GPT'),
+		parentXType: 'treepanel',
+		disabled: true,
+		enableFn: function(rec) {
+		    if (!rec || rec.data.parent ||
+			(rec.data.used && rec.data.used !== 'unused')) {
+			return false;
+		    } else {
+			return true;
+		    }
+		},
+		handler: 'initGPT',
+	    },
+	];
+
+	me.tbar = tbar;
+
+	me.callParent();
+    },
 });
-- 
2.20.1






More information about the pve-devel mailing list