Skip to content

Commit

Permalink
refactor: update motrpac-frontend to use react-router-dom
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirsamdarshi committed Jul 1, 2024
1 parent a180b2f commit bc5680c
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 215 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"react-helmet": "^6.1.0",
"react-redux": "8.0.5",
"react-responsive": "^10.0.0",
"react-router-dom": "^5.1.2",
"react-router-dom": "^6.22.3",
"react-table": "^7.7.0",
"react-tooltip": "^5.11.2",
"react-youtube": "^10.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/AnalysisPage/analysisHomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Redirect } from 'react-router-dom';
import { Navigate } from 'react-router-dom';
import { connect } from 'react-redux';
import analysisTypes from '../lib/analysisTypes';
import AnimalDataAnalysis from './animalDataAnalysis';
Expand All @@ -27,7 +27,7 @@ export function AnalysisHomePage({
!(subjectType === 'animal' || subjectType === 'human') ||
userType === 'external'
) {
return <Redirect to="/dashboard" />;
return <Navigate to="/dashboard" />;
}

// Button to return 1 depth level
Expand Down
333 changes: 181 additions & 152 deletions src/App/App.jsx
Original file line number Diff line number Diff line change
@@ -1,171 +1,200 @@
import React from 'react';
import { Router, Route, Switch } from 'react-router-dom';
import React, { lazy, Suspense } from 'react';
import { Provider } from 'react-redux';
import configureStore from './configureStore';
import 'bootstrap';
import History from './history';
import NavbarConnected from '../Navbar/navbar';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import AuthWrapper from '../Auth/AuthWrapper';
import Footer from '../Footer/footer';
import { PageTracker } from '../GoogleAnalytics/googleAnalytics.jsx';
import LandingPageConnected from '../LandingPage/landingPage';
import LinkoutPage from '../LinkoutPage/linkoutPage';
import AnalysisHomePageConnected from '../AnalysisPage/analysisHomePage';
import MethodsConnected from '../MethodsPage/methods';
import TeamPage from '../TeamPage/teamPage';
import Contact from '../ContactPage/contact';
import ErrorPageConnected from '../ErrorPage/error';
import ReleasePageConnected from '../ReleasePage/releasePage';
import DataStatusPageConnected from '../DataStatusPage/dataStatusPage';
import DataSummaryPageConnected from '../DataSummaryPage/dataSummaryPage';
import DataAccessPageConnected from '../DataAccess/dataAccessPage';
import RelatedStudy from '../RelatedStudy/relatedStudy';
import HeritageProteomics from '../RelatedStudy/heritageProteomics';
import AnnouncementsPage from '../AnnouncementsPage/announcementsPage';
import BrowseDataPageConnected from '../BrowseDataPage/browseDataPage';
import SearchPageConnected from '../Search/searchPage';
import GeneCentricViewConnected from '../AnalysisPage/GeneCentricViewRat/geneCentricViewPage';
import GraphicalClustering from '../AnalysisPage/GraphicalClustering/graphicalClusteringPage';
import CodeRepositories from '../CodeRepoPage/codeRepoPage';
import MainStudyConnected from '../MainStudy/mainStudy';
import Tutorials from '../Tutorials/tutorials';
import Publications from '../Publications/publications';
import MultiOmicsWorkingGroups from '../MultiOmicsWorkingGroups/multiOmicsWorkingGroups';
import FullTableEnduranceTraining from '../Publications/Data/Animal/Phenotype/fullTableEnduranceTraining';
import ClinicalStudyProtocols from '../Publications/Docs/Protocol/Clinical/clinicalStudyProtocols';
import Pass1b06PhenotypeAnimalConnected from '../AnalysisPage/pass1b06PhenotypeAnimal';
import CallbackConnected from '../Auth/callback';
import { withTracker } from '../GoogleAnalytics/googleAnalytics';
import PrivateRoute from '../Auth/privateRoute';
import ScrollToTop from '../lib/scrollToTop';
import NavbarConnected from '../Navbar/navbar';
import configureStore from './configureStore';
import 'bootstrap';
import History from './history';

const LinkoutPage = lazy(() => import('../LinkoutPage/linkoutPage'));
const AnalysisHomePageConnected = lazy(
() => import('../AnalysisPage/analysisHomePage'),
);
const MethodsConnected = lazy(() => import('../MethodsPage/methods'));
const TeamPage = lazy(() => import('../TeamPage/teamPage'));
const Contact = lazy(() => import('../ContactPage/contact'));
const ErrorPageConnected = lazy(() => import('../ErrorPage/error'));
const ReleasePageConnected = lazy(() => import('../ReleasePage/releasePage'));
const DataStatusPageConnected = lazy(
() => import('../DataStatusPage/dataStatusPage'),
);
const DataSummaryPageConnected = lazy(
() => import('../DataSummaryPage/dataSummaryPage'),
);
const DataAccessPageConnected = lazy(
() => import('../DataAccess/dataAccessPage'),
);
const RelatedStudy = lazy(() => import('../RelatedStudy/relatedStudy'));
const HeritageProteomics = lazy(
() => import('../RelatedStudy/heritageProteomics'),
);
const AnnouncementsPage = lazy(
() => import('../AnnouncementsPage/announcementsPage'),
);
const BrowseDataPageConnected = lazy(
() => import('../BrowseDataPage/browseDataPage'),
);
const SearchPageConnected = lazy(() => import('../Search/searchPage'));
const GeneCentricViewConnected = lazy(
() => import('../AnalysisPage/GeneCentricViewRat/geneCentricViewPage'),
);
const GraphicalClustering = lazy(
() => import('../AnalysisPage/GraphicalClustering/graphicalClusteringPage'),
);
const CodeRepositories = lazy(() => import('../CodeRepoPage/codeRepoPage'));
const MainStudyConnected = lazy(() => import('../MainStudy/mainStudy'));
const Tutorials = lazy(() => import('../Tutorials/tutorials'));
const Publications = lazy(() => import('../Publications/publications'));
const MultiOmicsWorkingGroups = lazy(
() => import('../MultiOmicsWorkingGroups/multiOmicsWorkingGroups'),
);
const FullTableEnduranceTraining = lazy(
() =>
import('../Publications/Data/Animal/Phenotype/fullTableEnduranceTraining'),
);
const ClinicalStudyProtocols = lazy(
() => import('../Publications/Docs/Protocol/Clinical/clinicalStudyProtocols'),
);
const Pass1b06PhenotypeAnimalConnected = lazy(
() => import('../AnalysisPage/pass1b06PhenotypeAnimal'),
);
const CallbackConnected = lazy(() => import('../Auth/callback'));

const store = configureStore();

function App({ history = History }) {
return (
<Provider store={store}>
<Router history={history}>
<ScrollToTop />
<BrowserRouter history={history}>
<ScrollToTop/>
<div className="App container-fluid">
<header>
<NavbarConnected />
<NavbarConnected/>
</header>
<div className="row justify-content-center">
<Switch>
<Route
path="/callback"
component={withTracker(CallbackConnected)}
/>
<Route
path="/"
exact
component={withTracker(LandingPageConnected)}
/>
<Route
path="/external-links"
component={withTracker(LinkoutPage)}
/>
<PrivateRoute
path="/analysis/:subjectType"
component={withTracker(AnalysisHomePageConnected)}
/>
<Route
path="/methods"
component={withTracker(MethodsConnected)}
/>
<Route path="/team" component={withTracker(TeamPage)} />
<Route path="/contact" component={withTracker(Contact)} />
<Route
path="/announcements"
component={withTracker(AnnouncementsPage)}
/>
<Route
path="/error"
component={withTracker(ErrorPageConnected)}
/>
<PrivateRoute
path="/summary"
component={withTracker(DataSummaryPageConnected)}
/>
<PrivateRoute
path="/releases"
component={withTracker(ReleasePageConnected)}
/>
<PrivateRoute
path="/qc-data-monitor"
component={withTracker(DataStatusPageConnected)}
/>
<Route
path="/data-download"
exact
component={withTracker(BrowseDataPageConnected)}
/>
<Route
path="/data-download/file-browser"
exact
component={withTracker(BrowseDataPageConnected)}
/>
<Route
path="/data-access"
component={withTracker(DataAccessPageConnected)}
/>
<Route
path="/related-studies"
exact
component={withTracker(RelatedStudy)}
/>
<Route
path="/related-studies/heritage-proteomics"
exact
component={withTracker(HeritageProteomics)}
/>
<Route
path="/search"
component={withTracker(SearchPageConnected)}
/>
<Route
path="/gene-centric"
component={withTracker(GeneCentricViewConnected)}
/>
<Route
path="/graphical-clustering"
component={withTracker(GraphicalClustering)}
/>
<Route
path="/code-repositories"
component={withTracker(CodeRepositories)}
/>
<Route
path="/project-overview"
component={withTracker(MainStudyConnected)}
/>
<Route path="/tutorials" component={withTracker(Tutorials)} />
<Route
path="/publications"
exact
component={withTracker(Publications)}
/>
<Route
path="/publications/data/animal/phenotype/full-table-endurance-training"
exact
component={withTracker(FullTableEnduranceTraining)}
/>
<Route
path="/publications/docs/protocol/clinical/study-protocols"
exact
component={withTracker(ClinicalStudyProtocols)}
/>
<PrivateRoute
path="/analysis-phenotype"
component={withTracker(Pass1b06PhenotypeAnimalConnected)}
/>
<PrivateRoute
path="/multiomics-working-groups"
component={withTracker(MultiOmicsWorkingGroups)}
/>
</Switch>
<Suspense fallback={<div/>}>
<Routes>
<Route element={<PageTracker/>}>
<Route
path="/callback"
element={<CallbackConnected/>}
/>
<Route
path="/"
exact
element={<LandingPageConnected/>}
/>
<Route
path="/external-links"
element={<LinkoutPage/>}
/>
<Route
path="/methods"
element={<MethodsConnected/>}
/>
<Route path="/team" element={<TeamPage/>}/>
<Route path="/contact" element={<Contact/>}/>
<Route
path="/announcements"
element={<AnnouncementsPage/>}
/>
<Route path="/error" element={<ErrorPageConnected/>}/>
<Route element={<AuthWrapper/>}>
<Route
path="/analysis/:subjectType"
element={<AnalysisHomePageConnected/>}
/>
<Route
path="/summary"
element={<DataSummaryPageConnected/>}
/>
<Route
path="/releases"
element={<ReleasePageConnected/>}
/>
<Route
path="/qc-data-monitor"
element={<DataStatusPageConnected/>}
/>
<Route
path="/publications/docs/protocol/clinical/study-protocols"
exact
element={<ClinicalStudyProtocols/>}
/>
<Route
path="/analysis-phenotype"
element={<Pass1b06PhenotypeAnimalConnected/>}
/>
<Route
path="/multiomics-working-groups"
element={<MultiOmicsWorkingGroups/>}
/>
</Route>
<Route
path="/data-download"
element={<BrowseDataPageConnected/>}
/>
<Route
path="/data-download/file-browser"
element={<BrowseDataPageConnected/>}
/>
<Route
path="/data-access"
element={<DataAccessPageConnected/>}
/>
<Route
path="/related-studies"
exact
element={<RelatedStudy/>}
/>
<Route
path="/related-studies/heritage-proteomics"
exact
element={<HeritageProteomics/>}
/>
<Route
path="/search"
element={<SearchPageConnected/>}
/>
<Route
path="/gene-centric"
element={<GeneCentricViewConnected/>}
/>
<Route
path="/graphical-clustering"
element={<GraphicalClustering/>}
/>
<Route
path="/code-repositories"
element={<CodeRepositories/>}
/>
<Route
path="/project-overview"
element={<MainStudyConnected/>}
/>
<Route path="/tutorials" element={<Tutorials/>}/>
<Route
path="/publications"
exact
element={<Publications/>}
/>
<Route
path="/publications/data/animal/phenotype/full-table-endurance-training"
exact
element={<FullTableEnduranceTraining/>}
/>
</Route>
</Routes>
</Suspense>
</div>
</div>
</Router>
<Footer />
</BrowserRouter>
<Footer/>
</Provider>
);
}
Expand Down
Loading

0 comments on commit bc5680c

Please sign in to comment.