public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-widget-toolkit 2/3] notification: smtp: only show 'Unchanged' in password field when it makes sense
Date: Fri, 27 Jun 2025 14:13:38 +0200	[thread overview]
Message-ID: <20250627121339.182283-2-l.wagner@proxmox.com> (raw)
In-Reply-To: <20250627121339.182283-1-l.wagner@proxmox.com>

The formula used for deriving the emptyText for the password field did
not correctly pick up the 'isCreate' flag, so 'Unchanged' was also
visible when creating a new SMTP target that has no password yet.

Also took the opportunity to improve the behavior when modifying an
existing target. Now the original state of the 'authentication' flag is
saved. The 'Unchanged' emptyText is only shown if the loaded config
contains authentication parameters. When editing a target *without*
authentication, the password field does not have the 'Unchanged'
emptyText any more.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 src/panel/SmtpEditPanel.js | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/panel/SmtpEditPanel.js b/src/panel/SmtpEditPanel.js
index fd10b54..a7cfaff 100644
--- a/src/panel/SmtpEditPanel.js
+++ b/src/panel/SmtpEditPanel.js
@@ -8,12 +8,10 @@ Ext.define('Proxmox.panel.SmtpEditPanel', {
 
     viewModel: {
         xtype: 'viewmodel',
-        cbind: {
-            isCreate: '{isCreate}',
-        },
         data: {
             mode: 'tls',
             authentication: true,
+            originalAuthentication: true,
         },
         formulas: {
             portEmptyText: function (get) {
@@ -33,8 +31,13 @@ Ext.define('Proxmox.panel.SmtpEditPanel', {
                 return `${Proxmox.Utils.defaultText} (${port})`;
             },
             passwordEmptyText: function (get) {
-                let isCreate = this.isCreate;
-                return get('authentication') && !isCreate ? gettext('Unchanged') : '';
+                let isCreate = this.getView().isCreate;
+
+                let auth = get('authentication');
+                let origAuth = get('originalAuthentication');
+                let shouldShowUnchanged = !isCreate && auth && origAuth;
+
+                return shouldShowUnchanged ? gettext('Unchanged') : '';
             },
         },
     },
@@ -123,7 +126,9 @@ Ext.define('Proxmox.panel.SmtpEditPanel', {
             inputType: 'password',
             fieldLabel: gettext('Password'),
             name: 'password',
-            allowBlank: true,
+            cbind: {
+                allowBlank: '{!isCreate}',
+            },
             bind: {
                 disabled: '{!authentication}',
                 emptyText: '{passwordEmptyText}',
@@ -206,6 +211,7 @@ Ext.define('Proxmox.panel.SmtpEditPanel', {
         // 'Authenticate' remains ticked (the default value) if loading an
         // SMTP target without authentication.
         me.getViewModel().set('authentication', values.authentication);
+        me.getViewModel().set('originalAuthentication', values.authentication);
 
         return values;
     },
-- 
2.39.5



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


  reply	other threads:[~2025-06-27 12:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27 12:13 [pve-devel] [PATCH proxmox-widget-toolkit 1/3] fix #5588: notification: smtp: fix 'Authenticate' checkbox in Chromium Lukas Wagner
2025-06-27 12:13 ` Lukas Wagner [this message]
2025-06-27 12:13 ` [pve-devel] [PATCH proxmox-widget-toolkit 3/3] notification: smtp: don't split translatable string Lukas Wagner
2025-06-27 12:22   ` Maximiliano Sandoval
2025-07-08 17:15 ` [pve-devel] [PATCH proxmox-widget-toolkit 1/3] fix #5588: notification: smtp: fix 'Authenticate' checkbox in Chromium Michael Köppl
2025-07-15 22:34 ` [pve-devel] applied: " Thomas Lamprecht

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=20250627121339.182283-2-l.wagner@proxmox.com \
    --to=l.wagner@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal