all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-gui] ui: queue: refactor deletion/delivery
@ 2025-09-29  7:34 Stoiko Ivanov
  2025-09-29 14:18 ` Dominik Csapak
  2025-09-29 14:22 ` [pmg-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2025-09-29  7:34 UTC (permalink / raw)
  To: pmg-devel

both actions have almost the same structure and calls, so unify this
in the doAction field, and use it for both deliver and delete.

the messages for the info-modal were kept as a whole string for both
assuming that this will provide a bit more context to translators.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 js/PostfixMailQueue.js | 50 +++++++++++++-----------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/js/PostfixMailQueue.js b/js/PostfixMailQueue.js
index ec39df9..2b908d9 100644
--- a/js/PostfixMailQueue.js
+++ b/js/PostfixMailQueue.js
@@ -58,16 +58,16 @@ Ext.define('PMG.Postfix.MailQueue', {
             view.delayFilterTask.delay(500);
         },
 
-        onFlush: function (button, event, rec) {
+        doAction: function(action, message) {
             var view = this.getView();
             let sel = view.getSelectionModel().getSelection();
             let ids = sel.map((r) => r.get('queue_id'));
 
-            let do_deliver = function () {
+            let do_action = function(){
                 Proxmox.Utils.API2Request({
                     url: `/api2/extjs/nodes/${view.nodename}/postfix/queue/${view.queuename}`,
                     method: 'POST',
-                    params: { action: 'deliver', ids: ids.join(';') },
+                    params: { action: action, ids: ids.join(';') },
                     waitMsgTarget: view,
                     success: () => {
                         view.selModel.deselectAll();
@@ -77,49 +77,29 @@ Ext.define('PMG.Postfix.MailQueue', {
                 });
             }
 
-            if (sel.length === 1) {
-                do_deliver();
-            } else if (sel.length > 1) {
+            if (sel.length === 1 && action === 'deliver') {
+                do_action(action, ids);
+            } else {
                 Ext.Msg.show({
                     title: gettext('Confirm'),
-                    message: Ext.String.format(gettext("Deliver {0} selected mails now?"), ids.length),
+                    message: Ext.String.format(message, ids.length),
                     buttons: Ext.Msg.YESNO,
                     icon: Ext.Msg.INFO,
                     fn: function (btn) {
-                        if (btn === 'yes') { do_deliver(); }
+                        if (btn === 'yes') { do_action(action, ids); }
                     },
                 });
             }
         },
 
-        onRemove: function (button, event, rec) {
-            var view = this.getView();
-            let sel = view.getSelectionModel().getSelection();
-            let ids = sel.map((r) => r.get('queue_id'));
-
-            let do_delete = function () {
-                Proxmox.Utils.API2Request({
-                    url: `/api2/extjs/nodes/${view.nodename}/postfix/queue/${view.queuename}`,
-                    method: 'POST',
-                    params: { action: 'delete', ids: ids.join(';') },
-                    waitMsgTarget: view,
-                    success: () => {
-                        view.selModel.deselectAll();
-                        view.store.load();
-                    },
-                    failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
-                });
-            }
+        onFlush: function (button, event, rec) {
+            let message = gettext("Deliver {0} selected mails?");
+            this.doAction('deliver', message);
+        },
 
-            Ext.Msg.show({
-                title: gettext('Confirm'),
-                message: Ext.String.format(gettext("Delete {0} selected mails?"), ids.length),
-                buttons: Ext.Msg.YESNO,
-                icon: Ext.Msg.INFO,
-                fn: function (btn) {
-                    if (btn === 'yes') { do_delete(); }
-                },
-            });
+        onRemove: function (button, event, rec) {
+            let message = gettext("Delete {0} selected mails?");
+            this.doAction('delete', message);
         },
 
         onHeaders: function (button, event, rec) {
-- 
2.47.3



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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pmg-devel] [PATCH pmg-gui] ui: queue: refactor deletion/delivery
  2025-09-29  7:34 [pmg-devel] [PATCH pmg-gui] ui: queue: refactor deletion/delivery Stoiko Ivanov
@ 2025-09-29 14:18 ` Dominik Csapak
  2025-09-29 14:21   ` Stoiko Ivanov
  2025-09-29 14:22 ` [pmg-devel] applied: " Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Dominik Csapak @ 2025-09-29 14:18 UTC (permalink / raw)
  To: Stoiko Ivanov, pmg-devel

the only thing i noticed is that the message for delivery changed,
not sure if that was intentional (see inline comments)

aside from that, looks good to me, so consider it

Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>

On 9/29/25 9:34 AM, Stoiko Ivanov wrote:
> both actions have almost the same structure and calls, so unify this
> in the doAction field, and use it for both deliver and delete.
> 
> the messages for the info-modal were kept as a whole string for both
> assuming that this will provide a bit more context to translators.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>   js/PostfixMailQueue.js | 50 +++++++++++++-----------------------------
>   1 file changed, 15 insertions(+), 35 deletions(-)
> 
> diff --git a/js/PostfixMailQueue.js b/js/PostfixMailQueue.js
> index ec39df9..2b908d9 100644
> --- a/js/PostfixMailQueue.js
> +++ b/js/PostfixMailQueue.js
> @@ -58,16 +58,16 @@ Ext.define('PMG.Postfix.MailQueue', {
>               view.delayFilterTask.delay(500);
>           },
>   
> -        onFlush: function (button, event, rec) {
> +        doAction: function(action, message) {
>               var view = this.getView();
>               let sel = view.getSelectionModel().getSelection();
>               let ids = sel.map((r) => r.get('queue_id'));
>   
> -            let do_deliver = function () {
> +            let do_action = function(){
>                   Proxmox.Utils.API2Request({
>                       url: `/api2/extjs/nodes/${view.nodename}/postfix/queue/${view.queuename}`,
>                       method: 'POST',
> -                    params: { action: 'deliver', ids: ids.join(';') },
> +                    params: { action: action, ids: ids.join(';') },
>                       waitMsgTarget: view,
>                       success: () => {
>                           view.selModel.deselectAll();
> @@ -77,49 +77,29 @@ Ext.define('PMG.Postfix.MailQueue', {
>                   });
>               }
>   
> -            if (sel.length === 1) {
> -                do_deliver();
> -            } else if (sel.length > 1) {
> +            if (sel.length === 1 && action === 'deliver') {
> +                do_action(action, ids);
> +            } else {
>                   Ext.Msg.show({
>                       title: gettext('Confirm'),
> -                    message: Ext.String.format(gettext("Deliver {0} selected mails now?"), ids.length),

here it was 'deliver ... now?'

> +                    message: Ext.String.format(message, ids.length),
>                       buttons: Ext.Msg.YESNO,
>                       icon: Ext.Msg.INFO,
>                       fn: function (btn) {
> -                        if (btn === 'yes') { do_deliver(); }
> +                        if (btn === 'yes') { do_action(action, ids); }
>                       },
>                   });
>               }
>           },
>   
> -        onRemove: function (button, event, rec) {
> -            var view = this.getView();
> -            let sel = view.getSelectionModel().getSelection();
> -            let ids = sel.map((r) => r.get('queue_id'));
> -
> -            let do_delete = function () {
> -                Proxmox.Utils.API2Request({
> -                    url: `/api2/extjs/nodes/${view.nodename}/postfix/queue/${view.queuename}`,
> -                    method: 'POST',
> -                    params: { action: 'delete', ids: ids.join(';') },
> -                    waitMsgTarget: view,
> -                    success: () => {
> -                        view.selModel.deselectAll();
> -                        view.store.load();
> -                    },
> -                    failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
> -                });
> -            }
> +        onFlush: function (button, event, rec) {
> +            let message = gettext("Deliver {0} selected mails?");

vs here it's 'deliver ...?'

> +            this.doAction('deliver', message);
> +        },
>   
> -            Ext.Msg.show({
> -                title: gettext('Confirm'),
> -                message: Ext.String.format(gettext("Delete {0} selected mails?"), ids.length),
> -                buttons: Ext.Msg.YESNO,
> -                icon: Ext.Msg.INFO,
> -                fn: function (btn) {
> -                    if (btn === 'yes') { do_delete(); }
> -                },
> -            });
> +        onRemove: function (button, event, rec) {
> +            let message = gettext("Delete {0} selected mails?");
> +            this.doAction('delete', message);
>           },
>   
>           onHeaders: function (button, event, rec) {



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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pmg-devel] [PATCH pmg-gui] ui: queue: refactor deletion/delivery
  2025-09-29 14:18 ` Dominik Csapak
@ 2025-09-29 14:21   ` Stoiko Ivanov
  0 siblings, 0 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2025-09-29 14:21 UTC (permalink / raw)
  To: Dominik Csapak; +Cc: pmg-devel

On Mon, 29 Sep 2025 16:18:31 +0200
Dominik Csapak <d.csapak@proxmox.com> wrote:

> the only thing i noticed is that the message for delivery changed,
> not sure if that was intentional (see inline comments)
That was somewhat intentional - as in - noticed the discrepancy as well -
did not see a good reason to keep it (and had a slight preference for the
version without 'now') - so unified them to the same.
thanks for the attention to detail! :)

> 
> aside from that, looks good to me, so consider it
> 
> Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
> 
> On 9/29/25 9:34 AM, Stoiko Ivanov wrote:
> > both actions have almost the same structure and calls, so unify this
> > in the doAction field, and use it for both deliver and delete.
> > 
> > the messages for the info-modal were kept as a whole string for both
> > assuming that this will provide a bit more context to translators.
> > 
> > Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> > ---
> >   js/PostfixMailQueue.js | 50 +++++++++++++-----------------------------
> >   1 file changed, 15 insertions(+), 35 deletions(-)
> > 
> > diff --git a/js/PostfixMailQueue.js b/js/PostfixMailQueue.js
> > index ec39df9..2b908d9 100644
> > --- a/js/PostfixMailQueue.js
> > +++ b/js/PostfixMailQueue.js
> > @@ -58,16 +58,16 @@ Ext.define('PMG.Postfix.MailQueue', {
> >               view.delayFilterTask.delay(500);
> >           },
> >   
> > -        onFlush: function (button, event, rec) {
> > +        doAction: function(action, message) {
> >               var view = this.getView();
> >               let sel = view.getSelectionModel().getSelection();
> >               let ids = sel.map((r) => r.get('queue_id'));
> >   
> > -            let do_deliver = function () {
> > +            let do_action = function(){
> >                   Proxmox.Utils.API2Request({
> >                       url: `/api2/extjs/nodes/${view.nodename}/postfix/queue/${view.queuename}`,
> >                       method: 'POST',
> > -                    params: { action: 'deliver', ids: ids.join(';') },
> > +                    params: { action: action, ids: ids.join(';') },
> >                       waitMsgTarget: view,
> >                       success: () => {
> >                           view.selModel.deselectAll();
> > @@ -77,49 +77,29 @@ Ext.define('PMG.Postfix.MailQueue', {
> >                   });
> >               }
> >   
> > -            if (sel.length === 1) {
> > -                do_deliver();
> > -            } else if (sel.length > 1) {
> > +            if (sel.length === 1 && action === 'deliver') {
> > +                do_action(action, ids);
> > +            } else {
> >                   Ext.Msg.show({
> >                       title: gettext('Confirm'),
> > -                    message: Ext.String.format(gettext("Deliver {0} selected mails now?"), ids.length),  
> 
> here it was 'deliver ... now?'
> 
> > +                    message: Ext.String.format(message, ids.length),
> >                       buttons: Ext.Msg.YESNO,
> >                       icon: Ext.Msg.INFO,
> >                       fn: function (btn) {
> > -                        if (btn === 'yes') { do_deliver(); }
> > +                        if (btn === 'yes') { do_action(action, ids); }
> >                       },
> >                   });
> >               }
> >           },
> >   
> > -        onRemove: function (button, event, rec) {
> > -            var view = this.getView();
> > -            let sel = view.getSelectionModel().getSelection();
> > -            let ids = sel.map((r) => r.get('queue_id'));
> > -
> > -            let do_delete = function () {
> > -                Proxmox.Utils.API2Request({
> > -                    url: `/api2/extjs/nodes/${view.nodename}/postfix/queue/${view.queuename}`,
> > -                    method: 'POST',
> > -                    params: { action: 'delete', ids: ids.join(';') },
> > -                    waitMsgTarget: view,
> > -                    success: () => {
> > -                        view.selModel.deselectAll();
> > -                        view.store.load();
> > -                    },
> > -                    failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
> > -                });
> > -            }
> > +        onFlush: function (button, event, rec) {
> > +            let message = gettext("Deliver {0} selected mails?");  
> 
> vs here it's 'deliver ...?'
> 
> > +            this.doAction('deliver', message);
> > +        },
> >   
> > -            Ext.Msg.show({
> > -                title: gettext('Confirm'),
> > -                message: Ext.String.format(gettext("Delete {0} selected mails?"), ids.length),
> > -                buttons: Ext.Msg.YESNO,
> > -                icon: Ext.Msg.INFO,
> > -                fn: function (btn) {
> > -                    if (btn === 'yes') { do_delete(); }
> > -                },
> > -            });
> > +        onRemove: function (button, event, rec) {
> > +            let message = gettext("Delete {0} selected mails?");
> > +            this.doAction('delete', message);
> >           },
> >   
> >           onHeaders: function (button, event, rec) {  
> 



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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] applied: [PATCH pmg-gui] ui: queue: refactor deletion/delivery
  2025-09-29  7:34 [pmg-devel] [PATCH pmg-gui] ui: queue: refactor deletion/delivery Stoiko Ivanov
  2025-09-29 14:18 ` Dominik Csapak
@ 2025-09-29 14:22 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2025-09-29 14:22 UTC (permalink / raw)
  To: pmg-devel, Stoiko Ivanov

On Mon, 29 Sep 2025 09:34:00 +0200, Stoiko Ivanov wrote:
> both actions have almost the same structure and calls, so unify this
> in the doAction field, and use it for both deliver and delete.
> 
> the messages for the info-modal were kept as a whole string for both
> assuming that this will provide a bit more context to translators.
> 
> 
> [...]

Applied, thanks!

[1/1] ui: queue: refactor deletion/delivery
      commit: bf8ef4b1d56aaa8f5854345bd26e2fa6c5a920f0


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-29 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-29  7:34 [pmg-devel] [PATCH pmg-gui] ui: queue: refactor deletion/delivery Stoiko Ivanov
2025-09-29 14:18 ` Dominik Csapak
2025-09-29 14:21   ` Stoiko Ivanov
2025-09-29 14:22 ` [pmg-devel] applied: " Thomas Lamprecht

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