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:36:08 UTC
(superset) 01/01: 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 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 06195b53ce60d292cf1f4908ed368bc62930fa2d
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Fri Mar 22 10:24:31 2024 +0100
fix: Persist query params appended to permalink (#27601)
---
superset/models/dashboard.py | 6 +++---
superset/views/core.py | 2 ++
tests/integration_tests/core_tests.py | 15 +++++++++++++++
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index b615d886ee..f5a1b3c061 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -320,9 +320,9 @@ class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
)
def datasets_trimmed_for_slices(self) -> list[dict[str, Any]]:
# Verbose but efficient database enumeration of dashboard datasources.
- slices_by_datasource: dict[tuple[type[BaseDatasource], int], set[Slice]] = (
- defaultdict(set)
- )
+ slices_by_datasource: dict[
+ tuple[type[BaseDatasource], int], set[Slice]
+ ] = defaultdict(set)
for slc in self.slices:
slices_by_datasource[(slc.cls_model, slc.datasource_id)].add(slc)
diff --git a/superset/views/core.py b/superset/views/core.py
index 613ea89b34..dead91cb98 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -891,6 +891,8 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
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 c4a0897332..3698e5f5be 100644
--- a/tests/integration_tests/core_tests.py
+++ b/tests/integration_tests/core_tests.py
@@ -1220,6 +1220,21 @@ class TestCore(SupersetTestCase):
resp = self.client.get("/superset/sqllab/history/")
assert resp.status_code == 302
+ @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()