From f580f6bcba15a20c12ead5b3e6eef643cc0aa1d6 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Wed, 20 Oct 2021 18:45:58 +0300 Subject: [PATCH] fix(Explore): Undefined owners (#17167) * Reconcile owners data * Fix on save --- .../src/components/Datasource/DatasourceEditor.jsx | 4 ++-- .../src/components/Datasource/DatasourceModal.tsx | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx index e725cdc238900..e80e402ec07a4 100644 --- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx +++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx @@ -409,8 +409,8 @@ class DatasourceEditor extends React.PureComponent { datasource: { ...props.datasource, owners: props.datasource.owners.map(owner => ({ - value: owner.id, - label: `${owner.first_name} ${owner.last_name}`, + value: owner.value || owner.id, + label: owner.label || `${owner.first_name} ${owner.last_name}`, })), metrics: props.datasource.metrics?.map(metric => { const { diff --git a/superset-frontend/src/components/Datasource/DatasourceModal.tsx b/superset-frontend/src/components/Datasource/DatasourceModal.tsx index 5cd6f3aa3f95f..89b7b5d6987e1 100644 --- a/superset-frontend/src/components/Datasource/DatasourceModal.tsx +++ b/superset-frontend/src/components/Datasource/DatasourceModal.tsx @@ -119,14 +119,17 @@ const DatasourceModal: FunctionComponent = ({ ), type: currentDatasource.type || currentDatasource.datasource_type, owners: currentDatasource.owners.map( - (o: { label: string; value: number }) => o.value, + (o: Record) => o.value || o.id, ), }, }, }) .then(({ json }) => { addSuccessToast(t('The dataset has been saved')); - onDatasourceSave(json); + onDatasourceSave({ + ...json, + owners: currentDatasource.owners, + }); onHide(); }) .catch(response => {