From e7e8e9d00d926384e289a489847ae441aeef079e Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 25 Oct 2018 11:44:05 -0700 Subject: [PATCH] [dashboard][bugfix][save as] re-direct to copied dashboard upon saveas (#6189) * [dashboard][bugfix][save as] re-direct to copied dashboard upon saveas * [dashboard][save modal] safer destructuring * [dashboard][save as] simplify Promise resolution * [dashboard] simply fetch slices error --- .../src/dashboard/actions/dashboardState.js | 4 +--- .../src/dashboard/actions/sliceEntities.js | 22 +++++++++---------- .../src/dashboard/components/SaveModal.jsx | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/superset/assets/src/dashboard/actions/dashboardState.js b/superset/assets/src/dashboard/actions/dashboardState.js index 883a508c0f..2ff139fcdb 100644 --- a/superset/assets/src/dashboard/actions/dashboardState.js +++ b/superset/assets/src/dashboard/actions/dashboardState.js @@ -132,16 +132,14 @@ export function saveDashboardRequest(data, id, saveType) { SupersetClient.post({ endpoint: `/superset/${path}/${id}/`, postPayload: { data }, - parseMethod: null, }) .then(response => Promise.all([ - Promise.resolve(response), dispatch(saveDashboardRequestSuccess()), dispatch( addSuccessToast(t('This dashboard was saved successfully.')), ), - ]), + ]).then(() => Promise.resolve(response)), ) .catch(response => getClientErrorObject(response).then(({ error }) => diff --git a/superset/assets/src/dashboard/actions/sliceEntities.js b/superset/assets/src/dashboard/actions/sliceEntities.js index 33e3507c1a..31a03db0d2 100644 --- a/superset/assets/src/dashboard/actions/sliceEntities.js +++ b/superset/assets/src/dashboard/actions/sliceEntities.js @@ -3,7 +3,10 @@ import { SupersetClient } from '@superset-ui/core'; import { addDangerToast } from '../../messageToasts/actions'; import { t } from '../../locales'; -import { getDatasourceParameter } from '../../modules/utils'; +import { + getDatasourceParameter, + getClientErrorObject, +} from '../../modules/utils'; export const SET_ALL_SLICES = 'SET_ALL_SLICES'; export function setAllSlices(slices) { @@ -64,22 +67,19 @@ export function fetchAllSlices(userId) { return dispatch(setAllSlices(slices)); }) - .catch(error => - Promise.all([ + .catch(errorResponse => + getClientErrorObject(errorResponse).then(({ error }) => { dispatch( fetchAllSlicesFailed( - error.error || - error.statusText || - t('Could not fetch all saved charts'), + error || t('Could not fetch all saved charts'), ), - ), + ); dispatch( addDangerToast( - t('Sorry there was an error fetching saved charts: ') + - error.error || error.statusText, + t('Sorry there was an error fetching saved charts: ') + error, ), - ), - ]), + ); + }), ); } diff --git a/superset/assets/src/dashboard/components/SaveModal.jsx b/superset/assets/src/dashboard/components/SaveModal.jsx index 13863a24c2..2e3d94973f 100644 --- a/superset/assets/src/dashboard/components/SaveModal.jsx +++ b/superset/assets/src/dashboard/components/SaveModal.jsx @@ -93,7 +93,7 @@ class SaveModal extends React.PureComponent { t('You must pick a name for the new dashboard'), ); } else { - this.onSave(data, dashboardId, saveType).then(([resp]) => { + this.onSave(data, dashboardId, saveType).then(resp => { if ( saveType === SAVE_TYPE_NEWDASHBOARD && resp &&