mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 13:25:02 -02:30
use constructor bound methods for nav group
This commit is contained in:
@@ -14,15 +14,20 @@ class NavExpandableGroup extends Component {
|
|||||||
// Extract a list of paths from the route params and store them for later. This creates
|
// Extract a list of paths from the route params and store them for later. This creates
|
||||||
// an array of url paths associated with any NavItem component rendered by this component.
|
// an array of url paths associated with any NavItem component rendered by this component.
|
||||||
this.navItemPaths = routes.map(({ path }) => path);
|
this.navItemPaths = routes.map(({ path }) => path);
|
||||||
|
|
||||||
|
this.isActiveGroup = this.isActiveGroup.bind(this);
|
||||||
|
this.isActivePath = this.isActivePath.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
isActiveGroup = () => this.navItemPaths.some(this.isActivePath);
|
isActiveGroup () {
|
||||||
|
return this.navItemPaths.some(this.isActivePath);
|
||||||
|
}
|
||||||
|
|
||||||
isActivePath = (path) => {
|
isActivePath (path) {
|
||||||
const { history } = this.props;
|
const { history } = this.props;
|
||||||
|
|
||||||
return history.location.pathname.startsWith(path);
|
return history.location.pathname.startsWith(path);
|
||||||
};
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { groupId, groupTitle, routes } = this.props;
|
const { groupId, groupTitle, routes } = this.props;
|
||||||
|
|||||||
Reference in New Issue
Block a user