[pve-devel] [PATCH manager 1/2] ui: factor out standalone node check
Dominik Csapak
d.csapak at proxmox.com
Mon Nov 13 09:59:30 CET 2023
into Utils and use it where we manually checked that
Signed-off-by: Dominik Csapak <d.csapak at 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
More information about the pve-devel
mailing list