Skip to content

Commit

Permalink
[dashboard][bugfix][save as] re-direct to copied dashboard upon saveas (
Browse files Browse the repository at this point in the history
apache#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

(cherry picked from commit e7e8e9d)
  • Loading branch information
williaster authored and michellethomas committed Oct 25, 2018
1 parent 8b5abb5 commit a01f913
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 1 addition & 3 deletions superset/assets/src/dashboard/actions/dashboardState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) =>
Expand Down
22 changes: 11 additions & 11 deletions superset/assets/src/dashboard/actions/sliceEntities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
),
),
]),
);
}),
);
}

Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/dashboard/components/SaveModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit a01f913

Please sign in to comment.