You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2024/03/22 12:30:16 UTC

(superset) 05/06: fix: Persist query params appended to permalink (#27601)

This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4ff331a66c099fdeda7278f3b374e6b33a62a6c8
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Fri Mar 22 10:24:31 2024 +0100

    fix: Persist query params appended to permalink (#27601)
    
    (cherry picked from commit 5083ca0e819d0cb024c597735329566575beccdb)
---
 superset/views/core.py                |  2 ++
 tests/integration_tests/core_tests.py | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/superset/views/core.py b/superset/views/core.py
index cc349d9f32..4faede0f34 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -843,6 +843,8 @@ class Superset(BaseSupersetView):
         if url_params := state.get("urlParams"):
             params = parse.urlencode(url_params)
             url = f"{url}&{params}"
+        if original_params := request.query_string.decode():
+            url = f"{url}&{original_params}"
         if hash_ := state.get("anchor", state.get("hash")):
             url = f"{url}#{hash_}"
         return redirect(url)
diff --git a/tests/integration_tests/core_tests.py b/tests/integration_tests/core_tests.py
index 573b096fc7..ef20fc25af 100644
--- a/tests/integration_tests/core_tests.py
+++ b/tests/integration_tests/core_tests.py
@@ -1185,6 +1185,21 @@ class TestCore(SupersetTestCase):
             is True
         )
 
+    @mock.patch("superset.views.core.request")
+    @mock.patch(
+        "superset.commands.dashboard.permalink.get.GetDashboardPermalinkCommand.run"
+    )
+    def test_dashboard_permalink(self, get_dashboard_permalink_mock, request_mock):
+        request_mock.query_string = b"standalone=3"
+        get_dashboard_permalink_mock.return_value = {"dashboardId": 1}
+        self.login()
+        resp = self.client.get("superset/dashboard/p/123/")
+
+        expected_url = "/superset/dashboard/1?permalink_key=123&standalone=3"
+
+        self.assertEqual(resp.headers["Location"], expected_url)
+        assert resp.status_code == 302
+
 
 if __name__ == "__main__":
     unittest.main()