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/08/01 22:37:00 UTC

[GitHub] timifasubaa closed pull request #5540: Fix superset error message flow

timifasubaa closed pull request #5540: Fix superset error message flow
URL: https://github.com/apache/incubator-superset/pull/5540
 
 
   

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/SqlLab/actions.js b/superset/assets/src/SqlLab/actions.js
index 798e8bde83..dae8ebf7a5 100644
--- a/superset/assets/src/SqlLab/actions.js
+++ b/superset/assets/src/SqlLab/actions.js
@@ -187,7 +187,7 @@ export function runQuery(query) {
         if (msg.indexOf('CSRF token') > 0) {
           msg = COMMON_ERR_MESSAGES.SESSION_TIMED_OUT;
         }
-        dispatch(queryFailed(query, msg, getErrorLink(msg)));
+        dispatch(queryFailed(query, msg, getErrorLink(err)));
       },
     });
   };
diff --git a/superset/assets/src/SqlLab/components/ResultSet.jsx b/superset/assets/src/SqlLab/components/ResultSet.jsx
index 6f502ea14e..1acda09b89 100644
--- a/superset/assets/src/SqlLab/components/ResultSet.jsx
+++ b/superset/assets/src/SqlLab/components/ResultSet.jsx
@@ -161,7 +161,7 @@ export default class ResultSet extends React.PureComponent {
       return (
         <Alert bsStyle="danger">
           {query.errorMessage}
-          {query.link && <a href={query.link}> {t('(Common errors and their resolutions)')} </a>}
+          {query.link && <a href={query.link}> {t('(Request Access)')} </a>}
         </Alert>);
     } else if (query.state === 'success' && query.ctas) {
       return (
diff --git a/superset/security.py b/superset/security.py
index f218f05248..0bfca36e9e 100644
--- a/superset/security.py
+++ b/superset/security.py
@@ -129,6 +129,10 @@ def get_table_access_error_msg(self, table_name):
         return """You need access to the following tables: {}, all database access or
               `all_datasource_access` permission""".format(table_name)
 
+    def get_table_access_link(self, tables):
+        from superset import conf
+        return conf.get('PERMISSION_INSTRUCTIONS_LINK')
+
     def datasource_access_by_name(
             self, database, datasource_name, schema=None):
         from superset import db
@@ -147,15 +151,19 @@ def datasource_access_by_name(
                 return True
         return False
 
-    def datasource_access_by_fullname(
-            self, database, full_table_name, schema):
-        table_name_pieces = full_table_name.split('.')
+    def get_schema_and_table(self, table_in_query, schema):
+        table_name_pieces = table_in_query.split('.')
         if len(table_name_pieces) == 2:
             table_schema = table_name_pieces[0]
             table_name = table_name_pieces[1]
         else:
             table_schema = schema
             table_name = table_name_pieces[0]
+        return (table_schema, table_name)
+
+    def datasource_access_by_fullname(
+            self, database, table_in_query, schema):
+        table_schema, table_name = self.get_schema_and_table(table_in_query, schema)
         return self.datasource_access_by_name(
             database, table_name, schema=table_schema)
 
diff --git a/superset/views/base.py b/superset/views/base.py
index d3fd1a4e06..25de44d26a 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -46,8 +46,9 @@ def json_error_response(msg=None, status=500, stacktrace=None, payload=None, lin
         payload = {'error': str(msg)}
         if stacktrace:
             payload['stacktrace'] = stacktrace
-        if link:
-            payload['link'] = link
+    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 0e41d4576b..2faecc37fb 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2426,9 +2426,8 @@ def sql_json(self):
         rejected_tables = security_manager.rejected_datasources(sql, mydb, schema)
         if rejected_tables:
             return json_error_response(
-                security_manager.get_datasource_access_error_msg('{}'.format(
-                    rejected_tables)),
-                link=security_manager.get_table_error_link(rejected_tables))
+                security_manager.get_table_access_error_msg(rejected_tables),
+                link=security_manager.get_table_access_link(rejected_tables))
         session.commit()
 
         select_as_cta = request.form.get('select_as_cta') == 'true'


 

----------------------------------------------------------------
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