From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 B6306A0532
 for <pve-devel@lists.proxmox.com>; Tue, 13 Jun 2023 10:44:03 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 9E8E32CB47
 for <pve-devel@lists.proxmox.com>; Tue, 13 Jun 2023 10:44:03 +0200 (CEST)
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 <pve-devel@lists.proxmox.com>; Tue, 13 Jun 2023 10:44:02 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 72C6F44F98
 for <pve-devel@lists.proxmox.com>; Tue, 13 Jun 2023 10:44:02 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Tue, 13 Jun 2023 10:43:58 +0200
Message-Id: <20230613084401.1282876-2-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20230613084401.1282876-1-d.csapak@proxmox.com>
References: <20230613084401.1282876-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.015 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 v2 1/4] ui: realm sync edit: improve ux
 when there is no ldap/ad realm
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>
X-List-Received-Date: Tue, 13 Jun 2023 08:44:03 -0000

by adding an empty text to the dropdown, and disabling the other
possibly invalid fields, so that it's clear why the panel is invalid

as soon as there is an ldap/ad realm, it gets autoselected anyway and
the fields get re-enabled.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* fix eslint warnings
 www/manager6/dc/RealmSyncJob.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/www/manager6/dc/RealmSyncJob.js b/www/manager6/dc/RealmSyncJob.js
index 5a903ef7..e12ad858 100644
--- a/www/manager6/dc/RealmSyncJob.js
+++ b/www/manager6/dc/RealmSyncJob.js
@@ -154,6 +154,11 @@ Ext.define('PVE.dc.RealmSyncJobEdit', {
 
 	updateDefaults: function(_field, newValue) {
 	    let me = this;
+
+	    ['scope', 'enable-new', 'schedule'].forEach((reference) => {
+		me.lookup(reference)?.setDisabled(false);
+	    });
+
 	    // only update on create
 	    if (!me.getView().isCreate) {
 		return;
@@ -232,6 +237,9 @@ Ext.define('PVE.dc.RealmSyncJobEdit', {
 			xtype: 'pmxRealmComboBox',
 			storeFilter: rec => rec.data.type === 'ldap' || rec.data.type === 'ad',
 		    },
+		    listConfig: {
+			emptyText: `<div class="x-grid-empty">${gettext('No LDAP/AD Realm found')}</div>`,
+		    },
 		    cbind: {
 			editable: '{isCreate}',
 		    },
@@ -245,6 +253,7 @@ Ext.define('PVE.dc.RealmSyncJobEdit', {
 		{
 		    xtype: 'pveCalendarEvent',
 		    fieldLabel: gettext('Schedule'),
+		    disabled: true,
 		    allowBlank: false,
 		    name: 'schedule',
 		    reference: 'schedule',
@@ -265,6 +274,7 @@ Ext.define('PVE.dc.RealmSyncJobEdit', {
 		    xtype: 'proxmoxKVComboBox',
 		    name: 'scope',
 		    reference: 'scope',
+		    disabled: true,
 		    fieldLabel: gettext('Scope'),
 		    value: '',
 		    emptyText: gettext('No default available'),
@@ -280,6 +290,7 @@ Ext.define('PVE.dc.RealmSyncJobEdit', {
 		    xtype: 'proxmoxKVComboBox',
 		    value: '1',
 		    deleteEmpty: false,
+		    disabled: true,
 		    allowBlank: false,
 		    comboItems: [
 			['1', Proxmox.Utils.yesText],
-- 
2.30.2