Skip to content

Commit

Permalink
Remove jquery usage to highlight sql lab menu (apache#5907)
Browse files Browse the repository at this point in the history
* Remove jquery hack

* change filter to find
  • Loading branch information
kristw authored and Grace Guo committed Sep 17, 2018
1 parent 041fe52 commit 39ef77a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions superset/assets/src/SqlLab/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}>
Expand Down

0 comments on commit 39ef77a

Please sign in to comment.