superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: Remove jquery usage to highlight sql lab menu (#5907)
Date Mon, 17 Sep 2018 18:05:27 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 39ef77a  Remove jquery usage to highlight sql lab menu (#5907)
39ef77a is described below

commit 39ef77abc5a15324387e144696d9a37068164a28
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Mon Sep 17 11:05:22 2018 -0700

    Remove jquery usage to highlight sql lab menu (#5907)
    
    * Remove jquery hack
    
    * change filter to find
---
 superset/assets/src/SqlLab/App.jsx | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/superset/assets/src/SqlLab/App.jsx b/superset/assets/src/SqlLab/App.jsx
index 01f9357..36d8ddd 100644
--- a/superset/assets/src/SqlLab/App.jsx
+++ b/superset/assets/src/SqlLab/App.jsx
@@ -3,7 +3,6 @@ import { createStore, compose, applyMiddleware } from 'redux';
 import { Provider } from 'react-redux';
 import thunkMiddleware from 'redux-thunk';
 import { hot } from 'react-hot-loader';
-import $ from 'jquery';
 
 import getInitialState from './getInitialState';
 import rootReducer from './reducers';
@@ -32,10 +31,16 @@ const store = createStore(
   ),
 );
 
-// jquery hack to highlight the navbar menu
-$('a:contains("SQL Lab")')
-  .parent()
-  .addClass('active');
+// Highlight the navbar menu
+const menus = document.querySelectorAll('.nav.navbar-nav li.dropdown');
+const sqlLabMenu = Array.prototype.slice.apply(menus)
+  .find(element => element.innerText.trim() === 'SQL Lab');
+if (sqlLabMenu) {
+  const classes = sqlLabMenu.getAttribute('class');
+  if (classes.indexOf('active') === -1) {
+    sqlLabMenu.setAttribute('class', `${classes} active`);
+  }
+}
 
 const Application = () => (
   <Provider store={store}>


Mime
View raw message