Files
ohif-viewer/platform/viewer/src/components/Header/Header.js
T

124 lines
2.9 KiB
JavaScript
Raw Normal View History

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';
import PropTypes from 'prop-types';
2020-04-17 12:26:09 -04:00
import classNames from 'classnames';
import { Dropdown, AboutContent, withModal } from '@ohif/ui';
2020-04-17 12:26:09 -04:00
//
import { UserPreferences } from './../UserPreferences';
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
2019-11-05 23:07:03 -05:00
import './Header.css';
2019-11-28 02:48:27 -03:00
function Header(props) {
const {
t,
user,
userManager,
modal: { show },
2020-04-17 12:26:09 -04:00
useLargeLogo,
linkPath,
linkText,
2019-11-28 02:48:27 -03:00
location,
children,
} = props;
2019-11-28 02:48:27 -03:00
const [options, setOptions] = useState([]);
2020-04-17 12:26:09 -04:00
const hasLink = linkText && linkPath;
2019-11-28 02:48:27 -03:00
useEffect(() => {
const optionsValue = [
{
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({
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-28 02:48:27 -03:00
title: t('Preferences'),
icon: {
name: 'user',
},
onClick: () =>
2019-11-28 02:48:27 -03:00
show({
content: UserPreferences,
title: t('User Preferences'),
}),
},
];
2019-11-05 23:07:03 -05:00
if (user && userManager) {
2019-11-28 02:48:27 -03:00
optionsValue.push({
title: t('Logout'),
icon: { name: 'power-off' },
2019-11-05 23:07:03 -05:00
onClick: () => userManager.signoutRedirect(),
});
}
2019-11-28 02:48:27 -03:00
setOptions(optionsValue);
}, [setOptions, show, t, user, userManager]);
return (
<>
<div className="notification-bar">{t('INVESTIGATIONAL USE ONLY')}</div>
2020-04-17 12:26:09 -04:00
<div
className={classNames('entry-header', { 'header-big': useLargeLogo })}
>
2019-11-28 02:48:27 -03:00
<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
2020-04-17 12:26:09 -04:00
{hasLink && (
2019-11-28 02:48:27 -03:00
<Link
className="header-btn header-studyListLinkSection"
to={{
2020-04-17 12:26:09 -04:00
pathname: linkPath,
2019-11-28 02:48:27 -03:00
state: { studyLink: location.pathname },
}}
>
2020-04-17 12:26:09 -04:00
{t(linkText)}
2019-11-28 02:48:27 -03:00
</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" />
</div>
2019-11-28 02:48:27 -03:00
</div>
</>
);
}
2019-01-08 10:48:57 +01:00
2019-11-28 02:48:27 -03:00
Header.propTypes = {
2020-04-17 12:26:09 -04:00
// Study list, /
linkText: PropTypes.string,
linkPath: PropTypes.string,
useLargeLogo: PropTypes.bool,
//
2019-11-28 02:48:27 -03:00
location: PropTypes.object.isRequired,
children: PropTypes.node,
t: PropTypes.func.isRequired,
userManager: PropTypes.object,
user: PropTypes.object,
modal: PropTypes.object,
};
Header.defaultProps = {
2020-04-17 12:26:09 -04:00
useLargeLogo: false,
2019-11-28 02:48:27 -03:00
children: OHIFLogo(),
};
2019-11-05 23:07:03 -05:00
export default withTranslation(['Header', 'AboutModal'])(
withRouter(withModal(Header))
);