You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/06/14 15:15:29 UTC

[superset] branch hugh/fix-params created (now 7c9e71b)

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

hugh pushed a change to branch hugh/fix-params
in repository https://gitbox.apache.org/repos/asf/superset.git.


      at 7c9e71b  working query params

This branch includes the following new commits:

     new 7c9e71b  working query params

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[superset] 01/01: working query params

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hugh/fix-params
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 7c9e71be048b642f2c00e10ed6a3727d4d70d0ad
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Jun 14 11:14:03 2021 -0400

    working query params
---
 .../CRUD/data/database/DatabaseModal/index.tsx      | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
index e350200..32a96c8 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -169,10 +169,19 @@ function dbReducer(
         [action.payload.name]: action.payload.value,
       };
     case ActionType.fetched:
+      let query = '';
+      if (action.payload?.parameters?.query) {
+        // convert query into URI params string
+        query = new URLSearchParams(action.payload.parameters.query).toString();
+      }
       return {
         engine: trimmedState.engine,
         configuration_method: trimmedState.configuration_method,
         ...action.payload,
+        parameters: {
+          ...action.payload.parameters,
+          query,
+        },
       };
     case ActionType.dbSelected:
       return {
@@ -266,6 +275,18 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     const { id, ...update } = db || {};
     if (db?.id) {
+      if (update?.parameters?.query) {
+        // convert query params into dictionary
+        update.parameters.query = JSON.parse(
+          `{"${decodeURI(db.parameters?.query || '')
+            .replace(/"/g, '\\"')
+            .replace(/&/g, '","')
+            .replace(/=/g, '":"')}"}`,
+        );
+      } else {
+        update.parameters.query = {};
+      }
+
       const result = await updateResource(
         db.id as number,
         update as DatabaseObject,