From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 3569B1FF164
	for <inbox@lore.proxmox.com>; Fri, 20 Jun 2025 16:38:40 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 5F7DDF0C6;
	Fri, 20 Jun 2025 16:39:05 +0200 (CEST)
From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 20 Jun 2025 16:31:46 +0200
Message-Id: <20250620143148.218469-39-d.kral@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250620143148.218469-1-d.kral@proxmox.com>
References: <20250620143148.218469-1-d.kral@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.011 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
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH manager v2 3/5] ui: ha: hide ha groups if
 use-location-rules is enabled
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Remove the HA Groups entry from the datacenter's config tabs if the
use-location-rules feature flag is enabled.

As changing the use-location-rules feature flag doesn't automatically
reload the web interface, show an empty message if the HA Groups page is
still open.

Remove the 'ha-groups' from the state provider as the ha-groups page
only exists conditionally now and the StateProvider expects all entries
to exist at any time.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
changes since v1:
    - NEW!

 www/manager6/StateProvider.js |  1 -
 www/manager6/Workspace.js     | 20 ++++++++++++++++++++
 www/manager6/dc/Config.js     | 24 ++++++++++++++----------
 www/manager6/ha/Groups.js     |  6 ++++++
 4 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/www/manager6/StateProvider.js b/www/manager6/StateProvider.js
index 5137ee55..d8686014 100644
--- a/www/manager6/StateProvider.js
+++ b/www/manager6/StateProvider.js
@@ -54,7 +54,6 @@ Ext.define('PVE.StateProvider', {
         system: 50,
         monitor: 49,
         'ha-fencing': 48,
-        'ha-groups': 47,
         'ha-resources': 46,
         'ceph-log': 45,
         'ceph-crushmap': 44,
diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index e6b18bf7..f9680429 100644
--- a/www/manager6/Workspace.js
+++ b/www/manager6/Workspace.js
@@ -164,6 +164,26 @@ Ext.define('PVE.StdWorkspace', {
 
             PVE.UIOptions.update();
 
+            Proxmox.Utils.API2Request({
+                url: '/cluster/options',
+                method: 'GET',
+                success: function (response) {
+                    let dcConfig = response.result?.data ?? {};
+                    PVE.HALocationEnabled = dcConfig?.ha?.['use-location-rules'] === 1;
+
+                    // remove HA Groups menu item if HA Location rules are enabled
+                    if (PVE.HALocationEnabled) {
+                        let haMenu = Ext.ComponentQuery.query('treelistitem[text="HA"]')[0];
+                        let haGroupsMenu = Object.values(haMenu?.itemMap ?? {}).find(
+                            (element) => element.getText() === 'Groups',
+                        );
+                        if (haGroupsMenu) {
+                            haGroupsMenu.addCls('x-hidden-display');
+                        }
+                    }
+                },
+            });
+
             Proxmox.Utils.API2Request({
                 url: '/cluster/sdn',
                 method: 'GET',
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 6173a9b2..7e39c85f 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -169,21 +169,25 @@ Ext.define('PVE.dc.Config', {
                     iconCls: 'fa fa-heartbeat',
                     itemId: 'ha',
                 },
-                {
+            );
+
+            if (!PVE.HALocationEnabled) {
+                me.items.push({
                     title: gettext('Groups'),
                     groups: ['ha'],
                     xtype: 'pveHAGroupsView',
                     iconCls: 'fa fa-object-group',
                     itemId: 'ha-groups',
-                },
-                {
-                    title: gettext('Fencing'),
-                    groups: ['ha'],
-                    iconCls: 'fa fa-bolt',
-                    xtype: 'pveFencingView',
-                    itemId: 'ha-fencing',
-                },
-            );
+                });
+            }
+
+            me.items.push({
+                title: gettext('Fencing'),
+                groups: ['ha'],
+                iconCls: 'fa fa-bolt',
+                xtype: 'pveFencingView',
+                itemId: 'ha-fencing',
+            });
             // always show on initial load, will be hiddea later if the SDN API calls don't exist,
             // else it won't be shown at first if the user initially loads with DC selected
             if (PVE.SDNInfo || PVE.SDNInfo === undefined) {
diff --git a/www/manager6/ha/Groups.js b/www/manager6/ha/Groups.js
index 6b4958f0..4aad0dda 100644
--- a/www/manager6/ha/Groups.js
+++ b/www/manager6/ha/Groups.js
@@ -112,6 +112,12 @@ Ext.define('PVE.ha.GroupsView', {
             },
         });
 
+        PVE.Utils.getHALocationFeatureStatus().then((isHALocationEnabled) => {
+            if (isHALocationEnabled) {
+                me.emptyText = gettext('HA Location rules are used instead of HA Groups');
+            }
+        });
+
         me.callParent();
     },
 });
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel