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 authored and GitHub committed 2022-12-02 09:23:44 -05:00
1 parent 2a9e1e65a2
commit 4c5d14c624
4 files changed
+23 -8

No files matched your search

+8 -1
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) {
@@ -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>
+8 -6
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,