diff --git a/js/components/header.js b/js/components/header.js index dcf3c475..0ae18751 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -110,7 +110,7 @@ let Header = React.createClass({ {getLangText('Log out')} ); - navRoutesLinks = ; + navRoutesLinks = ; } else { account = {getLangText('LOGIN')}; diff --git a/js/components/nav_routes_links.js b/js/components/nav_routes_links.js index 9a266ba8..cb950a95 100644 --- a/js/components/nav_routes_links.js +++ b/js/components/nav_routes_links.js @@ -3,53 +3,63 @@ import React from 'react'; import Nav from 'react-bootstrap/lib/Nav'; -import DropdownButton from 'react-bootstrap/lib/DropdownButton'; -import MenuItemLink from 'react-router-bootstrap/lib/MenuItemLink'; -import NavItemLink from 'react-router-bootstrap/lib/NavItemLink'; + +import NavRoutesLinksLink from './nav_routes_links_link'; + +import AclProxy from './acl_proxy'; import { sanitizeList } from '../utils/general_utils'; let NavRoutesLinks = React.createClass({ propTypes: { - routes: React.PropTypes.element + routes: React.PropTypes.element, + userAcl: React.PropTypes.object }, - extractLinksFromRoutes(node, i) { + extractLinksFromRoutes(node, userAcl, i) { if(!node) { return; } - node = node.props; + let links = node.props.children.map((child, j) => { - let links = node.children.map((child, j) => { + let childrenFn = null; - // check if this a candidate for a link generation - if(child.props.headerTitle && typeof child.props.headerTitle === 'string') { + if(child.props.children && child.props.children.length > 0) { + childrenFn = this.extractLinksFromRoutes(child, userAcl, i++); + } - // also check if it is a candidate for generating a dropdown menu - if(child.props.children && child.props.children.length > 0) { + let { aclName, headerTitle, name, children } = child.props; + if(headerTitle && typeof headerTitle === 'string') { + + if(aclName && typeof aclName !== 'undefined') { return ( - - {this.extractLinksFromRoutes(child, i++)} - - ); - } else if(i === 1) { - // if the node's child is actually a node of level one (a child of a node), we're - // returning a DropdownButton matching MenuItemLink - return ( - {child.props.headerTitle} - ); - } else if(i === 0) { - return ( - {child.props.headerTitle} + + + ); } else { - return null; + return ( + + ); } } else { return null; } + }); // remove all nulls from the list of generated links @@ -57,9 +67,11 @@ let NavRoutesLinks = React.createClass({ }, render() { + let {routes, userAcl} = this.props; + return ( ); } diff --git a/js/components/nav_routes_links_link.js b/js/components/nav_routes_links_link.js new file mode 100644 index 00000000..0e9fa912 --- /dev/null +++ b/js/components/nav_routes_links_link.js @@ -0,0 +1,49 @@ +'use strict'; + +import React from 'react'; + +import DropdownButton from 'react-bootstrap/lib/DropdownButton'; +import MenuItemLink from 'react-router-bootstrap/lib/MenuItemLink'; +import NavItemLink from 'react-router-bootstrap/lib/NavItemLink'; + +let NavRoutesLinksLink = React.createClass({ + propTypes: { + headerTitle: React.PropTypes.string, + routeName: React.PropTypes.string, + + children: React.PropTypes.oneOfType([ + React.PropTypes.arrayOf(React.PropTypes.element), + React.PropTypes.element + ]), + + depth: React.PropTypes.number + }, + + render() { + let { children, headerTitle, depth, routeName } = this.props; + + if(children) { + return ( + + {children} + + ); + } else { + if(depth === 1) { + // if the node's child is actually a node of level one (a child of a node), we're + // returning a DropdownButton matching MenuItemLink + return ( + {headerTitle} + ); + } else if(depth === 0) { + return ( + {headerTitle} + ); + } else { + return null; + } + } + } +}); + +export default NavRoutesLinksLink; \ No newline at end of file diff --git a/js/components/whitelabel/wallet/wallet_routes.js b/js/components/whitelabel/wallet/wallet_routes.js index 1c4ef4a7..f6723a55 100644 --- a/js/components/whitelabel/wallet/wallet_routes.js +++ b/js/components/whitelabel/wallet/wallet_routes.js @@ -71,7 +71,7 @@ let ROUTES = { - +