2019-11-28 02:48:27 -03:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2019-11-05 23:07:03 -05:00
|
|
|
import { Link, withRouter } from 'react-router-dom';
|
|
|
|
|
import { withTranslation } from 'react-i18next';
|
2020-02-12 17:35:04 -03:00
|
|
|
|
2019-11-05 23:07:03 -05:00
|
|
|
import PropTypes from 'prop-types';
|
2019-06-06 14:41:31 -04:00
|
|
|
|
2019-11-11 23:03:36 -03:00
|
|
|
import { Dropdown, AboutContent, withModal } from '@ohif/ui';
|
2020-02-12 17:35:04 -03:00
|
|
|
|
|
|
|
|
import { UserPreferences } from './../UserPreferences';
|
2019-01-24 14:00:01 +01:00
|
|
|
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
|
2019-11-05 23:07:03 -05:00
|
|
|
import './Header.css';
|
2019-11-11 23:03:36 -03:00
|
|
|
|
2019-09-06 15:31:26 -03:00
|
|
|
// Context
|
|
|
|
|
import AppContext from './../../context/AppContext';
|
|
|
|
|
|
2019-11-28 02:48:27 -03:00
|
|
|
function Header(props) {
|
|
|
|
|
const {
|
|
|
|
|
t,
|
|
|
|
|
user,
|
|
|
|
|
userManager,
|
|
|
|
|
modal: { show },
|
|
|
|
|
home,
|
|
|
|
|
location,
|
|
|
|
|
children,
|
|
|
|
|
} = props;
|
2019-01-24 14:00:01 +01:00
|
|
|
|
2019-11-28 02:48:27 -03:00
|
|
|
const [options, setOptions] = useState([]);
|
2019-01-31 05:55:05 -02:00
|
|
|
|
2019-11-28 02:48:27 -03:00
|
|
|
useEffect(() => {
|
|
|
|
|
const optionsValue = [
|
2019-01-31 05:55:05 -02:00
|
|
|
{
|
2019-06-07 17:55:53 -03:00
|
|
|
title: t('About'),
|
2019-06-16 22:51:28 -05:00
|
|
|
icon: { name: 'info' },
|
2019-11-05 23:07:03 -05:00
|
|
|
onClick: () =>
|
2019-11-28 02:48:27 -03:00
|
|
|
show({
|
2019-11-25 19:13:42 -03:00
|
|
|
content: AboutContent,
|
2019-11-05 23:07:03 -05:00
|
|
|
title: t('OHIF Viewer - About'),
|
|
|
|
|
}),
|
2019-05-29 08:39:54 -04:00
|
|
|
},
|
2019-11-11 23:03:36 -03:00
|
|
|
{
|
2019-11-28 02:48:27 -03:00
|
|
|
title: t('Preferences'),
|
2019-11-11 23:03:36 -03:00
|
|
|
icon: {
|
|
|
|
|
name: 'user',
|
|
|
|
|
},
|
|
|
|
|
onClick: () =>
|
2019-11-28 02:48:27 -03:00
|
|
|
show({
|
2020-02-12 17:35:04 -03:00
|
|
|
content: UserPreferences,
|
2019-11-11 23:03:36 -03:00
|
|
|
title: t('User Preferences'),
|
|
|
|
|
}),
|
|
|
|
|
},
|
2019-01-31 05:55:05 -02:00
|
|
|
];
|
2019-06-06 14:41:31 -04:00
|
|
|
|
2019-11-05 23:07:03 -05:00
|
|
|
if (user && userManager) {
|
2019-11-28 02:48:27 -03:00
|
|
|
optionsValue.push({
|
2019-07-21 16:43:42 +02:00
|
|
|
title: t('Logout'),
|
2019-09-06 15:31:26 -03:00
|
|
|
icon: { name: 'power-off' },
|
2019-11-05 23:07:03 -05:00
|
|
|
onClick: () => userManager.signoutRedirect(),
|
2019-07-21 16:43:42 +02:00
|
|
|
});
|
|
|
|
|
}
|
2019-11-28 02:48:27 -03:00
|
|
|
|
|
|
|
|
setOptions(optionsValue);
|
|
|
|
|
}, [setOptions, show, t, user, userManager]);
|
|
|
|
|
|
|
|
|
|
const { appConfig = {} } = AppContext;
|
|
|
|
|
const showStudyList =
|
|
|
|
|
appConfig.showStudyList !== undefined ? appConfig.showStudyList : true;
|
2019-01-01 09:23:17 -02:00
|
|
|
|
2019-10-28 14:47:57 -04:00
|
|
|
// ANTD -- Hamburger, Drawer, Menu
|
2019-11-28 02:48:27 -03:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className="notification-bar">{t('INVESTIGATIONAL USE ONLY')}</div>
|
|
|
|
|
<div className={`entry-header ${home ? 'header-big' : ''}`}>
|
|
|
|
|
<div className="header-left-box">
|
|
|
|
|
{location && location.studyLink && (
|
|
|
|
|
<Link
|
|
|
|
|
to={location.studyLink}
|
|
|
|
|
className="header-btn header-viewerLink"
|
|
|
|
|
>
|
|
|
|
|
{t('Back to Viewer')}
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
2019-10-28 14:47:57 -04:00
|
|
|
|
2019-11-28 02:48:27 -03:00
|
|
|
{children}
|
2019-10-28 14:47:57 -04:00
|
|
|
|
2019-11-28 02:48:27 -03:00
|
|
|
{showStudyList && !home && (
|
|
|
|
|
<Link
|
|
|
|
|
className="header-btn header-studyListLinkSection"
|
|
|
|
|
to={{
|
|
|
|
|
pathname: '/',
|
|
|
|
|
state: { studyLink: location.pathname },
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{t('Study list')}
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2019-10-28 14:47:57 -04:00
|
|
|
|
2019-11-28 02:48:27 -03:00
|
|
|
<div className="header-menu">
|
|
|
|
|
<span className="research-use">{t('INVESTIGATIONAL USE ONLY')}</span>
|
|
|
|
|
<Dropdown title={t('Options')} list={options} align="right" />
|
2019-01-31 05:55:05 -02:00
|
|
|
</div>
|
2019-11-28 02:48:27 -03:00
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
2019-01-31 05:55:05 -02:00
|
|
|
}
|
2019-01-08 10:48:57 +01:00
|
|
|
|
2019-11-28 02:48:27 -03:00
|
|
|
Header.propTypes = {
|
|
|
|
|
home: PropTypes.bool.isRequired,
|
|
|
|
|
location: PropTypes.object.isRequired,
|
|
|
|
|
children: PropTypes.node,
|
|
|
|
|
t: PropTypes.func.isRequired,
|
|
|
|
|
userManager: PropTypes.object,
|
|
|
|
|
user: PropTypes.object,
|
|
|
|
|
modal: PropTypes.object,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Header.defaultProps = {
|
|
|
|
|
home: true,
|
|
|
|
|
children: OHIFLogo(),
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-05 23:07:03 -05:00
|
|
|
export default withTranslation(['Header', 'AboutModal'])(
|
|
|
|
|
withRouter(withModal(Header))
|
|
|
|
|
);
|