mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
pass_error_message_separately
This commit is contained in:
parent
6e37d3f882
commit
7a107fac62
@ -221,6 +221,7 @@ class Chart extends React.PureComponent {
|
|||||||
<StackTraceMessage
|
<StackTraceMessage
|
||||||
message={this.props.chartAlert}
|
message={this.props.chartAlert}
|
||||||
queryResponse={this.props.queryResponse}
|
queryResponse={this.props.queryResponse}
|
||||||
|
resolutionLink={this.props.resolutionLink}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,11 @@ const propTypes = {
|
|||||||
message: PropTypes.string,
|
message: PropTypes.string,
|
||||||
queryResponse: PropTypes.object,
|
queryResponse: PropTypes.object,
|
||||||
showStackTrace: PropTypes.bool,
|
showStackTrace: PropTypes.bool,
|
||||||
|
resolutionLink: PropTypes.string,
|
||||||
};
|
};
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
showStackTrace: false,
|
showStackTrace: false,
|
||||||
|
resolutionLink: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
class StackTraceMessage extends React.PureComponent {
|
class StackTraceMessage extends React.PureComponent {
|
||||||
@ -25,6 +27,10 @@ class StackTraceMessage extends React.PureComponent {
|
|||||||
return this.props.queryResponse && this.props.queryResponse.stacktrace;
|
return this.props.queryResponse && this.props.queryResponse.stacktrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasLink() {
|
||||||
|
return this.props.queryResponse && this.props.queryResponse.link;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className={`stack-trace-container${this.hasTrace() ? ' has-trace' : ''}`}>
|
<div className={`stack-trace-container${this.hasTrace() ? ' has-trace' : ''}`}>
|
||||||
@ -33,6 +39,9 @@ class StackTraceMessage extends React.PureComponent {
|
|||||||
onClick={() => this.setState({ showStackTrace: !this.state.showStackTrace })}
|
onClick={() => this.setState({ showStackTrace: !this.state.showStackTrace })}
|
||||||
>
|
>
|
||||||
{this.props.message}
|
{this.props.message}
|
||||||
|
{this.hasLink() &&
|
||||||
|
<a href={this.props.queryResponse.link}> (Request Access) </a>
|
||||||
|
}
|
||||||
</Alert>
|
</Alert>
|
||||||
{this.hasTrace() &&
|
{this.hasTrace() &&
|
||||||
<Collapse in={this.state.showStackTrace}>
|
<Collapse in={this.state.showStackTrace}>
|
||||||
|
@ -41,11 +41,13 @@ def get_error_msg():
|
|||||||
return error_msg
|
return error_msg
|
||||||
|
|
||||||
|
|
||||||
def json_error_response(msg=None, status=500, stacktrace=None, payload=None):
|
def json_error_response(msg=None, status=500, stacktrace=None, payload=None, link=None):
|
||||||
if not payload:
|
if not payload:
|
||||||
payload = {'error': str(msg)}
|
payload = {'error': str(msg)}
|
||||||
if stacktrace:
|
if stacktrace:
|
||||||
payload['stacktrace'] = stacktrace
|
payload['stacktrace'] = stacktrace
|
||||||
|
if link:
|
||||||
|
payload['link'] = link
|
||||||
return Response(
|
return Response(
|
||||||
json.dumps(payload, default=utils.json_iso_dttm_ser),
|
json.dumps(payload, default=utils.json_iso_dttm_ser),
|
||||||
status=status, mimetype='application/json')
|
status=status, mimetype='application/json')
|
||||||
|
@ -68,14 +68,7 @@ DATASOURCE_MISSING_ERR = __('The datasource seems to have been deleted')
|
|||||||
ACCESS_REQUEST_MISSING_ERR = __(
|
ACCESS_REQUEST_MISSING_ERR = __(
|
||||||
'The access requests seem to have been deleted')
|
'The access requests seem to have been deleted')
|
||||||
USER_MISSING_ERR = __('The user seems to have been deleted')
|
USER_MISSING_ERR = __('The user seems to have been deleted')
|
||||||
perms_instruction_link = config.get('PERMISSION_INSTRUCTIONS_LINK')
|
DATASOURCE_ACCESS_ERR = __("You don't have access to this datasource")
|
||||||
if perms_instruction_link:
|
|
||||||
DATASOURCE_ACCESS_ERR = __(
|
|
||||||
"You don't have access to this datasource. <a href='{}'>(Gain access)</a>"
|
|
||||||
.format(perms_instruction_link),
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
DATASOURCE_ACCESS_ERR = __("You don't have access to this datasource")
|
|
||||||
|
|
||||||
FORM_DATA_KEY_BLACKLIST = []
|
FORM_DATA_KEY_BLACKLIST = []
|
||||||
if not config.get('ENABLE_JAVASCRIPT_CONTROLS'):
|
if not config.get('ENABLE_JAVASCRIPT_CONTROLS'):
|
||||||
@ -1090,7 +1083,9 @@ class Superset(BaseSupersetView):
|
|||||||
stacktrace=traceback.format_exc())
|
stacktrace=traceback.format_exc())
|
||||||
|
|
||||||
if not security_manager.datasource_access(viz_obj.datasource, g.user):
|
if not security_manager.datasource_access(viz_obj.datasource, g.user):
|
||||||
return json_error_response(DATASOURCE_ACCESS_ERR, status=404)
|
perms_instruction_link = config.get('PERMISSION_INSTRUCTIONS_LINK')
|
||||||
|
return json_error_response(
|
||||||
|
DATASOURCE_ACCESS_ERR, status=404, link=perms_instruction_link)
|
||||||
|
|
||||||
if csv:
|
if csv:
|
||||||
return CsvResponse(
|
return CsvResponse(
|
||||||
|
Loading…
Reference in New Issue
Block a user