graceguo-supercat closed pull request #5907: Remove jquery usage to highlight
sql lab menu
URL: https://github.com/apache/incubator-superset/pull/5907
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/assets/src/SqlLab/App.jsx
b/superset/assets/src/SqlLab/App.jsx
index 01f93578d0..36d8ddd1f9 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}>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]