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 2019/05/11 06:30:02 UTC

[incubator-superset] 01/01: add getTable extension

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

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

commit c97f58e7b8c61d89cffa4d85d516913d5d578c30
Author: hughhhh <hm...@lyft.com>
AuthorDate: Fri May 10 23:29:47 2019 -0700

    add getTable extension
---
 superset/assets/src/components/OmniContainer.jsx | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/superset/assets/src/components/OmniContainer.jsx b/superset/assets/src/components/OmniContainer.jsx
index edf33b9..50a0300 100644
--- a/superset/assets/src/components/OmniContainer.jsx
+++ b/superset/assets/src/components/OmniContainer.jsx
@@ -46,6 +46,18 @@ const getDashboards = query =>
             title: t('An error occurred while fethching Dashboards'),
         }));
 
+const getTables = query => SupersetClient.get({
+        endpoint: `/tablemodelview/api/read?_flt_2_table_name=${query}` })
+    .then(({ json }) => json.result.map(item => ({
+        title: item.table_name,
+        ...item,
+      }),
+    ))
+    .catch(() => ({
+        title: t('An error occurred while fethching Dashboards'),
+    }));
+
+
 class OmniContainer extends React.Component {
   constructor(props) {
     super(props);
@@ -84,7 +96,7 @@ class OmniContainer extends React.Component {
   render() {
       return (
         <Modal show={this.state.showOmni} style={{ marginTop: '25%' }}>
-          <Omnibar className="Omnibar" placeholder="Search all dashboards" extensions={[getDashboards]} />
+          <Omnibar className="Omnibar" placeholder="Search all dashboards" extensions={[getDashboards, getTables]} />
         </Modal>
       );
   }