Make link highlighting great again. also prefer dashes to underscores in routes
parent
97fb7a834c
commit
4531b718a3
|
@ -158,7 +158,7 @@ export function createExploration(source, push) {
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
const explorer = parseRawExplorer(resp.data);
|
const explorer = parseRawExplorer(resp.data);
|
||||||
dispatch(loadExploration(explorer));
|
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));
|
dispatch(createExploration(source, push));
|
||||||
} else {
|
} else {
|
||||||
dispatch(loadExploration(explorer));
|
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) {
|
if (!explorerURI) {
|
||||||
const explorer = _.maxBy(explorers, (ex) => ex.updated_at);
|
const explorer = _.maxBy(explorers, (ex) => ex.updated_at);
|
||||||
dispatch(loadExploration(explorer));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ export function chooseExploration(explorerURI, source, push) {
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
const explorer = parseRawExplorer(resp.data);
|
const explorer = parseRawExplorer(resp.data);
|
||||||
dispatch(loadExploration(explorer));
|
dispatch(loadExploration(explorer));
|
||||||
push(`/sources/${source.id}/chronograf/data_explorer/${btoa(explorerURI)}`);
|
push(`/sources/${source.id}/chronograf/data-explorer/${btoa(explorerURI)}`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,14 +105,14 @@ const Root = React.createClass({
|
||||||
<Route path="accounts/:accountID" component={ClusterAccountPage} />
|
<Route path="accounts/:accountID" component={ClusterAccountPage} />
|
||||||
<Route path="databases/manager/:database" component={DatabaseManager} />
|
<Route path="databases/manager/:database" component={DatabaseManager} />
|
||||||
<Route path="databases/retentionpolicies/:database" component={RetentionPoliciesPage} />
|
<Route path="databases/retentionpolicies/:database" component={RetentionPoliciesPage} />
|
||||||
<Route path="chronograf/data_explorer" component={DataExplorer} />
|
<Route path="chronograf/data-explorer" component={DataExplorer} />
|
||||||
<Route path="chronograf/data_explorer/:base64ExplorerID" component={DataExplorer} />
|
<Route path="chronograf/data-explorer/:base64ExplorerID" component={DataExplorer} />
|
||||||
<Route path="roles" component={RolesPageContainer} />
|
<Route path="roles" component={RolesPageContainer} />
|
||||||
<Route path="roles/:roleSlug" component={RolePageContainer} />
|
<Route path="roles/:roleSlug" component={RolePageContainer} />
|
||||||
<Route path="hosts" component={HostsPage} />
|
<Route path="hosts" component={HostsPage} />
|
||||||
<Route path="hosts/:hostID" component={HostPage} />
|
<Route path="hosts/:hostID" component={HostPage} />
|
||||||
<Route path="kapacitor" component={KapacitorPage} />
|
<Route path="kapacitor-config" component={KapacitorPage} />
|
||||||
<Route path="kapacitor_tasks" component={KapacitorTasksPage} />
|
<Route path="kapacitor-tasks" component={KapacitorTasksPage} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="tasks" component={TasksPage} />
|
<Route path="tasks" component={TasksPage} />
|
||||||
<Route path="*" component={NotFound} />
|
<Route path="*" component={NotFound} />
|
||||||
|
|
|
@ -9,12 +9,11 @@ const NavListItem = React.createClass({
|
||||||
link: string.isRequired,
|
link: string.isRequired,
|
||||||
children: node,
|
children: node,
|
||||||
location: string,
|
location: string,
|
||||||
matcher: string,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {link, children, matcher, location} = this.props;
|
const {link, children, location} = this.props;
|
||||||
const isActive = matcher && !!location.match(matcher);
|
const isActive = location.startsWith(link);
|
||||||
|
|
||||||
return <Link className={cx("sidebar__menu-item", {active: isActive})} to={link}>{children}</Link>;
|
return <Link className={cx("sidebar__menu-item", {active: isActive})} to={link}>{children}</Link>;
|
||||||
},
|
},
|
||||||
|
@ -40,21 +39,20 @@ const NavBlock = React.createClass({
|
||||||
link: string,
|
link: string,
|
||||||
icon: string.isRequired,
|
icon: string.isRequired,
|
||||||
location: string,
|
location: string,
|
||||||
matcher: string,
|
|
||||||
className: string,
|
className: string,
|
||||||
wrapperClassName: string,
|
wrapperClassName: string,
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {location, matcher, className, wrapperClassName} = this.props;
|
const {location, className, wrapperClassName} = this.props;
|
||||||
const isActive = matcher && !!location.match(matcher);
|
|
||||||
|
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) => {
|
const children = React.Children.map((this.props.children), (child) => {
|
||||||
if (child && child.type === NavListItem) {
|
if (child && child.type === NavListItem) {
|
||||||
return React.cloneElement(child, {
|
return React.cloneElement(child, {location});
|
||||||
location,
|
|
||||||
isActive,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return child;
|
return child;
|
||||||
|
|
|
@ -17,28 +17,28 @@ const SideNav = React.createClass({
|
||||||
<div className="sidebar__logo">
|
<div className="sidebar__logo">
|
||||||
<a href="/"><span className="icon cubo-uniform"></span></a>
|
<a href="/"><span className="icon cubo-uniform"></span></a>
|
||||||
</div>
|
</div>
|
||||||
<NavBlock matcher="hosts" icon="cpu" link={`${sourcePrefix}/hosts`}>
|
<NavBlock icon="cpu" link={`${sourcePrefix}/hosts`}>
|
||||||
<NavHeader link={`${sourcePrefix}/hosts`} title="Infrastructure" />
|
<NavHeader link={`${sourcePrefix}/hosts`} title="Infrastructure" />
|
||||||
<NavListItem matcher="hosts" link={`${sourcePrefix}/hosts`}>Host List</NavListItem>
|
<NavListItem link={`${sourcePrefix}/hosts`}>Host List</NavListItem>
|
||||||
</NavBlock>
|
</NavBlock>
|
||||||
<NavBlock matcher="chronograf" icon="graphline" link={`${sourcePrefix}/chronograf/data_explorer`}>
|
<NavBlock icon="graphline" link={`${sourcePrefix}/chronograf/data-explorer`}>
|
||||||
<NavHeader link={`${sourcePrefix}/chronograf/data_explorer`} title={'Chronograf'} />
|
<NavHeader link={`${sourcePrefix}/chronograf/data-explorer`} title={'Chronograf'} />
|
||||||
<NavListItem matcher={'data_explorer'} link={`${sourcePrefix}/chronograf/data_explorer`}>Data Explorer</NavListItem>
|
<NavListItem link={`${sourcePrefix}/chronograf/data-explorer`}>Data Explorer</NavListItem>
|
||||||
</NavBlock>
|
</NavBlock>
|
||||||
<NavBlock matcher="overview" icon="crown" link={`${sourcePrefix}/overview`}>
|
<NavBlock icon="crown" link={`${sourcePrefix}/manage-sources`}>
|
||||||
<NavHeader link={`${sourcePrefix}/overview`} title="Sources" />
|
<NavHeader link={`${sourcePrefix}/manage-sources`} title="Sources" />
|
||||||
<NavListItem matcher="manage-sources$" link={`${sourcePrefix}/manage-sources`}>InfluxDB</NavListItem>
|
<NavListItem link={`${sourcePrefix}/manage-sources`}>InfluxDB</NavListItem>
|
||||||
<NavListItem matcher="kapacitor" link={`${sourcePrefix}/kapacitor`}>Kapacitor</NavListItem>
|
<NavListItem link={`${sourcePrefix}/kapacitor-config`}>Kapacitor</NavListItem>
|
||||||
<NavListItem matcher="queries" link={`${sourcePrefix}/queries`}>Queries</NavListItem>
|
<NavListItem link={`${sourcePrefix}/queries`}>Queries</NavListItem>
|
||||||
<NavListItem matcher="tasks" link={`${sourcePrefix}/tasks`}>Tasks</NavListItem>
|
<NavListItem link={`${sourcePrefix}/tasks`}>Tasks</NavListItem>
|
||||||
<NavListItem matcher="roles" link={`${sourcePrefix}/roles`}>Roles</NavListItem>
|
<NavListItem link={`${sourcePrefix}/roles`}>Roles</NavListItem>
|
||||||
<NavListItem matcher="accounts" link={`${sourcePrefix}/accounts`}>Cluster Accounts</NavListItem>
|
<NavListItem link={`${sourcePrefix}/accounts`}>Cluster Accounts</NavListItem>
|
||||||
<NavListItem matcher="manager" link={`${sourcePrefix}/databases/manager/_internal`}>Database Manager</NavListItem>
|
<NavListItem link={`${sourcePrefix}/databases/manager/_internal`}>Database Manager</NavListItem>
|
||||||
<NavListItem matcher="retentionpolicies" link={`${sourcePrefix}/databases/retentionpolicies/_internal`}>Retention Policies</NavListItem>
|
<NavListItem link={`${sourcePrefix}/databases/retentionpolicies/_internal`}>Retention Policies</NavListItem>
|
||||||
</NavBlock>
|
</NavBlock>
|
||||||
<NavBlock matcher="alerting" icon="cubo-uniform">
|
<NavBlock icon="cubo-uniform" link={`${sourcePrefix}/kapacitor-tasks`}>
|
||||||
<NavHeader link={`${sourcePrefix}/kapacitor_tasks`} title="Alerting" />
|
<NavHeader link={`${sourcePrefix}/kapacitor-tasks`} title="Alerting" />
|
||||||
<NavListItem matcher="kapacitor_tasks" link={`${sourcePrefix}/kapacitor_tasks`}>Kapacitor Tasks</NavListItem>
|
<NavListItem link={`${sourcePrefix}/kapacitor-tasks`}>Kapacitor Tasks</NavListItem>
|
||||||
</NavBlock>
|
</NavBlock>
|
||||||
</NavBar>
|
</NavBar>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue