Skip to content

Commit

Permalink
Fix redirect to SQL Lab (apache#5777)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8af3e1f)
(cherry picked from commit 1d64350)
  • Loading branch information
betodealmeida committed Oct 12, 2018
1 parent 0162a09 commit e34ba4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions superset/assets/src/chart/chartAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ export function runQuery(formData, force = false, timeout = 60, key) {
};
}

export const SQLLAB_REDIRECT_FAILED = 'SQLLAB_REDIRECT_FAILED';
export function sqllabRedirectFailed(error, key) {
return { type: SQLLAB_REDIRECT_FAILED, error, key };
}

export function redirectSQLLab(formData) {
return function () {
return function (dispatch) {
const { url, payload } = getExploreUrlAndPayload({ formData, endpointType: 'query' });
$.ajax({
type: 'POST',
Expand All @@ -218,7 +223,7 @@ export function redirectSQLLab(formData) {
.search({ datasourceKey: formData.datasource, sql: response.query });
window.open(redirectUrl.href(), '_blank');
},
error: () => notify.error(t("The SQL couldn't be loaded")),
error: (xhr, status, error) => dispatch(sqllabRedirectFailed(error, formData.slice_id)),
});
};
}
Expand Down
6 changes: 6 additions & 0 deletions superset/assets/src/chart/chartReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ export default function chartReducer(charts = {}, action) {
annotationQuery,
};
},
[actions.SQLLAB_REDIRECT_FAILED](state) {
return { ...state,
chartStatus: 'failed',
chartAlert: t('An error occurred while redirecting to SQL Lab: %s', action.error),
};
},
};

/* eslint-disable no-param-reassign */
Expand Down

0 comments on commit e34ba4a

Please sign in to comment.