From 4531b718a3662801cb984b6bc6ffaf32671ab8ac Mon Sep 17 00:00:00 2001 From: Will Piers Date: Tue, 25 Oct 2016 15:05:42 -0700 Subject: [PATCH] Make link highlighting great again. also prefer dashes to underscores in routes --- ui/src/chronograf/actions/view/index.js | 8 +++--- ui/src/index.js | 8 +++--- ui/src/side_nav/components/NavItems.js | 18 ++++++------- ui/src/side_nav/components/SideNav.js | 36 ++++++++++++------------- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/ui/src/chronograf/actions/view/index.js b/ui/src/chronograf/actions/view/index.js index e2246d5449..0a1fc09211 100644 --- a/ui/src/chronograf/actions/view/index.js +++ b/ui/src/chronograf/actions/view/index.js @@ -158,7 +158,7 @@ export function createExploration(source, push) { }).then((resp) => { const explorer = parseRawExplorer(resp.data); dispatch(loadExploration(explorer)); - push(`/sources/${source.id}/chronograf/data_explorer/${btoa(explorer.link.href)}`); // Base64 encode explorer URI + push(`/sources/${source.id}/chronograf/data-explorer/${btoa(explorer.link.href)}`); // Base64 encode explorer URI }); }; } @@ -183,7 +183,7 @@ export function deleteExplorer(source, explorerURI, push) { dispatch(createExploration(source, push)); } else { dispatch(loadExploration(explorer)); - push(`/sources/${source.id}/chronograf/data_explorer/${btoa(explorer.id)}`); + push(`/sources/${source.id}/chronograf/data-explorer/${btoa(explorer.id)}`); } } @@ -254,7 +254,7 @@ export function fetchExplorers({source, userID, explorerURI, push}) { if (!explorerURI) { const explorer = _.maxBy(explorers, (ex) => ex.updated_at); dispatch(loadExploration(explorer)); - push(`/sources/${source.id}/chronograf/data_explorer/${btoa(explorer.link.href)}`); + push(`/sources/${source.id}/chronograf/data-explorer/${btoa(explorer.link.href)}`); return; } @@ -312,7 +312,7 @@ export function chooseExploration(explorerURI, source, push) { }).then((resp) => { const explorer = parseRawExplorer(resp.data); dispatch(loadExploration(explorer)); - push(`/sources/${source.id}/chronograf/data_explorer/${btoa(explorerURI)}`); + push(`/sources/${source.id}/chronograf/data-explorer/${btoa(explorerURI)}`); }); }; } diff --git a/ui/src/index.js b/ui/src/index.js index c2713be3e2..161e915a21 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -105,14 +105,14 @@ const Root = React.createClass({ - - + + - - + + diff --git a/ui/src/side_nav/components/NavItems.js b/ui/src/side_nav/components/NavItems.js index 75d7248f5b..9ae06794fb 100644 --- a/ui/src/side_nav/components/NavItems.js +++ b/ui/src/side_nav/components/NavItems.js @@ -9,12 +9,11 @@ const NavListItem = React.createClass({ link: string.isRequired, children: node, location: string, - matcher: string, }, render() { - const {link, children, matcher, location} = this.props; - const isActive = matcher && !!location.match(matcher); + const {link, children, location} = this.props; + const isActive = location.startsWith(link); return {children}; }, @@ -40,21 +39,20 @@ const NavBlock = React.createClass({ link: string, icon: string.isRequired, location: string, - matcher: string, className: string, wrapperClassName: string, }, render() { - const {location, matcher, className, wrapperClassName} = this.props; - const isActive = matcher && !!location.match(matcher); + const {location, className, wrapperClassName} = this.props; + + const isActive = React.Children.toArray(this.props.children).find((child) => { + return child.type === NavListItem && location.startsWith(child.props.link); + }); const children = React.Children.map((this.props.children), (child) => { if (child && child.type === NavListItem) { - return React.cloneElement(child, { - location, - isActive, - }); + return React.cloneElement(child, {location}); } return child; diff --git a/ui/src/side_nav/components/SideNav.js b/ui/src/side_nav/components/SideNav.js index a2f5e32d67..6d7d5470e2 100644 --- a/ui/src/side_nav/components/SideNav.js +++ b/ui/src/side_nav/components/SideNav.js @@ -17,28 +17,28 @@ const SideNav = React.createClass({
- + - Host List + Host List - - - Data Explorer + + + Data Explorer - - - InfluxDB - Kapacitor - Queries - Tasks - Roles - Cluster Accounts - Database Manager - Retention Policies + + + InfluxDB + Kapacitor + Queries + Tasks + Roles + Cluster Accounts + Database Manager + Retention Policies - - - Kapacitor Tasks + + + Kapacitor Tasks );