diff --git a/embark-ui/src/components/Layout.js b/embark-ui/src/components/Layout.js index d5b8ea928..3e17e69db 100644 --- a/embark-ui/src/components/Layout.js +++ b/embark-ui/src/components/Layout.js @@ -1,6 +1,7 @@ import React from 'react'; +import {Link} from 'react-router-dom'; import PropTypes from 'prop-types'; -import { DropdownItem, DropdownMenu, DropdownToggle, Nav, NavItem, NavLink, Container } from 'reactstrap'; +import {DropdownItem, DropdownMenu, DropdownToggle, Nav, NavItem, NavLink, Container} from 'reactstrap'; import {LIGHT_THEME, DARK_THEME} from '../constants'; import FontAwesome from 'react-fontawesome'; @@ -23,99 +24,120 @@ import SearchBar from './SearchBar'; import logo from '../images/logo-new.svg'; -const sidebarNavItems = {items: [ - {name: "Dashboard", url: "/embark", icon: 'fa fa-tachometer'}, - {name: "Deployment", url: "/embark/deployment", icon: "fa fa-arrow-up"}, - {name: "Contracts", url: "/embark/contracts", icon: "fa fa-file-text"}, - {name: "Explorer", url: "/embark/explorer", icon: "fa fa-compass", children: [ +const HEADER_NAV_ITEMS = [ + {name: "Dashboard", to: "/embark", icon: 'tachometer'}, + {name: "Deployment", to: "/embark/deployment", icon: "arrow-up"}, + {name: "Contracts", to: "/embark/contracts", icon: "file-text"}, + {name: "Explorer", to: "/embark/explorer/overview", icon: "compass"}, + {name: "Editor", to: "/embark/editor", icon: "codepen"}, + {name: "Utils", to: "/embark/utilities/converter", icon: "cog"} +]; + +const SIDEBAR_NAV_ITEMS = { + "/embark/explorer" : {items: [ {url: "/embark/explorer/overview", icon: "fa fa-signal", name: "Overview"}, {url: "/embark/explorer/accounts", icon: "fa fa-users", name: "Accounts"}, {url: "/embark/explorer/blocks", icon: "fa fa-stop", name: "Blocks"}, {url: "/embark/explorer/transactions", icon: "fa fa-tree", name: "Transactions"} ]}, - {name: "Editor", url: "/embark/editor", icon: "fa fa-codepen"}, - {name: "Documentation", url: "/embark/documentation", icon: "fa fa-book"}, - {name: "Utils", url: "/embark/utilities/converter", icon: "fa fa-cog", children: [ + "/embark/utilities/": {items: [ {url: "/embark/utilities/converter", icon: "fa fa-plug", name: "Converter"}, {url: "/embark/utilities/communication", icon: "fa fa-phone", name: "Communication"}, {url: "/embark/utilities/ens", icon: "fa fa-circle", name: "ENS"}, {url: "/embark/utilities/sign-and-verify", icon: "fa fa-edit", name: "Sign & Verify"}, {url: "/embark/utilities/transaction-decoder", icon: "fa fa-edit", name: "Transaction Decoder"} ]} -]}; +}; + +const removeCssClasses = () => { + document.body.classList.remove('sidebar-fixed'); + document.body.classList.remove('sidebar-lg-show'); +} + +const getSidebar = (location) => { + const currentItem = Object.keys(SIDEBAR_NAV_ITEMS).find(path => location.pathname.startsWith(path)); + return currentItem && SIDEBAR_NAV_ITEMS[currentItem]; +} function searchTheExplorer(value) { // TODO: search } -const Layout = ({children, logout, credentials, location, toggleTheme, currentTheme}) => ( -