match user and users path in primary navigation

This commit is contained in:
Sebastian Sdorra
2018-07-30 09:36:44 +02:00
parent 768e1afd1a
commit f9f93b338e
2 changed files with 9 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ class PrimaryNavigation extends React.Component<Props> {
/>
<PrimaryNavigationLink
to="/users"
match="/(user|users)"
label={t("primary-navigation.users")}
/>
<PrimaryNavigationLink

View File

@@ -5,6 +5,7 @@ import { Route, Link } from "react-router-dom";
type Props = {
to: string,
label: string,
match?: string,
activeOnlyWhenExact?: boolean
};
@@ -19,9 +20,14 @@ class PrimaryNavigationLink extends React.Component<Props> {
};
render() {
const { to, activeOnlyWhenExact } = this.props;
const { to, match, activeOnlyWhenExact } = this.props;
const path = match ? match : to;
return (
<Route path={to} exact={activeOnlyWhenExact} children={this.renderLink} />
<Route
path={path}
exact={activeOnlyWhenExact}
children={this.renderLink}
/>
);
}
}