superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccwilli...@apache.org
Subject [incubator-superset] 03/03: [superset-client][datasource editor] remove unused funcs in DatasourceControl
Date Wed, 17 Oct 2018 20:23:44 GMT
This is an automated email from the ASF dual-hosted git repository.

ccwilliams pushed a commit to branch chris--ajax-datasource-editor
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 43aa59c9e5beda25077ab5c8f4fdc9bea661a94a
Author: Chris Williams <chris.williams@airbnb.com>
AuthorDate: Wed Oct 17 13:23:28 2018 -0700

    [superset-client][datasource editor] remove unused funcs in DatasourceControl
---
 .../assets/src/datasource/DatasourceEditor.jsx     |  1 -
 superset/assets/src/datasource/DatasourceModal.jsx |  1 -
 .../components/controls/DatasourceControl.jsx      | 52 +++-------------------
 3 files changed, 5 insertions(+), 49 deletions(-)

diff --git a/superset/assets/src/datasource/DatasourceEditor.jsx b/superset/assets/src/datasource/DatasourceEditor.jsx
index 86289a3..7731365 100644
--- a/superset/assets/src/datasource/DatasourceEditor.jsx
+++ b/superset/assets/src/datasource/DatasourceEditor.jsx
@@ -269,7 +269,6 @@ export class DatasourceEditor extends React.PureComponent {
       this.props.addSuccessToast(t('Metadata has been synced'));
       this.setState(() => ({ metadataLoading: false }));
     }).catch((error) => {
-      // @TODO replace this with a util function to read body and pull error
       const msg = error.error || error.statusText || t('An error has occurred');
       this.props.addDangerToast(msg);
       this.setState(() => ({ metadataLoading: false }));
diff --git a/superset/assets/src/datasource/DatasourceModal.jsx b/superset/assets/src/datasource/DatasourceModal.jsx
index b895f25..0d4d8e2 100644
--- a/superset/assets/src/datasource/DatasourceModal.jsx
+++ b/superset/assets/src/datasource/DatasourceModal.jsx
@@ -73,7 +73,6 @@ class DatasourceModal extends React.PureComponent {
           actions: [
             Dialog.DefaultAction('Ok', () => {}, 'btn-danger'),
           ],
-          // @TODO replace this with a util function to read body and pull error
           body: error.error || error.statusText || t('An error has occurred'),
         });
       });
diff --git a/superset/assets/src/explore/components/controls/DatasourceControl.jsx b/superset/assets/src/explore/components/controls/DatasourceControl.jsx
index fcecdaf..bf2409f 100644
--- a/superset/assets/src/explore/components/controls/DatasourceControl.jsx
+++ b/superset/assets/src/explore/components/controls/DatasourceControl.jsx
@@ -43,8 +43,6 @@ class DatasourceControl extends React.PureComponent {
     };
     this.toggleShowDatasource = this.toggleShowDatasource.bind(this);
     this.toggleEditDatasourceModal = this.toggleEditDatasourceModal.bind(this);
-    this.setSearchRef = this.setSearchRef.bind(this);
-    this.selectDatasource = this.selectDatasource.bind(this);
   }
 
   onChange(vizType) {
@@ -52,57 +50,17 @@ class DatasourceControl extends React.PureComponent {
     this.setState(() => ({ showModal: false }));
   }
 
-  onEnterModal() {
-    if (this.searchRef) {
-      this.searchRef.focus();
-    }
-    if (!this.state.datasources) {
-      SupersetClient.get({ endpoint: '/superset/datasources/' })
-        .then(({ json }) => {
-          const datasources = json.map(ds => ({
-            rawName: ds.name,
-            connection: ds.connection,
-            schema: ds.schema,
-             name: (
-               <a
-                 href="#"
-                 onClick={this.selectDatasource.bind(this, ds.uid)}
-                 className="datasource-link"
-               >
-                 {ds.name}
-               </a>
-             ),
-            type: ds.type,
-          }));
-
-          this.setState(() => ({ loading: false, datasources }));
-        })
-        .catch(() => {
-          this.setState(() => ({ loading: false }));
-          this.props.addDangerToast(t('Something went wrong while fetching the datasource
list'));
-        });
-    }
-  }
-
-  setSearchRef(searchRef) {
-    this.searchRef = searchRef;
-  }
-
   toggleShowDatasource() {
-    this.setState({ showDatasource: !this.state.showDatasource });
+    this.setState(({ showDatasource }) => ({ showDatasource: !showDatasource }));
   }
 
   toggleModal() {
-    this.setState({ showModal: !this.state.showModal });
-  }
-
-  selectDatasource(datasourceId) {
-    this.setState({ showModal: false });
-    this.props.onChange(datasourceId);
+    this.setState(({ showModal }) => ({ showModal: !showModal }));
   }
-
   toggleEditDatasourceModal() {
-    this.setState({ showEditDatasourceModal: !this.state.showEditDatasourceModal });
+    this.setState(({ showEditDatasourceModal }) => ({
+      showEditDatasourceModal: !showEditDatasourceModal,
+    }));
   }
 
   renderDatasource() {


Mime
View raw message