mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 01:00:14 -04:00
* Prettier all the JS files * Add GitHub Action to autoformat code pushed to master * Fix eslint violation due to formatting. * Remove GitHub actions for styling * Add restyled.io config
32 lines
669 B
JavaScript
32 lines
669 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();
|