import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { Link } from 'react-router-dom'; import { connect } from 'react-redux' 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, history, i18n } = 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) => { return ( {i18n.header[link.name] || link.name} ) }) const site_title = i18n.header.site_name || (site.name + " cortex") document.querySelector('title').innerHTML = site_title document.body.parentNode.setAttribute('lang', i18n.language) document.body.setAttribute('section', location.pathname.replace(/[0-9]/g, '').replace(/\//g, '_').replace(/^_/, '').replace(/_$/, '')) return (
{site_title} {i18n.header.system} {i18n.header.dashboard} {links} {playing && {fps} fps}
) } const mapStateToProps = state => ({ site: state.system.site, app: state.system.app, fps: state.live.fps, playing: state.live.playing, i18n: state.system.i18n.strings, }) const mapDispatchToProps = (dispatch, ownProps) => ({ actions: bindActionCreators(systemActions, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(Header)