[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
This commit is contained in:
Chris Williams 2018-10-25 11:44:05 -07:00 committed by GitHub
parent ef8429cbf5
commit e7e8e9d00d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 15 deletions

View File

@ -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 }) =>

View File

@ -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,
),
),
]),
);
}),
);
}

View File

@ -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 &&