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

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

commit aa65132165a78a7faa0310a057778ae651b90c99
Author: hughhhh <[email protected]>
AuthorDate: Thu Jul 15 10:52:02 2021 -0700

    working form
---
 .../DatabaseModal/DatabaseConnectionForm.tsx       |  9 ++++--
 .../CRUD/data/database/DatabaseModal/index.tsx     | 34 ++--------------------
 .../src/views/CRUD/data/database/types.ts          |  2 +-
 3 files changed, 9 insertions(+), 36 deletions(-)

diff --git 
a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
 
b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
index fa2fe87..24eb8e6 100644
--- 
a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
+++ 
b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
@@ -219,7 +219,10 @@ const TableCatalog = ({
             <Input
               name="table-catalog-name-1"
               placeholder="Enter create a name for this sheet"
-              onChange={changeMethods.onParametersChange}
+              onChange={e => {
+                console.log(e.target.value);
+                setTableCatalog([{ name: `table-catalog-${e.target.value}` }]);
+              }}
             />
             {/* <CloseOutlined
               onClick={() => {
@@ -233,14 +236,14 @@ const TableCatalog = ({
               }}
             /> */}
             <ValidatedInput
-              name="table-catalog-value-1"
+              name={sheet.name}
               type="gsheet"
               required={required}
               validationMethods={{ onBlur: getValidation }}
               errorMessage={validationErrors?.table_catalog}
               placeholder="Paste the shareable Google Sheet URL here"
               onChange={changeMethods.onParametersChange}
-              onPaste={(e) => {
+              onPaste={e => {
                 changeMethods.onParametersChange({
                   target: {
                     name: 'table-catalog-value-1',
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 358f731..7ebb285 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -228,45 +228,15 @@ function dbReducer(
         [action.payload.name]: action.payload.value,
       };
     case ActionType.parametersChange:
-      const data = {};
       if (action.payload.name.startsWith('table-catalog')) {
-        // Reformatting gsheets components for validation
-        console.log('state', state);
-        console.log('action', action);
-
-        // Go through key can pull out names
-        if (trimmedState.parameters?.table_catalog) {
-          console.log(
-            'table_catalog',
-            Object.keys(trimmedState.parameters?.table_catalog),
-          );
-          Object.keys(trimmedState.parameters?.table_catalog).map(k => {
-            if (k.startsWith('table-catalog-name')) {
-              console.log(k);
-              console.log(k.split('-').pop());
-              console.log(
-                trimmedState.parameters?.table_catalog[
-                  `table-catalog-value-${k.split('-').pop()}`
-                ],
-              );
-              data[trimmedState.parameters?.table_catalog[k]] =
-                trimmedState.parameters?.table_catalog[
-                  `table-catalog-value-${k.split('-').pop()}`
-                ];
-            }
-          });
-        }
-
-        console.log('data', data);
-
-        // match key with values
+        // formatting wrapping google sheets table catalog
         return {
           ...trimmedState,
           parameters: {
             ...trimmedState.parameters,
             table_catalog: {
               ...trimmedState.parameters?.table_catalog,
-              [action.payload.name]: action.payload.value,
+              [action.payload.name.substring(14)]: action.payload.value, // 
removing table-catalog from key
             },
           },
         };
diff --git a/superset-frontend/src/views/CRUD/data/database/types.ts 
b/superset-frontend/src/views/CRUD/data/database/types.ts
index 031e49d..33c8010 100644
--- a/superset-frontend/src/views/CRUD/data/database/types.ts
+++ b/superset-frontend/src/views/CRUD/data/database/types.ts
@@ -40,7 +40,7 @@ export type DatabaseObject = {
     encryption?: boolean;
     credentials_info?: string;
     query?: string | object;
-    table_catalog?: Record<string, string>;
+    table_catalog?: object;
   };
   configuration_method: CONFIGURATION_METHOD;
   engine?: string;

Reply via email to