diff --git a/src/App.jsx b/src/App.jsx index ac88f3f7f6..faaba35be8 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -53,23 +53,52 @@ import Teams from './pages/Teams'; import Templates from './pages/Templates'; import Users from './pages/Users'; +const SideNavItems = ({ items, history }) => { + const currentPath = history.location.pathname.replace(/^\//, ''); + let activeGroup; + if (currentPath !== '') { + const groupPaths = items.map(({ groupName, routes }) => ({ + groupName, + paths: routes.map(({ path }) => path) + })); + [{ groupName: activeGroup }] = groupPaths + .filter(({ paths }) => paths.indexOf(currentPath) > -1); + } else { + activeGroup = 'views'; + } + + return (items.map(({ title, groupName, routes }) => ( + + {routes.map(({ path, title: itemTitle }) => ( + + {itemTitle} + + ))} + + ))); +}; + class App extends React.Component { constructor (props) { super(props); const isNavOpen = typeof window !== 'undefined' && window.innerWidth >= parseInt(breakpointMd.value, 10); this.state = { - isNavOpen, - activeGroup: 'views_group', + isNavOpen }; } - onNavSelect = result => { - this.setState({ - activeGroup: result.groupId - }); - }; - onNavToggle = () => { this.setState(({ isNavOpen }) => ({ isNavOpen: !isNavOpen })); }; @@ -98,9 +127,8 @@ class App extends React.Component { }; render () { - console.log('render'); - const { activeGroup, isNavOpen } = this.state; - const { logo, loginInfo } = this.props; + const { isNavOpen } = this.state; + const { logo, loginInfo, history } = this.props; const PageToolbar = ( @@ -146,211 +174,61 @@ class App extends React.Component { + )}