From eb3030ed0ad5aa93b99d237867480c989369930c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 18 Jun 2018 11:48:22 +0200 Subject: waaaay better nav! --- app/client/common/header.component.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'app/client/common') diff --git a/app/client/common/header.component.js b/app/client/common/header.component.js index 85e1895..11eb761 100644 --- a/app/client/common/header.component.js +++ b/app/client/common/header.component.js @@ -7,19 +7,26 @@ import * as systemActions from '../system/system.actions' import modules from '../modules' +function NavLink(props){ + if (! props.to) { + return {props.children} + } + let children = props.to === props.location.pathname ? {props.children} : props.children + return ( + {children} + ) +} + function Header(props){ - const { site, app, fps, playing, actions, location } = props + const { site, app, fps, playing, actions, location, history } = props const tool_list = Object.keys(modules).map((name, i) => { const label = name.replace(/_/, " ") return }) const tool = modules[app.tool] const links = tool.links().map((link,i) => { - let name = link.url === location.pathname ? {link.name} : link.name return ( - - {link.url ? {name} : name} - + {link.name} ) }) return ( @@ -27,12 +34,20 @@ function Header(props){ {playing && {fps} fps} {links} - { + let path = window.location.pathname.split("/") + path.shift() + console.log(path) + if (path[0] in modules && path[1]) { + history.push('/' + e.target.value + '/' + path[1] + '/') + } + actions.changeTool(e.target.value, true) + }} value={app.tool}> {tool_list} - system - dashboard + system + dashboard {site.name} cortex ) -- cgit v1.2.3-70-g09d2