From 37a85cf616b61932ca1417c30f876178ce90c6c4 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Tue, 18 Mar 2025 10:47:55 +0100 Subject: [PATCH] fix: ui: sync job: edit rate limit based on sync direction Commit 9aa213b8 ("ui: sync job: adapt edit window to be used for pull and push") adapted the sync job edit so jobs in both, push and pull can be edited using the same window. This however did not include the switching of the direction to which the http client rate limit is applied to. Fix this by further adding the edit field for `rate-out` and conditionally hide the less useful rate limit direction (rate-out for pull and rate-in for push). This allows to preserve the values if explicitly set via the sync job config. Reported in the community forum: https://forum.proxmox.com/threads/163414/ Fixes: 9aa213b8 ("ui: sync job: adapt edit window to be used for pull and push") Signed-off-by: Christian Ebner Reviewed-by: Dominik Csapak Tested-by: Dominik Csapak Link: https://lore.proxmox.com/20250318094756.204368-1-c.ebner@proxmox.com --- www/window/SyncJobEdit.js | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js index 9c4d2bba..4cef9a1d 100644 --- a/www/window/SyncJobEdit.js +++ b/www/window/SyncJobEdit.js @@ -73,9 +73,16 @@ Ext.define('PBS.window.SyncJobEdit', { init: function() { let view = this.getView(); - if (view.syncDirectionPush && view.datastore !== undefined) { - let localNs = view.down('pbsNamespaceSelector[name=ns]').getValue(); - view.down('pbsGroupFilter').setLocalNamespace(view.datastore, localNs); + // Cannot use cbind to hide rate limit field depending on sync direction, + // set it in init as workaround. + if (view.syncDirectionPush) { + view.down('pmxBandwidthField[name=rate-in]').setHidden(true); + if (view.datastore !== undefined) { + let localNs = view.down('pbsNamespaceSelector[name=ns]').getValue(); + view.down('pbsGroupFilter').setLocalNamespace(view.datastore, localNs); + } + } else { + view.down('pmxBandwidthField[name=rate-out]').setHidden(true); } }, }, @@ -90,6 +97,15 @@ Ext.define('PBS.window.SyncJobEdit', { me.callParent([values]); }, + getVisibleRateLimitField: function() { + let me = this; + if (me.syncDirectionPush) { + return me.down('field[name=rate-out]'); + } else { + return me.down('field[name=rate-in]'); + } + }, + items: { xtype: 'tabpanel', bodyPadding: 10, @@ -106,6 +122,7 @@ Ext.define('PBS.window.SyncJobEdit', { } if (!me.isCreate) { PBS.Utils.delete_if_default(values, 'rate-in'); + PBS.Utils.delete_if_default(values, 'rate-out'); PBS.Utils.delete_if_default(values, 'remote'); if (typeof values.delete === 'string') { values.delete = values.delete.split(','); @@ -190,7 +207,17 @@ Ext.define('PBS.window.SyncJobEdit', { fieldLabel: gettext('Rate Limit'), emptyText: gettext('Unlimited'), submitAutoScaledSizeUnit: true, - // NOTE: handle deleteEmpty in onGetValues due to bandwidth field having a cbind too + // NOTE: handle deleteEmpty in onGetValues due to bandwidth field having a cbind too, + // further hide rate limit field depending on sync direction in controller init. + }, + { + xtype: 'pmxBandwidthField', + name: 'rate-out', + fieldLabel: gettext('Rate Limit'), + emptyText: gettext('Unlimited'), + submitAutoScaledSizeUnit: true, + // NOTE: handle deleteEmpty in onGetValues due to bandwidth field having a cbind too, + // further hide rate limit field depending on sync direction in controller init. }, ], @@ -222,7 +249,7 @@ Ext.define('PBS.window.SyncJobEdit', { let me = this; let form = me.up('pbsSyncJobEdit'); let nsField = form.down('field[name=remote-ns]'); - let rateLimitField = form.down('field[name=rate-in]'); + let rateLimitField = form.getVisibleRateLimitField(); let remoteField = form.down('field[name=remote]'); let storeField = form.down('field[name=remote-store]'); @@ -264,7 +291,7 @@ Ext.define('PBS.window.SyncJobEdit', { let me = this; let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]'); remoteStoreField.setRemote(value); - let rateLimitField = me.up('pbsSyncJobEdit').down('field[name=rate-in]'); + let rateLimitField = me.up('pbsSyncJobEdit').getVisibleRateLimitField(); rateLimitField.setDisabled(!value); if (!value) { rateLimitField.setValue(null);