From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4C390987B8 for ; Mon, 13 Nov 2023 10:00:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3333AF655 for ; Mon, 13 Nov 2023 09:59:34 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 13 Nov 2023 09:59:33 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E3845418DD for ; Mon, 13 Nov 2023 09:59:32 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Mon, 13 Nov 2023 09:59:30 +0100 Message-Id: <20231113085931.1126018-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.017 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH manager 1/2] ui: factor out standalone node check X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Nov 2023 09:00:04 -0000 into Utils and use it where we manually checked that Signed-off-by: Dominik Csapak --- I put it into utils since i did not find a better place. Could have put it in the ResourceStore, but coupling those things seemed wrong to me. www/manager6/Utils.js | 4 ++++ www/manager6/form/ComboBoxSetStoreNode.js | 2 +- www/manager6/grid/Replication.js | 4 ++-- www/manager6/lxc/CmdMenu.js | 2 +- www/manager6/lxc/Config.js | 2 +- www/manager6/menu/TemplateMenu.js | 2 +- www/manager6/qemu/CmdMenu.js | 2 +- www/manager6/qemu/Config.js | 2 +- www/manager6/storage/LVMEdit.js | 2 +- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index be30393e..9b77ebd3 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -1921,6 +1921,10 @@ Ext.define('PVE.Utils', { 'ok': 2, '__default__': 3, }, + + isStandaloneNode: function() { + return PVE.data.ResourceStore.getNodes().length < 2; + }, }, singleton: true, diff --git a/www/manager6/form/ComboBoxSetStoreNode.js b/www/manager6/form/ComboBoxSetStoreNode.js index d5695bad..26b1f95b 100644 --- a/www/manager6/form/ComboBoxSetStoreNode.js +++ b/www/manager6/form/ComboBoxSetStoreNode.js @@ -56,7 +56,7 @@ Ext.define('PVE.form.ComboBoxSetStoreNode', { initComponent: function() { let me = this; - if (me.showNodeSelector && PVE.data.ResourceStore.getNodes().length > 1) { + if (me.showNodeSelector && !PVE.Utils.isStandaloneNode()) { me.errorHeight = 140; Ext.apply(me.listConfig ?? {}, { tbar: { diff --git a/www/manager6/grid/Replication.js b/www/manager6/grid/Replication.js index 1e4e00fc..79824b9b 100644 --- a/www/manager6/grid/Replication.js +++ b/www/manager6/grid/Replication.js @@ -220,7 +220,7 @@ Ext.define('PVE.grid.ReplicaView', { // currently replication is for cluster only, so disable the whole component for non-cluster checkPrerequisites: function() { let view = this.getView(); - if (PVE.data.ResourceStore.getNodes().length < 2) { + if (PVE.Utils.isStandaloneNode()) { view.mask(gettext("Replication needs at least two nodes"), ['pve-static-mask']); } }, @@ -450,7 +450,7 @@ Ext.define('PVE.grid.ReplicaView', { // if we set the warning mask, we do not want to load // or set the mask on store errors - if (PVE.data.ResourceStore.getNodes().length < 2) { + if (PVE.Utils.isStandaloneNode()) { return; } diff --git a/www/manager6/lxc/CmdMenu.js b/www/manager6/lxc/CmdMenu.js index 56f36b5e..b1403fc6 100644 --- a/www/manager6/lxc/CmdMenu.js +++ b/www/manager6/lxc/CmdMenu.js @@ -31,7 +31,7 @@ Ext.define('PVE.lxc.CmdMenu', { }; let caps = Ext.state.Manager.get('GuiCap'); - let standalone = PVE.data.ResourceStore.getNodes().length < 2; + let standalone = PVE.Utils.isStandaloneNode(); let running = false, stopped = true, suspended = false; switch (info.status) { diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js index 85d32e3c..4516ee8f 100644 --- a/www/manager6/lxc/Config.js +++ b/www/manager6/lxc/Config.js @@ -92,7 +92,7 @@ Ext.define('PVE.lxc.Config', { var migrateBtn = Ext.create('Ext.Button', { text: gettext('Migrate'), disabled: !caps.vms['VM.Migrate'], - hidden: PVE.data.ResourceStore.getNodes().length < 2, + hidden: PVE.Utils.isStandaloneNode(), handler: function() { var win = Ext.create('PVE.window.Migrate', { vmtype: 'lxc', diff --git a/www/manager6/menu/TemplateMenu.js b/www/manager6/menu/TemplateMenu.js index eb91481c..7cd87f6a 100644 --- a/www/manager6/menu/TemplateMenu.js +++ b/www/manager6/menu/TemplateMenu.js @@ -22,7 +22,7 @@ Ext.define('PVE.menu.TemplateMenu', { me.title = (guestType === 'qemu' ? 'VM ' : 'CT ') + info.vmid; let caps = Ext.state.Manager.get('GuiCap'); - let standaloneNode = PVE.data.ResourceStore.getNodes().length < 2; + let standaloneNode = PVE.Utils.isStandaloneNode(); me.items = [ { diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js index ccc5f74d..4f59d5f7 100644 --- a/www/manager6/qemu/CmdMenu.js +++ b/www/manager6/qemu/CmdMenu.js @@ -32,7 +32,7 @@ Ext.define('PVE.qemu.CmdMenu', { }; let caps = Ext.state.Manager.get('GuiCap'); - let standalone = PVE.data.ResourceStore.getNodes().length < 2; + let standalone = PVE.Utils.isStandaloneNode(); let running = false, stopped = true, suspended = false; switch (info.status) { diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js index 6acf589c..fb0d9cde 100644 --- a/www/manager6/qemu/Config.js +++ b/www/manager6/qemu/Config.js @@ -67,7 +67,7 @@ Ext.define('PVE.qemu.Config', { var migrateBtn = Ext.create('Ext.Button', { text: gettext('Migrate'), disabled: !caps.vms['VM.Migrate'], - hidden: PVE.data.ResourceStore.getNodes().length < 2, + hidden: PVE.Utils.isStandaloneNode(), handler: function() { var win = Ext.create('PVE.window.Migrate', { vmtype: 'qemu', diff --git a/www/manager6/storage/LVMEdit.js b/www/manager6/storage/LVMEdit.js index 75c7bdb8..fde302fc 100644 --- a/www/manager6/storage/LVMEdit.js +++ b/www/manager6/storage/LVMEdit.js @@ -114,7 +114,7 @@ Ext.define('PVE.storage.LunSelector', { initComponent: function() { let me = this; - if (PVE.data.ResourceStore.getNodes().length > 1) { + if (!PVE.Utils.isStandaloneNode()) { me.errorHeight = 140; Ext.apply(me.listConfig ?? {}, { tbar: { -- 2.30.2