You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/06/14 04:45:21 UTC

[GitHub] timifasubaa closed pull request #5193: [WIP] Fix access request flow

timifasubaa closed pull request #5193: [WIP] Fix access request flow
URL: https://github.com/apache/incubator-superset/pull/5193
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/chart/Chart.jsx b/superset/assets/src/chart/Chart.jsx
index f223174efa..e7c0d3f078 100644
--- a/superset/assets/src/chart/Chart.jsx
+++ b/superset/assets/src/chart/Chart.jsx
@@ -221,6 +221,7 @@ class Chart extends React.PureComponent {
         <StackTraceMessage
           message={this.props.chartAlert}
           queryResponse={this.props.queryResponse}
+          resolutionLink={this.props.resolutionLink}
         />
         }
 
diff --git a/superset/assets/src/chart/chartAction.js b/superset/assets/src/chart/chartAction.js
index cb24f65f14..dd7522e9ae 100644
--- a/superset/assets/src/chart/chartAction.js
+++ b/superset/assets/src/chart/chartAction.js
@@ -135,6 +135,7 @@ export function runQuery(formData, force = false, timeout = 60, key) {
       },
       timeout: timeout * 1000,
     });
+    // HYERR IT IS
     const queryPromise = Promise.resolve(dispatch(chartUpdateStarted(queryRequest, payload, key)))
       .then(() => queryRequest)
       .then((queryResponse) => {
diff --git a/superset/assets/src/chart/chartReducer.js b/superset/assets/src/chart/chartReducer.js
index f68a5b80ee..f97590a930 100644
--- a/superset/assets/src/chart/chartReducer.js
+++ b/superset/assets/src/chart/chartReducer.js
@@ -34,6 +34,7 @@ export const chart = {
 export default function chartReducer(charts = {}, action) {
   const actionHandlers = {
     [actions.CHART_UPDATE_SUCCEEDED](state) {
+      console.log(state);
       return { ...state,
         chartStatus: 'success',
         queryResponse: action.queryResponse,
diff --git a/superset/assets/src/components/StackTraceMessage.jsx b/superset/assets/src/components/StackTraceMessage.jsx
index ee190b7c5c..ab6f3e1904 100644
--- a/superset/assets/src/components/StackTraceMessage.jsx
+++ b/superset/assets/src/components/StackTraceMessage.jsx
@@ -10,6 +10,7 @@ const propTypes = {
 };
 const defaultProps = {
   showStackTrace: false,
+  resolutionLink: '',
 };
 
 class StackTraceMessage extends React.PureComponent {
@@ -25,6 +26,10 @@ class StackTraceMessage extends React.PureComponent {
     return this.props.queryResponse && this.props.queryResponse.stacktrace;
   }
 
+  hasLink() {
+    return this.props.queryResponse && this.props.queryResponse.link;
+  }
+
   render() {
     return (
       <div className={`stack-trace-container${this.hasTrace() ? ' has-trace' : ''}`}>
@@ -32,7 +37,10 @@ class StackTraceMessage extends React.PureComponent {
           bsStyle="warning"
           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>
         {this.hasTrace() &&
           <Collapse in={this.state.showStackTrace}>
diff --git a/superset/views/base.py b/superset/views/base.py
index dc2e48f43a..d3fd1a4e06 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -41,11 +41,13 @@ def get_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:
         payload = {'error': str(msg)}
         if stacktrace:
             payload['stacktrace'] = stacktrace
+        if link:
+            payload['link'] = link
     return Response(
         json.dumps(payload, default=utils.json_iso_dttm_ser),
         status=status, mimetype='application/json')
diff --git a/superset/views/core.py b/superset/views/core.py
index 14380c50ab..b0c91046f7 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -68,14 +68,7 @@
 ACCESS_REQUEST_MISSING_ERR = __(
     'The access requests seem to have been deleted')
 USER_MISSING_ERR = __('The user seems to have been deleted')
-perms_instruction_link = config.get('PERMISSION_INSTRUCTIONS_LINK')
-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")
+DATASOURCE_ACCESS_ERR = __("You don't have access to this datasource")
 
 FORM_DATA_KEY_BLACKLIST = []
 if not config.get('ENABLE_JAVASCRIPT_CONTROLS'):
@@ -1089,8 +1082,11 @@ def generate_json(self, datasource_type, datasource_id, form_data,
                 utils.error_msg_from_exception(e),
                 stacktrace=traceback.format_exc())
 
-        if not security_manager.datasource_access(viz_obj.datasource, g.user):
-            return json_error_response(DATASOURCE_ACCESS_ERR, status=404)
+        if True: #not security_manager.datasource_access(viz_obj.datasource, g.user):
+            #check where this is called on the frontend and try to see if you can make the container render the bootstrao daata if it is there 
+            # ****
+            perms_instruction_link = config.get('PERMISSION_INSTRUCTIONS_LINK')
+            return json_error_response(DATASOURCE_ACCESS_ERR, status=404, link=perms_instruction_link)
 
         if csv:
             return CsvResponse(


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org