Skip to content

Commit

Permalink
Merge pull request #167 from kbss-cvut/statistics-navbar
Browse files Browse the repository at this point in the history
Added ava-analytics link to navbar
  • Loading branch information
LaChope committed May 23, 2024
2 parents a2c2bcd + 692258a commit c05f286
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/components/MainView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { isAdmin } from "../utils/SecurityUtils";
import Messages from "./message/Messages";
import Footer from "../Footer";
import PropTypes from "prop-types";
import { ANALYTICS_URL } from "../../config/index.js";

class MainView extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -61,6 +62,26 @@ class MainView extends React.Component {
}
}

_renderStatisticsNavLink(path) {
return (
<>
{ANALYTICS_URL === "" ? (
<NavLink
className="nav-link"
isActive={() => path.startsWith(Routes.statistics.path)}
to={Routes.statistics.path}
>
{this.i18n("statistics.panel-title")}
</NavLink>
) : (
<Nav.Link className="nav-link" href={ANALYTICS_URL}>
{this.i18n("statistics.panel-title")}
</Nav.Link>
)}
</>
);
}

render() {
if (this.props.status === ACTION_STATUS.PENDING) {
return <LoaderMask />;
Expand Down Expand Up @@ -120,15 +141,7 @@ class MainView extends React.Component {
</NavItem>
</IfGranted>
<IfGranted expected={ROLE.ADMIN} actual={user.role}>
<NavItem>
<NavLink
className="nav-link"
isActive={() => path.startsWith(Routes.statistics.path)}
to={Routes.statistics.path}
>
{this.i18n("statistics.panel-title")}
</NavLink>
</NavItem>
<NavItem>{this._renderStatisticsNavLink(path)}</NavItem>
</IfGranted>
<IfGranted expected={ROLE.ADMIN} actual={user.role}>
<NavItem>
Expand Down

0 comments on commit c05f286

Please sign in to comment.