mirror of
https://github.com/getredash/redash.git
synced 2026-05-09 03:03:08 -04:00
* Refine SettingsMenu service and <settings-screen> component * Rename services/settingsMenu file to match default export name * CR1
32 lines
601 B
JavaScript
32 lines
601 B
JavaScript
import { isFunction, extend, omit, sortBy } 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');
|
|
}
|
|
}
|
|
|
|
export default new SettingsMenu();
|