mirror of
https://github.com/getredash/redash.git
synced 2026-05-14 01:00:56 -04:00
* Migrate settings-screen to React
* Use black instead of blue color for active item
* Revert "Use black instead of blue color for active item"
This reverts commit 0e4ececa6a.
* Add selectable=false to the Menu
36 lines
694 B
JavaScript
36 lines
694 B
JavaScript
import { isFunction, extend, omit, sortBy, find } from 'lodash';
|
|
|
|
class SettingsMenuItem {
|
|
constructor(menuItem) {
|
|
extend(
|
|
this,
|
|
{ pathPrefix: `/${menuItem.path}` },
|
|
omit(menuItem, ['isActive']),
|
|
);
|
|
if (isFunction(menuItem.isActive)) {
|
|
this.isActive = menuItem.isActive;
|
|
}
|
|
}
|
|
|
|
isActive(path) {
|
|
return path.startsWith(this.pathPrefix);
|
|
}
|
|
}
|
|
|
|
class SettingsMenu {
|
|
constructor() {
|
|
this.items = [];
|
|
}
|
|
|
|
add(item) {
|
|
this.items.push(new SettingsMenuItem(item));
|
|
this.items = sortBy(this.items, 'order');
|
|
}
|
|
|
|
getActiveItem(path) {
|
|
return find(this.items, item => item.isActive(path));
|
|
}
|
|
}
|
|
|
|
export default new SettingsMenu();
|