Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard][bugfix][save as] re-direct to copied dashboard upon saveas #6189

Merged
merged 4 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 17 additions & 15 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,21 @@ export function fetchAllSlices(userId) {

return dispatch(setAllSlices(slices));
})
.catch(error =>
Promise.all([
dispatch(
fetchAllSlicesFailed(
error.error ||
error.statusText ||
t('Could not fetch all saved charts'),
.catch(errorResponse =>
getClientErrorObject(errorResponse).then(({ error }) =>
Promise.all([
Copy link
Contributor

@kristw kristw Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promise.all seems unnecessary.
Is anybody expecting the result from the dispatches?
Might be better to return the errorObject, or don't care about return value at all.

.catch(errorResponse => 
  getClientErrorObject(errorResponse).then(({ error }) => {
    dispatch(...);
    dispatch(...);
  });
.catch(errorResponse => {
  const errorObjectPromise = getClientErrorObject(errorResponse);
  errorObject.then(({ error }) => {
    dispatch(...);
    dispatch(...);
  });
  return errorObjectPromise;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is necessary over here. redirecting is depends on new dash id in the response.

dispatch(
fetchAllSlicesFailed(
error || t('Could not fetch all saved charts'),
),
),
),
dispatch(
addDangerToast(
t('Sorry there was an error fetching saved charts: ') +
error.error || error.statusText,
dispatch(
addDangerToast(
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