From 9a090ca50429928fcba11bec506334b8d10e5eab Mon Sep 17 00:00:00 2001 From: shellyear Date: Thu, 16 May 2024 14:46:19 +0200 Subject: [PATCH] [feature] use internal router tool to handle routing to the statistics page --- src/components/MainView.jsx | 19 ++++++++++++------- src/utils/Routes.jsx | 2 -- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/MainView.jsx b/src/components/MainView.jsx index 5cb6bee..539c5c1 100644 --- a/src/components/MainView.jsx +++ b/src/components/MainView.jsx @@ -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) { @@ -61,6 +62,14 @@ class MainView extends React.Component { } } + showStatistics = () => { + if (ANALYTICS_URL === "") { + transitionTo(routes.statistics); + } else { + window.location.href = ANALYTICS_URL; + } + }; + render() { if (this.props.status === ACTION_STATUS.PENDING) { return ; @@ -120,14 +129,10 @@ class MainView extends React.Component { - - path.startsWith(Routes.statistics.path)} - to={Routes.statistics.path} - > + +
this.showStatistics()}> {this.i18n("statistics.panel-title")} - +
diff --git a/src/utils/Routes.jsx b/src/utils/Routes.jsx index 0cdd247..c868477 100644 --- a/src/utils/Routes.jsx +++ b/src/utils/Routes.jsx @@ -10,7 +10,6 @@ import requireAuth from "../components/misc/hoc/RequireAuth"; import UsersController from "../components/user/UsersController"; import UserController from "../components/user/UserController"; import PasswordChangeController from "../components/user/PasswordChangeController"; -import Statistics from "../components/statistics/Statistics"; import InstitutionsController from "../components/institution/InstitutionsController"; import InstitutionController from "../components/institution/InstitutionController"; import RecordsController from "../components/record/RecordsController"; @@ -35,7 +34,6 @@ export const authRoutes = ( -