From c37d3a939fb0618926cb6d0034a0507e7bffdf85 Mon Sep 17 00:00:00 2001 From: Darya Plotnytska Date: Mon, 23 Oct 2023 15:01:27 +0200 Subject: [PATCH 1/2] console: Fix general settings submit --- .../views/gateway-general-settings/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/webui/console/views/gateway-general-settings/index.js b/pkg/webui/console/views/gateway-general-settings/index.js index 1d256092a9..278188909f 100644 --- a/pkg/webui/console/views/gateway-general-settings/index.js +++ b/pkg/webui/console/views/gateway-general-settings/index.js @@ -77,12 +77,26 @@ const GatewayGeneralSettingsInner = () => { const handleSubmit = useCallback( async values => { const formValues = { ...values } - const { attributes } = formValues + const { attributes, frequency_plan_ids } = formValues if (isEqual(gateway.attributes || {}, attributes)) { delete formValues.attributes } const changed = diff(gateway, formValues) - const update = 'attributes' in changed ? { ...changed, attributes } : changed + let update + if ('attributes' in changed) { + update = { + ...changed, + attributes, + } + } else if ('frequency_plan_ids' in changed) { + update = { + ...changed, + frequency_plan_ids, + } + } else { + update = changed + } + try { await dispatch(updateGateway(gtwId, update)) toast({ From 19e91024ff035ea513da0b25850ab78712e7b09c Mon Sep 17 00:00:00 2001 From: Darya Plotnytska Date: Tue, 24 Oct 2023 09:53:53 +0200 Subject: [PATCH 2/2] console: Use diff patch in full --- .../views/gateway-general-settings/index.js | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/pkg/webui/console/views/gateway-general-settings/index.js b/pkg/webui/console/views/gateway-general-settings/index.js index 278188909f..47e5426945 100644 --- a/pkg/webui/console/views/gateway-general-settings/index.js +++ b/pkg/webui/console/views/gateway-general-settings/index.js @@ -81,24 +81,17 @@ const GatewayGeneralSettingsInner = () => { if (isEqual(gateway.attributes || {}, attributes)) { delete formValues.attributes } - const changed = diff(gateway, formValues) - let update - if ('attributes' in changed) { - update = { - ...changed, - attributes, - } - } else if ('frequency_plan_ids' in changed) { - update = { - ...changed, - frequency_plan_ids, - } - } else { - update = changed + if (isEqual(gateway.frequency_plan_ids || {}, frequency_plan_ids)) { + delete formValues.frequency_plan_ids } + const changed = diff(gateway, formValues, { + patchArraysItems: false, + patchInFull: ['attributes', 'frequency_plan_ids'], + }) + try { - await dispatch(updateGateway(gtwId, update)) + await dispatch(updateGateway(gtwId, changed)) toast({ title: gtwId, message: m.updateSuccess,