From f500bd65af69da2bc24d26987896799dda0cd2c2 Mon Sep 17 00:00:00 2001 From: ethan-l-geotab Date: Thu, 8 May 2025 11:41:04 -0400 Subject: [PATCH 1/5] flipping back to original redux state for update --- .../src/explore/components/PropertiesModal/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/explore/components/PropertiesModal/index.tsx b/superset-frontend/src/explore/components/PropertiesModal/index.tsx index d4163535af74..173c0e897982 100644 --- a/superset-frontend/src/explore/components/PropertiesModal/index.tsx +++ b/superset-frontend/src/explore/components/PropertiesModal/index.tsx @@ -198,12 +198,22 @@ function PropertiesModal({ body: JSON.stringify(payload), }); // update the redux state + // convert the tags to the format used in the selectOwners back to original redux format + const selectedOwnersArray = ensureIsArray(selectedOwners); + const newOwners = selectedOwnersArray.map((owner: any) => { + const [first_name, ...last_name_parts] = owner.label.split(' '); + return { + id: owner.value, + first_name, + last_name: last_name_parts.join(' '), + }; + }); const updatedChart = { ...payload, ...res.json.result, tags, id: slice.slice_id, - owners: selectedOwners, + owners: newOwners, }; onSave(updatedChart); addSuccessToast(t('Chart properties updated')); From 7d55d6e53c3300eacbb2d3d44bbb4511994d0fea Mon Sep 17 00:00:00 2001 From: ethan-l-geotab Date: Thu, 8 May 2025 13:54:05 -0400 Subject: [PATCH 2/5] korbit suggestions --- .../src/explore/components/PropertiesModal/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/explore/components/PropertiesModal/index.tsx b/superset-frontend/src/explore/components/PropertiesModal/index.tsx index 173c0e897982..9e91222dd4a3 100644 --- a/superset-frontend/src/explore/components/PropertiesModal/index.tsx +++ b/superset-frontend/src/explore/components/PropertiesModal/index.tsx @@ -201,11 +201,14 @@ function PropertiesModal({ // convert the tags to the format used in the selectOwners back to original redux format const selectedOwnersArray = ensureIsArray(selectedOwners); const newOwners = selectedOwnersArray.map((owner: any) => { - const [first_name, ...last_name_parts] = owner.label.split(' '); + const nameParts = owner.label.split(' '); + const first_name = nameParts[0] || ''; + const last_name = + nameParts.length > 1 ? nameParts.slice(1).join(' ') : ''; return { id: owner.value, first_name, - last_name: last_name_parts.join(' '), + last_name, }; }); const updatedChart = { From 19b3173721adeae04d549f77d85d1765354bf4fc Mon Sep 17 00:00:00 2001 From: ethan-l-geotab Date: Tue, 20 May 2025 15:23:52 -0400 Subject: [PATCH 3/5] new solution --- .../components/PropertiesModal/index.tsx | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/superset-frontend/src/explore/components/PropertiesModal/index.tsx b/superset-frontend/src/explore/components/PropertiesModal/index.tsx index 9e91222dd4a3..b26140a261d8 100644 --- a/superset-frontend/src/explore/components/PropertiesModal/index.tsx +++ b/superset-frontend/src/explore/components/PropertiesModal/index.tsx @@ -192,33 +192,15 @@ function PropertiesModal({ } try { - const res = await SupersetClient.put({ + let res = await SupersetClient.put({ endpoint: `/api/v1/chart/${slice.slice_id}`, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }); - // update the redux state - // convert the tags to the format used in the selectOwners back to original redux format - const selectedOwnersArray = ensureIsArray(selectedOwners); - const newOwners = selectedOwnersArray.map((owner: any) => { - const nameParts = owner.label.split(' '); - const first_name = nameParts[0] || ''; - const last_name = - nameParts.length > 1 ? nameParts.slice(1).join(' ') : ''; - return { - id: owner.value, - first_name, - last_name, - }; + res = await SupersetClient.get({ + endpoint: `/api/v1/chart/${slice.slice_id}`, }); - const updatedChart = { - ...payload, - ...res.json.result, - tags, - id: slice.slice_id, - owners: newOwners, - }; - onSave(updatedChart); + onSave(res.json.result); addSuccessToast(t('Chart properties updated')); onHide(); } catch (res) { From d736c35cb09e40ec565b3cffcd30fd3b1c116f51 Mon Sep 17 00:00:00 2001 From: ethan-l-geotab Date: Fri, 8 Aug 2025 15:47:42 -0400 Subject: [PATCH 4/5] return new data --- .../components/PropertiesModal/PropertiesModal.test.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx b/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx index 4bfa0cff8567..48f2df834466 100644 --- a/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx +++ b/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx @@ -86,6 +86,12 @@ fetchMock.get('glob:*/api/v1/chart/318*', { type: 1, }, ], + show_title: 'Show Slice', + certification_details: 'Test certification details', + certified_by: 'Test certified by', + description: 'Test description', + cache_timeout: '1000', + slice_name: 'Test chart new name', }, show_columns: [ 'owners.id', From cf401880aca682b57011d065c0ab398cf720555b Mon Sep 17 00:00:00 2001 From: ethan-l-geotab <165913720+ethan-l-geotab@users.noreply.github.com> Date: Tue, 26 Aug 2025 11:07:45 -0400 Subject: [PATCH 5/5] Refactor chart endpoint usage in PropertiesModal --- .../src/explore/components/PropertiesModal/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/explore/components/PropertiesModal/index.tsx b/superset-frontend/src/explore/components/PropertiesModal/index.tsx index b26140a261d8..c9e14d44512e 100644 --- a/superset-frontend/src/explore/components/PropertiesModal/index.tsx +++ b/superset-frontend/src/explore/components/PropertiesModal/index.tsx @@ -192,13 +192,14 @@ function PropertiesModal({ } try { + const chartEndpoint = `/api/v1/chart/${slice.slice_id}`; let res = await SupersetClient.put({ - endpoint: `/api/v1/chart/${slice.slice_id}`, + endpoint: chartEndpoint, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }); res = await SupersetClient.get({ - endpoint: `/api/v1/chart/${slice.slice_id}`, + endpoint: chartEndpoint, }); onSave(res.json.result); addSuccessToast(t('Chart properties updated'));