[sqllab] Fix sql lab resolution link (#5216)
* pass link * update frontend to show link differently * nits
This commit is contained in:
parent
70679d4c93
commit
93cdf60920
|
|
@ -78,8 +78,8 @@ export function querySuccess(query, results) {
|
|||
return { type: QUERY_SUCCESS, query, results };
|
||||
}
|
||||
|
||||
export function queryFailed(query, msg) {
|
||||
return { type: QUERY_FAILED, query, msg };
|
||||
export function queryFailed(query, msg, link) {
|
||||
return { type: QUERY_FAILED, query, msg, link };
|
||||
}
|
||||
|
||||
export function stopQuery(query) {
|
||||
|
|
@ -98,6 +98,14 @@ export function requestQueryResults(query) {
|
|||
return { type: REQUEST_QUERY_RESULTS, query };
|
||||
}
|
||||
|
||||
function getErrorLink(err) {
|
||||
let link = '';
|
||||
if (err.responseJSON && err.responseJSON.link) {
|
||||
link = err.responseJSON.link;
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
export function fetchQueryResults(query) {
|
||||
return function (dispatch) {
|
||||
dispatch(requestQueryResults(query));
|
||||
|
|
@ -114,7 +122,7 @@ export function fetchQueryResults(query) {
|
|||
if (err.responseJSON && err.responseJSON.error) {
|
||||
msg = err.responseJSON.error;
|
||||
}
|
||||
dispatch(queryFailed(query, msg));
|
||||
dispatch(queryFailed(query, msg, getErrorLink(err)));
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
@ -166,7 +174,7 @@ export function runQuery(query) {
|
|||
if (msg.indexOf('CSRF token') > 0) {
|
||||
msg = COMMON_ERR_MESSAGES.SESSION_TIMED_OUT;
|
||||
}
|
||||
dispatch(queryFailed(query, msg));
|
||||
dispatch(queryFailed(query, msg, getErrorLink(msg)));
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -155,7 +155,11 @@ export default class ResultSet extends React.PureComponent {
|
|||
if (query.state === 'stopped') {
|
||||
return <Alert bsStyle="warning">Query was stopped</Alert>;
|
||||
} else if (query.state === 'failed') {
|
||||
return <Alert bsStyle="danger">{query.errorMessage}</Alert>;
|
||||
return (
|
||||
<Alert bsStyle="danger">
|
||||
{query.errorMessage}
|
||||
{query.link && <a href={query.link}> {t('(Common errors and their resolutions)')} </a>}
|
||||
</Alert>);
|
||||
} else if (query.state === 'success' && query.ctas) {
|
||||
return (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ class SouthPane extends React.PureComponent {
|
|||
} else {
|
||||
results = <Alert bsStyle="info">{t('Run a query to display results here')}</Alert>;
|
||||
}
|
||||
|
||||
const dataPreviewTabs = props.dataPreviewQueries.map(query => (
|
||||
<Tab
|
||||
title={t('Preview for %s', query.tableName)}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,12 @@ export const sqlLabReducer = function (state, action) {
|
|||
if (action.query.state === 'stopped') {
|
||||
return state;
|
||||
}
|
||||
const alts = { state: 'failed', errorMessage: action.msg, endDttm: now() };
|
||||
const alts = {
|
||||
state: 'failed',
|
||||
errorMessage: action.msg,
|
||||
endDttm: now(),
|
||||
link: action.link,
|
||||
};
|
||||
return alterInObject(state, 'queries', action.query, alts);
|
||||
},
|
||||
[actions.SET_ACTIVE_QUERY_EDITOR]() {
|
||||
|
|
|
|||
|
|
@ -152,9 +152,6 @@ def execute_sql(
|
|||
def handle_error(msg):
|
||||
"""Local method handling error while processing the SQL"""
|
||||
troubleshooting_link = config['TROUBLESHOOTING_LINK']
|
||||
msg = 'Error: {}. You can find common superset errors and their \
|
||||
resolutions at: {}'.format(msg, troubleshooting_link) \
|
||||
if troubleshooting_link else msg
|
||||
query.error_message = msg
|
||||
query.status = QueryStatus.FAILED
|
||||
query.tmp_table_name = None
|
||||
|
|
@ -163,6 +160,8 @@ def execute_sql(
|
|||
'status': query.status,
|
||||
'error': msg,
|
||||
})
|
||||
if troubleshooting_link:
|
||||
payload['link'] = troubleshooting_link
|
||||
return payload
|
||||
|
||||
if store_results and not results_backend:
|
||||
|
|
|
|||
Loading…
Reference in New Issue