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/13 16:52:52 UTC

[superset] branch hugh/move-extra-fields created (now d2abd4b)

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

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


      at d2abd4b  fix upper level values

This branch includes the following new commits:

     new 7de54c6  save this
     new b92c9b3  proper schema
     new d2abd4b  fix upper level values

The 3 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/03: save this

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

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

commit 7de54c6efbf5d6292059827bcea34854d6a1ef90
Author: hughhhh <hu...@gmail.com>
AuthorDate: Sun Jun 13 11:30:20 2021 -0400

    save this
---
 .../data/database/DatabaseModal/ExtraOptions.tsx   |  3 +-
 .../CRUD/data/database/DatabaseModal/index.tsx     | 61 +++++++---------------
 2 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx
index 8e91e05..89e9936 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx
@@ -48,7 +48,6 @@ const ExtraOptions = ({
 }) => {
   const expandableModalIsOpen = !!db?.expose_in_sqllab;
   const createAsOpen = !!(db?.allow_ctas || db?.allow_cvas);
-  const MDPstring = JSON.stringify(db?.extra_json?.metadata_params);
 
   return (
     <Collapse
@@ -419,7 +418,7 @@ const ExtraOptions = ({
           <div className="input-container">
             <StyledJsonEditor
               name="metadata_params"
-              value={MDPstring || '{}'}
+              value={db?.extra_json?.metadata_params || '{}'}
               placeholder={t('Metadata Parameters')}
               onChange={(json: object) =>
                 onExtraEditorChange({ json, name: 'metadata_params' })
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 5ef64ce..49c7da0 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -188,14 +188,29 @@ function dbReducer(
         [action.payload.name]: action.payload.value,
       };
     case ActionType.fetched:
-      console.log(action.payload.extra_json);
+      console.log(action.payload);
+      let extra_json = {
+        ...JSON.parse(action.payload.extra || ''),
+      };
+
+      // convert all the keys in this payload into strings
+      extra_json = {
+        ...extra_json,
+        metadata_params: JSON.stringify(extra_json.metadata_params),
+        engine_params: JSON.stringify(extra_json.engine_params),
+        metadata_cache_timeout: JSON.stringify(
+          extra_json.metadata_cache_timeout,
+        ),
+        schemas_allowed_for_csv_upload: JSON.stringify(
+          extra_json.schemas_allowed_for_csv_upload,
+        ),
+      };
+
       return {
         engine: trimmedState.engine,
         configuration_method: trimmedState.configuration_method,
         ...action.payload,
-        extra_json: {
-          ...JSON.parse(action.payload.extra || ''),
-        },
+        extra_json,
       };
     case ActionType.dbSelected:
     case ActionType.configMethodChange:
@@ -280,44 +295,6 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
         delete update.parameters;
       }
 
-      // const extraValues = {
-      //   metadata_cache_timeout: {
-      //     schema_cache_timeout:
-      //       db?.extra_json?.metadata_cache_timeout?.schema_cache_timeout || '',
-      //     table_cache_timeout:
-      //       db?.extra_json?.metadata_cache_timeout?.table_cache_timeout || '',
-      //   },
-      //   cost_query_enabled: db?.extra_json?.cost_query_enabled || undefined,
-      //   allows_virtual_table_explore:
-      //     db?.extra_json?.allows_virtual_table_explore || undefined,
-      //   schemas_allowed_for_csv_upload:
-      //     db?.extra_json?.schemas_allowed_for_csv_upload || '',
-      //   impersonate_user: db?.extra_json?.impersonate_user || undefined,
-      //   allow_csv_upload: db?.extra_json?.allow_csv_upload || undefined,
-      //   version: db?.extra_json?.version || '',
-      //   metadata_params: db?.extra_json?.metadata_params || {},
-      //   engine_params: db?.extra_json?.engine_params || {},
-      // };
-
-      // console.log('extraValues', extraValues);
-
-      // Structure extra_json
-      // const extraValuesStructured = {
-      //   ...extraValues,
-      //   ...db?.extra_json,
-      // };
-
-      // console.log('extraValuesStructured', extraValuesStructured);
-
-      console.log(
-        'db?.extra_json',
-        JSON.parse(db?.extra_json?.metadata_params),
-      );
-
-      const updateExtraMDP = JSON.parse(db?.extra_json?.metadata_params);
-      // update?.extra_json?.metadata_params = updateExtraMDP;
-      console.log(updateExtraMDP);
-
       // Add values back to extra field
       update.extra = JSON.stringify(
         { ...db?.extra_json, metadata_params: updateExtraMDP },

[superset] 02/03: proper schema

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

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

commit b92c9b333c68b302c8cc87ba9053485315b39a0c
Author: hughhhh <hu...@gmail.com>
AuthorDate: Sun Jun 13 12:02:46 2021 -0400

    proper schema
---
 .../src/views/CRUD/data/database/types.ts              | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/database/types.ts b/superset-frontend/src/views/CRUD/data/database/types.ts
index 2ec6266..e0246f8 100644
--- a/superset-frontend/src/views/CRUD/data/database/types.ts
+++ b/superset-frontend/src/views/CRUD/data/database/types.ts
@@ -49,21 +49,23 @@ export type DatabaseObject = {
   // Security
   encrypted_extra?: string;
   server_cert?: string;
+  allow_csv_upload?: boolean;
+  impersonate_user?: boolean;
 
   // Extra
   extra_json?: {
+    engine_params?: {};
+    metadata_params?: {};
     metadata_cache_timeout?: {
-      schema_cache_timeout?: string; // in Performance
-      table_cache_timeout?: string; // in Performance
+      schema_cache_timeout?: number; // in Performance
+      table_cache_timeout?: number; // in Performance
     }; // No field, holds schema and table timeout
-    cost_query_enabled?: boolean; // in SQL Lab
     allows_virtual_table_explore?: boolean; // in SQL Lab
-    schemas_allowed_for_csv_upload?: string; // in Security
-    impersonate_user?: boolean; // in Security
-    allow_csv_upload?: boolean; // in Security
+    schemas_allowed_for_csv_upload?: []; // in Security
     version?: string;
-    metadata_params?: {};
-    engine_params?: {};
+
+    // todo: ask beto where this should live
+    cost_query_enabled?: boolean; // in SQL Lab
   };
   extra?: string;
 };

[superset] 03/03: fix upper level values

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

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

commit d2abd4b492566e53b5a09bdffd2426e657f283e6
Author: hughhhh <hu...@gmail.com>
AuthorDate: Sun Jun 13 12:50:14 2021 -0400

    fix upper level values
---
 .../data/database/DatabaseModal/ExtraOptions.tsx   |  9 ++++---
 .../CRUD/data/database/DatabaseModal/index.tsx     | 31 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx
index 89e9936..1ee564a 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/ExtraOptions.tsx
@@ -66,6 +66,7 @@ const ExtraOptions = ({
         }
         key="1"
       >
+        {console.log(db)}
         <StyledInputContainer css={{ ...no_margin_bottom }}>
           <div className="input-container">
             <IndeterminateCheckbox
@@ -372,8 +373,8 @@ const ExtraOptions = ({
             <IndeterminateCheckbox
               id="impersonate_user"
               indeterminate={false}
-              checked={!!db?.extra_json?.impersonate_user}
-              onChange={onExtraInputChange}
+              checked={!!db?.impersonate_user}
+              onChange={onInputChange}
               labelText={t('Impersonate logged in user (Presto & Hive)')}
             />
             <InfoTooltip
@@ -392,8 +393,8 @@ const ExtraOptions = ({
             <IndeterminateCheckbox
               id="allow_csv_upload"
               indeterminate={false}
-              checked={!!db?.extra_json?.allow_csv_upload}
-              onChange={onExtraInputChange}
+              checked={!!db?.allow_csv_upload}
+              onChange={onInputChange}
               labelText={t('Allow data upload')}
             />
             <InfoTooltip
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 49c7da0..56875ed 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -159,6 +159,7 @@ function dbReducer(
         },
       };
     case ActionType.inputChange:
+      console.log('action', action);
       if (action.payload.type === 'checkbox') {
         return {
           ...trimmedState,
@@ -287,6 +288,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
   };
 
   const onSave = async () => {
+    console.log('db', db);
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     const { id, ...update } = db || {};
     if (db?.id) {
@@ -295,6 +297,35 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
         delete update.parameters;
       }
 
+      // const extraValues = {
+      //   metadata_cache_timeout: {
+      //     schema_cache_timeout:
+      //       db?.extra_json?.metadata_cache_timeout?.schema_cache_timeout || '',
+      //     table_cache_timeout:
+      //       db?.extra_json?.metadata_cache_timeout?.table_cache_timeout || '',
+      //   },
+      //   cost_query_enabled: db?.extra_json?.cost_query_enabled || undefined,
+      //   allows_virtual_table_explore:
+      //     db?.extra_json?.allows_virtual_table_explore || undefined,
+      //   schemas_allowed_for_csv_upload:
+      //     db?.extra_json?.schemas_allowed_for_csv_upload || '',
+      //   impersonate_user: db?.extra_json?.impersonate_user || undefined,
+      //   allow_csv_upload: db?.extra_json?.allow_csv_upload || undefined,
+      //   version: db?.extra_json?.version || '',
+      //   metadata_params: db?.extra_json?.metadata_params || {},
+      //   engine_params: db?.extra_json?.engine_params || {},
+      // };
+
+      // console.log('extraValues', extraValues);
+
+      // Structure extra_json
+      // const extraValuesStructured = {
+      //   ...extraValues,
+      //   ...db?.extra_json,
+      // };
+
+      // console.log('extraValuesStructured', extraValuesStructured);
+
       // Add values back to extra field
       update.extra = JSON.stringify(
         { ...db?.extra_json, metadata_params: updateExtraMDP },