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 5B65D92171 for ; Tue, 28 Mar 2023 18:55:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3AD801FA91 for ; Tue, 28 Mar 2023 18:55:22 +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 ; Tue, 28 Mar 2023 18:55:21 +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 8A29047249 for ; Tue, 28 Mar 2023 18:55:21 +0200 (CEST) From: Thomas Lamprecht To: pbs-devel@lists.proxmox.com Date: Tue, 28 Mar 2023 18:55:15 +0200 Message-Id: <20230328165515.296403-2-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230328165515.296403-1-t.lamprecht@proxmox.com> References: <20230328165515.296403-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.095 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 Subject: [pbs-devel] applied: [PATCH backup 2/2] ui: user edit: rework interaction of realm and view model X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Mar 2023 16:55:52 -0000 avoid accessing private members directly but rather try to use the public API, this then allows us do drop declaring a reference on the realm combobox, which was not directly used and thus a bit subtle. Signed-off-by: Thomas Lamprecht --- still not the cleanest approach in general IMO, it probably would be better to move the "can PW change" logic into the combobox (either in a child here or in widget toolkit) and, e.g., expose it via a selectionCanChangePW like getter there which can then be bindend here. www/window/UserEdit.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/www/window/UserEdit.js b/www/window/UserEdit.js index 0129aeed..63a6f7f8 100644 --- a/www/window/UserEdit.js +++ b/www/window/UserEdit.js @@ -1,6 +1,5 @@ Ext.define('PBS.window.UserEditViewModel', { extend: 'Ext.app.ViewModel', - alias: 'viewmodel.pbsUserEdit', data: { @@ -9,15 +8,16 @@ Ext.define('PBS.window.UserEditViewModel', { formulas: { maySetPassword: function(get) { - // Dummy read, so that ExtJS will update the formula when - // the combobox changes - let _dummy = get('realm'); + let realm = get('realm'); - // All in all a bit hacky, is there a nicer way to do this? - let realm_type = this.data.realmComboBox.selection?.data.type - ? this.data.realmComboBox.selection?.data.type : 'pbs'; - - return Proxmox.Schema.authDomains[realm_type].pwchange && this.config.view.isCreate; + let view = this.getView(); + let realmStore = view.down('pmxRealmComboBox').getStore(); + if (realmStore.isLoaded()) { + let rec = realmStore.findRecord('realm', realm, 0, false, true, true); + return Proxmox.Schema.authDomains[rec.data.type]?.pwchange && view.isCreate; + } else { + return view.isCreate; + } }, }, }); @@ -78,8 +78,9 @@ Ext.define('PBS.window.UserEdit', { allowBlank: false, matchFieldWidth: false, listConfig: { width: 300 }, - reference: 'realmComboBox', - bind: '{realm}', + bind: { + value: '{realm}', + }, cbind: { hidden: '{!isCreate}', disabled: '{!isCreate}', -- 2.30.2