all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH backup 2/2] ui: user edit: rework interaction of realm and view model
Date: Tue, 28 Mar 2023 18:55:15 +0200	[thread overview]
Message-ID: <20230328165515.296403-2-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20230328165515.296403-1-t.lamprecht@proxmox.com>

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 <t.lamprecht@proxmox.com>
---

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





      reply	other threads:[~2023-03-28 16:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 16:55 [pbs-devel] applied: [PATCH backup 1/2] ui: user edit: fix filtering out pam realm on user-add Thomas Lamprecht
2023-03-28 16:55 ` Thomas Lamprecht [this message]

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=20230328165515.296403-2-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pbs-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