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
This commit is contained in:
Tim 2022-12-02 22:23:44 +08:00 committed by GitHub
parent 2a9e1e65a2
commit 4c5d14c624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 8 deletions

View File

@ -202,6 +202,7 @@ function ViewerLayout({
<div>
<Header
menuOptions={menuOptions}
isReturnEnabled={!!appConfig.showStudyList}
onClickReturnButton={onClickReturnButton}
WhiteLabeling={appConfig.whiteLabeling}
>

View File

@ -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) {

View File

@ -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 (
<div className="w-full h-full flex justify-center items-center text-white">
<div>
<h4>{message}</h4>
{showGoBackButton && (
{showGoBackButton && showStudyList && (
<h5>
<Link to={'/'}>Go back to the Study List</Link>
</h5>

View File

@ -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,