mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 22:19:28 -02:30
Start with nav expanded
This commit is contained in:
@@ -7,10 +7,12 @@ class NavExpandableGroup extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
const { routes } = this.props;
|
const { routes } = this.props;
|
||||||
|
this.state = { isExpanded: true };
|
||||||
|
|
||||||
// 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.handleExpand = this.handleExpand.bind(this);
|
||||||
this.isActiveGroup = this.isActiveGroup.bind(this);
|
this.isActiveGroup = this.isActiveGroup.bind(this);
|
||||||
this.isActivePath = this.isActivePath.bind(this);
|
this.isActivePath = this.isActivePath.bind(this);
|
||||||
}
|
}
|
||||||
@@ -24,8 +26,13 @@ class NavExpandableGroup extends Component {
|
|||||||
return Boolean(matchPath(history.location.pathname, { path }));
|
return Boolean(matchPath(history.location.pathname, { path }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleExpand(e, isExpanded) {
|
||||||
|
this.setState({ isExpanded });
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { groupId, groupTitle, routes } = this.props;
|
const { groupId, groupTitle, routes } = this.props;
|
||||||
|
const { isExpanded } = this.state;
|
||||||
|
|
||||||
if (routes.length === 1) {
|
if (routes.length === 1) {
|
||||||
const [{ path }] = routes;
|
const [{ path }] = routes;
|
||||||
@@ -39,8 +46,10 @@ class NavExpandableGroup extends Component {
|
|||||||
return (
|
return (
|
||||||
<NavExpandable
|
<NavExpandable
|
||||||
isActive={this.isActiveGroup()}
|
isActive={this.isActiveGroup()}
|
||||||
|
isExpanded={isExpanded}
|
||||||
groupId={groupId}
|
groupId={groupId}
|
||||||
title={groupTitle}
|
title={groupTitle}
|
||||||
|
onExpand={this.handleExpand}
|
||||||
>
|
>
|
||||||
{routes.map(({ path, title }) => (
|
{routes.map(({ path, title }) => (
|
||||||
<NavItem
|
<NavItem
|
||||||
|
|||||||
Reference in New Issue
Block a user