all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] fix #7191: ui: correctly sort TFA column in DC/Permission/Users
Date: Fri,  9 Jan 2026 10:35:07 +0100	[thread overview]
Message-ID: <20260109093511.1177868-1-d.csapak@proxmox.com> (raw)

ExtJS does not sort this column correctly since the field is not defined
in our 'pmx-users' model, so it ignores it when sorting.

Add the keys field to the model definition. This enables sorting, but
does not take into account the additional info we use when rendering the
column.

To do that, use the rendered values as strings to sort them.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/Utils.js             | 25 +++++++++++++++++++++++++
 www/manager6/dc/UserView.js       | 28 +++++-----------------------
 www/manager6/form/UserSelector.js |  1 +
 3 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 0e0751e7..fee252e6 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1363,6 +1363,31 @@ Ext.define('PVE.Utils', {
             return retVal.length < 1 ? value : retVal;
         },
 
+        render_tfa: function (v, _mD, record) {
+            let tfa_type = PVE.Parser.parseTfaType(v);
+            if (tfa_type === undefined) {
+                return Proxmox.Utils.noText;
+            }
+
+            if (tfa_type !== 1) {
+                return tfa_type;
+            }
+
+            let locked_until = record.data['tfa-locked-until'];
+            if (locked_until !== undefined) {
+                let now = new Date().getTime() / 1000;
+                if (locked_until > now) {
+                    return gettext('Locked');
+                }
+            }
+
+            if (record.data['totp-locked']) {
+                return gettext('TOTP Locked');
+            }
+
+            return Proxmox.Utils.yesText;
+        },
+
         windowHostname: function () {
             return window.location.hostname.replace(
                 Proxmox.Utils.IP6_bracket_match,
diff --git a/www/manager6/dc/UserView.js b/www/manager6/dc/UserView.js
index 9d33a5bf..279ed5fb 100644
--- a/www/manager6/dc/UserView.js
+++ b/www/manager6/dc/UserView.js
@@ -209,29 +209,11 @@ Ext.define('PVE.dc.UserView', {
                     header: 'TFA',
                     width: 120,
                     sortable: true,
-                    renderer: function (v, metaData, record) {
-                        let tfa_type = PVE.Parser.parseTfaType(v);
-                        if (tfa_type === undefined) {
-                            return Proxmox.Utils.noText;
-                        }
-
-                        if (tfa_type !== 1) {
-                            return tfa_type;
-                        }
-
-                        let locked_until = record.data['tfa-locked-until'];
-                        if (locked_until !== undefined) {
-                            let now = new Date().getTime() / 1000;
-                            if (locked_until > now) {
-                                return gettext('Locked');
-                            }
-                        }
-
-                        if (record.data['totp-locked']) {
-                            return gettext('TOTP Locked');
-                        }
-
-                        return Proxmox.Utils.yesText;
+                    renderer: PVE.Utils.render_tfa,
+                    sorter: function (a, b) {
+                        let a_text = PVE.Utils.render_tfa(a.data.keys, undefined, a);
+                        let b_text = PVE.Utils.render_tfa(b.data.keys, undefined, b);
+                        return a_text.toString().localeCompare(b_text.toString());
                     },
                     dataIndex: 'keys',
                 },
diff --git a/www/manager6/form/UserSelector.js b/www/manager6/form/UserSelector.js
index f0bf6579..d49cce03 100644
--- a/www/manager6/form/UserSelector.js
+++ b/www/manager6/form/UserSelector.js
@@ -8,6 +8,7 @@ Ext.define('pmx-users', {
         'comment',
         { type: 'boolean', name: 'enable' },
         { type: 'date', dateFormat: 'timestamp', name: 'expire' },
+        { type: 'string', name: 'keys' },
     ],
     proxy: {
         type: 'proxmox',
-- 
2.47.3



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


                 reply	other threads:[~2026-01-09  9:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260109093511.1177868-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-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