Skip to content

Commit

Permalink
fix: showStudyList config (#1647)
Browse files Browse the repository at this point in the history
* fix: `showStudyList` config

* showStudyList should default to true if not defined
  • Loading branch information
dannyrb authored Apr 17, 2020
1 parent b0cfc45 commit d9fc7bb
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 35 deletions.
2 changes: 2 additions & 0 deletions platform/viewer/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class App extends Component {

static defaultProps = {
config: {
showStudyList: true,
whiteLabelling: {},
oidc: [],
extensions: [],
Expand All @@ -102,6 +103,7 @@ class App extends Component {
const { config, defaultExtensions } = props;

const appDefaultConfig = {
showStudyList: true,
cornerstoneExtensionConfig: {},
extensions: [],
routerBasename: '/',
Expand Down
36 changes: 18 additions & 18 deletions platform/viewer/src/components/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import React, { useState, useEffect } from 'react';
import { Link, withRouter } from 'react-router-dom';
import { withTranslation } from 'react-i18next';

import PropTypes from 'prop-types';

import classNames from 'classnames';
import { Dropdown, AboutContent, withModal } from '@ohif/ui';

//
import { UserPreferences } from './../UserPreferences';
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
import './Header.css';

// Context
import AppContext from './../../context/AppContext';

function Header(props) {
const {
t,
user,
userManager,
modal: { show },
home,
useLargeLogo,
linkPath,
linkText,
location,
children,
} = props;

const [options, setOptions] = useState([]);
const hasLink = linkText && linkPath;

useEffect(() => {
const optionsValue = [
Expand Down Expand Up @@ -61,15 +60,12 @@ function Header(props) {
setOptions(optionsValue);
}, [setOptions, show, t, user, userManager]);

const { appConfig = {} } = AppContext;
const showStudyList =
appConfig.showStudyList !== undefined ? appConfig.showStudyList : true;

// ANTD -- Hamburger, Drawer, Menu
return (
<>
<div className="notification-bar">{t('INVESTIGATIONAL USE ONLY')}</div>
<div className={`entry-header ${home ? 'header-big' : ''}`}>
<div
className={classNames('entry-header', { 'header-big': useLargeLogo })}
>
<div className="header-left-box">
{location && location.studyLink && (
<Link
Expand All @@ -82,15 +78,15 @@ function Header(props) {

{children}

{showStudyList && !home && (
{hasLink && (
<Link
className="header-btn header-studyListLinkSection"
to={{
pathname: '/',
pathname: linkPath,
state: { studyLink: location.pathname },
}}
>
{t('Study list')}
{t(linkText)}
</Link>
)}
</div>
Expand All @@ -105,7 +101,11 @@ function Header(props) {
}

Header.propTypes = {
home: PropTypes.bool.isRequired,
// Study list, /
linkText: PropTypes.string,
linkPath: PropTypes.string,
useLargeLogo: PropTypes.bool,
//
location: PropTypes.object.isRequired,
children: PropTypes.node,
t: PropTypes.func.isRequired,
Expand All @@ -115,7 +115,7 @@ Header.propTypes = {
};

Header.defaultProps = {
home: true,
useLargeLogo: false,
children: OHIFLogo(),
};

Expand Down
33 changes: 24 additions & 9 deletions platform/viewer/src/connectedComponents/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { extensionManager } from './../App.js';
// Contexts
import WhiteLabellingContext from '../context/WhiteLabellingContext.js';
import UserManagerContext from '../context/UserManagerContext';
import AppContext from '../context/AppContext';

import './Viewer.css';

Expand Down Expand Up @@ -230,9 +231,23 @@ class Viewer extends Component {
{whiteLabelling => (
<UserManagerContext.Consumer>
{userManager => (
<ConnectedHeader home={false} userManager={userManager}>
{whiteLabelling.logoComponent}
</ConnectedHeader>
<AppContext.Consumer>
{appContext => (
<ConnectedHeader
linkText={
appContext.appConfig.showStudyList
? 'Study List'
: undefined
}
linkPath={
appContext.appConfig.showStudyList ? '/' : undefined
}
userManager={userManager}
>
{whiteLabelling.logoComponent}
</ConnectedHeader>
)}
</AppContext.Consumer>
)}
</UserManagerContext.Consumer>
)}
Expand Down Expand Up @@ -290,11 +305,11 @@ class Viewer extends Component {
activeIndex={this.props.activeViewportIndex}
/>
) : (
<ConnectedStudyBrowser
studies={this.state.thumbnails}
studyMetadata={this.props.studies}
/>
)}
<ConnectedStudyBrowser
studies={this.state.thumbnails}
studyMetadata={this.props.studies}
/>
)}
</SidePanel>

{/* MAIN */}
Expand Down Expand Up @@ -332,7 +347,7 @@ export default withDialog(Viewer);
* @param {Study[]} studies
* @param {DisplaySet[]} studies[].displaySets
*/
const _mapStudiesToThumbnails = function (studies) {
const _mapStudiesToThumbnails = function(studies) {
return studies.map(study => {
const { StudyInstanceUID } = study;

Expand Down
9 changes: 2 additions & 7 deletions platform/viewer/src/routes/routesUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ const ROUTES_DEF = {
path: ['/studylist', '/'],
component: StudyListRouting,
condition: appConfig => {
return appConfig.showStudyList !== undefined
? appConfig.showStudyList
: true;
return appConfig.showStudyList;
},
},
local: {
Expand All @@ -72,10 +70,7 @@ const ROUTES_DEF = {
'/projects/:project/locations/:location/datasets/:dataset/dicomStores/:dicomStore',
component: StudyListRouting,
condition: appConfig => {
const showList =
appConfig.showStudyList !== undefined
? appConfig.showStudyList
: true;
const showList = appConfig.showStudyList;

return showList && !!appConfig.enableGoogleCloudAdapter;
},
Expand Down
2 changes: 1 addition & 1 deletion platform/viewer/src/studylist/StudyListRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function StudyListRoute(props) {
<UserManagerContext.Consumer>
{userManager => (
<ConnectedHeader
home={true}
useLargeLogo={true}
user={user}
userManager={userManager}
>
Expand Down

0 comments on commit d9fc7bb

Please sign in to comment.