You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "justinpark (via GitHub)" <gi...@apache.org> on 2023/10/09 19:25:45 UTC

[PR] fix(sqllab): Forcefully open sql in new browser tab [superset]

justinpark opened a new pull request, #25582:
URL: https://github.com/apache/superset/pull/25582

   ### SUMMARY
   Fixes the addressed issue (no. 6) on https://github.com/apache/superset/pull/25151#issuecomment-1747279563
   
   Since the #25151 replaces the SupersetClient.postForm by the router navigation, it loses the way to open the sql link in the new browser tab.
   This commit recovers the way of opening sql in the new browser tab forcefully (when opening the link with the command/window key pressed).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before:
   
   https://github.com/apache/superset/assets/1392866/7514c6aa-9c8a-440f-aa70-59749bca82f8
   
   After:
   
   https://github.com/apache/superset/assets/1392866/9f64b550-527d-493b-94cd-d03425710ca7
   
   ### TESTING INSTRUCTIONS
   Go to Explore and open the control menu
   Click the Open in SQL Lab link with the cmd key (cmd + click/win + click)
   The editor with the populated sql will be opened in the new browser tab
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] fix(sqllab): Allow opening of SQL Lab in new browser tab [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark merged PR #25582:
URL: https://github.com/apache/superset/pull/25582


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] fix(sqllab): Forcefully open sql in new browser tab [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on code in PR #25582:
URL: https://github.com/apache/superset/pull/25582#discussion_r1350724768


##########
superset/views/sqllab.py:
##########
@@ -31,12 +35,16 @@ class SqllabView(BaseSupersetView):
 
     method_permission_name = MODEL_API_RW_METHOD_PERMISSION_MAP
 
-    @expose("/")
+    @expose("/", methods=["GET", "POST"])
     @has_access
     @permission_name("read")
     @event_logger.log_this
     def root(self) -> FlaskResponse:
-        return self.render_app_template()
+        payload = {}
+        if form_data := request.form.get("form_data"):
+            with contextlib.suppress(json.JSONDecodeError):
+                payload["requested_query"] = json.loads(form_data)
+        return self.render_app_template(payload)

Review Comment:
   restored from https://github.com/apache/superset/pull/25151/files#diff-76c6a0b5c14a297c62ac3207416870471affdb153c5ae12b96d7b7da9304e9ddL996-L999



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] fix(sqllab): Forcefully open sql in new browser tab [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on code in PR #25582:
URL: https://github.com/apache/superset/pull/25582#discussion_r1350723259


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -294,12 +323,13 @@ class DatasourceControl extends React.PureComponent {
         )}
         <Menu.Item key={CHANGE_DATASET}>{t('Swap dataset')}</Menu.Item>
         {!isMissingDatasource && canAccessSqlLab && (
-          <Menu.Item>
+          <Menu.Item key={VIEW_IN_SQL_LAB}>

Review Comment:
   restored from https://github.com/apache/superset/pull/25151/files#diff-78c4d83a33f43bb08129edc9951935a77f11e58fe32f85565ab0576dcfbb01f0L129-L253



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] fix(sqllab): Forcefully open sql in new browser tab [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on code in PR #25582:
URL: https://github.com/apache/superset/pull/25582#discussion_r1350723621


##########
superset-frontend/src/components/Chart/chartAction.js:
##########
@@ -579,12 +580,18 @@ export function redirectSQLLab(formData, history) {
           datasourceKey: formData.datasource,
           sql: json.result[0].query,
         };
-        history.push({
-          pathname: redirectUrl,
-          state: {
-            requestedQuery: payload,
-          },
-        });
+        if (history) {
+          history.push({
+            pathname: redirectUrl,
+            state: {
+              requestedQuery: payload,
+            },
+          });
+        } else {
+          SupersetClient.postForm(redirectUrl, {

Review Comment:
   restored from https://github.com/apache/superset/pull/25151/files#diff-a612babd68b1abfd9dd4ebeff1bec35c7512602e35846c4058aacbac65c6c7beL583-L584



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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