From c2cdef890234fb8f3860f5b620833e49f33159cb Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Fri, 10 Mar 2023 15:08:08 +0100 Subject: [PATCH] ui: create ceph pool: fix false-positive trigger showing advanced fields Since the rule selector is not allowed to be empty, but the loading of the rules is not instant, the validity change will trigger before the load was finished. Since it is in the advanced section, it will be opened every time instead of only when there is an invalid value. This patch fixes that by temporarily setting 'allowBlank' to true until the store is loaded, and then it revalidates the field. Signed-off-by: Dominik Csapak Tested-By: Aaron Lauterer --- www/manager6/ceph/Pool.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js index a1f008d1..f7a4d9ba 100644 --- a/www/manager6/ceph/Pool.js +++ b/www/manager6/ceph/Pool.js @@ -484,6 +484,10 @@ Ext.define('PVE.form.CephRuleSelector', { if (!me.nodename) { throw "no nodename given"; } + + me.originalAllowBlank = me.allowBlank; + me.allowBlank = true; + Ext.apply(me, { store: { fields: ['name'], @@ -492,13 +496,17 @@ Ext.define('PVE.form.CephRuleSelector', { type: 'proxmox', url: `/api2/json/nodes/${me.nodename}/ceph/rules`, }, - autoLoad: me.isCreate ? { + autoLoad: { callback: (records, op, success) => { - if (success && records.length > 0) { + if (me.isCreate && success && records.length > 0) { me.select(records[0]); } + + me.allowBlank = me.originalAllowBlank; + delete me.originalAllowBlank; + me.validate(); }, - } : true, + }, }, }); -- 2.39.5