From 4c5d14c624fce85f2149e2a170b5f48007b815f1 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 2 Dec 2022 22:23:44 +0800 Subject: [PATCH] fix: Add support for showStudyList configuration setting (#3009) I followed suit with how it was implemented in the v2 branch, on the 404 page I just hit the link back to the study list if we're not configured to display it. See PR #2131 --- extensions/default/src/ViewerLayout/index.tsx | 1 + platform/viewer/src/App.tsx | 9 ++++++++- platform/viewer/src/routes/NotFound/NotFound.tsx | 7 ++++++- platform/viewer/src/routes/index.tsx | 14 ++++++++------ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/extensions/default/src/ViewerLayout/index.tsx b/extensions/default/src/ViewerLayout/index.tsx index 3211dd350..422bcc8e8 100644 --- a/extensions/default/src/ViewerLayout/index.tsx +++ b/extensions/default/src/ViewerLayout/index.tsx @@ -202,6 +202,7 @@ function ViewerLayout({
diff --git a/platform/viewer/src/App.tsx b/platform/viewer/src/App.tsx index bf8b359e3..4da997d39 100644 --- a/platform/viewer/src/App.tsx +++ b/platform/viewer/src/App.tsx @@ -50,7 +50,13 @@ function App({ config, defaultExtensions, defaultModes }) { // Set appConfig const appConfigState = init.appConfig; - const { routerBasename, modes, dataSources, oidc } = appConfigState; + const { + routerBasename, + modes, + dataSources, + oidc, + showStudyList, + } = appConfigState; const { UIDialogService, @@ -92,6 +98,7 @@ function App({ config, defaultExtensions, defaultModes }) { commandsManager, hotkeysManager, routerBasename, + showStudyList, }); if (oidc) { diff --git a/platform/viewer/src/routes/NotFound/NotFound.tsx b/platform/viewer/src/routes/NotFound/NotFound.tsx index 723b362ab..7c668d0e0 100644 --- a/platform/viewer/src/routes/NotFound/NotFound.tsx +++ b/platform/viewer/src/routes/NotFound/NotFound.tsx @@ -2,15 +2,20 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; +import { useAppConfig } from '@state'; + const NotFound = ({ message = 'Sorry, this page does not exist.', showGoBackButton = true, }) => { + const [appConfig] = useAppConfig(); + const { showStudyList } = appConfig; + return (

{message}

- {showGoBackButton && ( + {showGoBackButton && showStudyList && (
Go back to the Study List
diff --git a/platform/viewer/src/routes/index.tsx b/platform/viewer/src/routes/index.tsx index 5c44ab832..8b0cf0484 100644 --- a/platform/viewer/src/routes/index.tsx +++ b/platform/viewer/src/routes/index.tsx @@ -13,12 +13,6 @@ import PrivateRoute from './PrivateRoute'; // TODO: Include "routes" debug route if dev build const bakedInRoutes = [ // WORK LIST - { - path: '/', - children: DataSourceWrapper, - private: true, - props: { children: WorkList }, - }, { path: '/local', children: Local, @@ -27,6 +21,12 @@ const bakedInRoutes = [ // NOT FOUND (404) const notFoundRoute = { component: NotFound }; +const WorkListRoute = { + path: '/', + children: DataSourceWrapper, + private: true, + props: { children: WorkList }, +}; const createRoutes = ({ modes, @@ -36,6 +36,7 @@ const createRoutes = ({ commandsManager, hotkeysManager, routerBasename, + showStudyList, }) => { const routes = buildModeRoutes({ @@ -54,6 +55,7 @@ const createRoutes = ({ ); const allRoutes = [ ...routes, + ...(showStudyList ? [WorkListRoute] : []), ...(customRoutes?.routes || []), ...bakedInRoutes, customRoutes?.notFoundRoute || notFoundRoute,