all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/2] ui: factor out standalone node check
Date: Mon, 13 Nov 2023 09:59:30 +0100	[thread overview]
Message-ID: <20231113085931.1126018-1-d.csapak@proxmox.com> (raw)

into Utils and use it where we manually checked that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
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





             reply	other threads:[~2023-11-13  9:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13  8:59 Dominik Csapak [this message]
2023-11-13  8:59 ` [pve-devel] [PATCH manager v2 2/2] ui: hide bulk migrate options on standalone nodes Dominik Csapak
2023-11-13 10:20 ` [pve-devel] applied: [PATCH manager 1/2] ui: factor out standalone node check Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231113085931.1126018-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal