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

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

commit 07a3f03f29bbd4f643f1ff2de47521746e91375a
Author: hughhhh <[email protected]>
AuthorDate: Thu Nov 19 19:52:36 2020 -0800

    update tableview with dataset endpoint
---
 .../src/datasource/ChangeDatasourceModal.tsx       | 83 +++++++++++++++-------
 1 file changed, 56 insertions(+), 27 deletions(-)

diff --git a/superset-frontend/src/datasource/ChangeDatasourceModal.tsx 
b/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
index 4f1597b..70486be 100644
--- a/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
+++ b/superset-frontend/src/datasource/ChangeDatasourceModal.tsx
@@ -68,7 +68,7 @@ const ChangeDatasourceModal: 
FunctionComponent<ChangeDatasourceModalProps> = ({
   useEffect(() => {
     const selectDatasource = (datasource: any) => {
       SupersetClient.get({
-        endpoint: `/datasource/get/${datasource.type}/${datasource.id}`,
+        endpoint: `/datasource/get/${datasource.kind}/${datasource.id}`,
       })
         .then(({ json }) => {
           onDatasourceSave(json);
@@ -92,34 +92,63 @@ const ChangeDatasourceModal: 
FunctionComponent<ChangeDatasourceModalProps> = ({
         searchRef.current.focus();
       }
       if (!datasources) {
+
         SupersetClient.get({
-          endpoint: '/superset/datasources/',
-        })
-          .then(({ json }) => {
-            const data = json.map((ds: any) => ({
-              rawName: ds.name,
-              connection: ds.connection,
-              schema: ds.schema,
-              name: (
-                <a
-                  href="#"
-                  onClick={() => selectDatasource(ds)}
-                  className="datasource-link"
-                >
-                  {ds.name}
-                </a>
-              ),
-              type: ds.type,
-            }));
-            setLoading(false);
-            setDatasources(data);
-          })
-          .catch(response => {
-            setLoading(false);
-            getClientErrorObject(response).then(({ error }: any) => {
-              addDangerToast(error.error || error.statusText || error);
-            });
+          endpoint: '/api/v1/dataset/',
+        }).then(({ json }) => {
+          console.log(json);
+          const data = json.result.map((ds: any) => ({
+            rawName: ds.table_name,
+            connection: ds.database.database_name,
+            schema: ds.schema,
+            name: (
+              <a
+                href="#"
+                onClick={() => selectDatasource(ds)}
+                className="datasource-link"
+              >
+                {ds.table_name}
+              </a>
+            ),
+            type: ds.kind,
+          }));
+          setLoading(false);
+          setDatasources(data);
+        }).catch(response => {
+          setLoading(false);
+          getClientErrorObject(response).then(({ error }: any) => {
+            addDangerToast(error.error || error.statusText || error);
           });
+        });
+
+        // SupersetClient.get({
+        //   endpoint: '/superset/datasources/',
+        // })
+        //   .then(({ json }) => {
+        //     const data = json.map((ds: any) => ({
+        //       rawName: ds.name,
+        //       connection: ds.connection,
+        //       schema: ds.schema,
+        //       name: (
+        //         <a
+        //           href="#"
+        //           onClick={() => selectDatasource(ds)}
+        //           className="datasource-link"
+        //         >
+        //           {ds.name}
+        //         </a>
+        //       ),
+        //       type: ds.type,
+        //     }));
+        //     setLoading(false);
+        //     setDatasources(data);
+        //   })
+        //   .catch(response => {
+        //     setLoading(false);
+        //     getClientErrorObject(response).then(({ error }: any) => {
+        //       addDangerToast(error.error || error.statusText || error);
+        //     });
+        //   });
       }
     };
 

Reply via email to