UNPKG

@attivio/suit

Version:

Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.

95 lines (83 loc) 3.73 kB
var _class, _temp; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React from 'react'; import Dropdown from 'react-bootstrap/lib/Dropdown'; import MenuItem from 'react-bootstrap/lib/MenuItem'; // LJV TODO Move help link to configuration and don't show if not set. /** * Displays the currently logged-in user inside the masthead. * The user can click on the name to pop-up a menu with a log-out command. */ var MastheadUser = (_temp = _class = function (_React$Component) { _inherits(MastheadUser, _React$Component); function MastheadUser(props) { _classCallCheck(this, MastheadUser); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.handleLogoutMenuItem = _this.handleLogoutMenuItem.bind(_this); return _this; } MastheadUser.prototype.handleLogoutMenuItem = function handleLogoutMenuItem() { // We shouldn't get here if there's no logout function, but double-check anyway if (this.props.logoutFunction) { this.props.logoutFunction(); } }; MastheadUser.prototype.render = function render() { var dropdown = null; // Only show the menu with the logout item if there's a function passed in. if (this.props.logoutFunction) { dropdown = React.createElement( 'span', null, ' ', React.createElement( Dropdown, { id: 'attivio-globalmast-user-dropdown', pullRight: true }, React.createElement( Dropdown.Toggle, { noCaret: true, useAnchor: true, style: { background: 'transparent', color: '#fff' } }, React.createElement('span', { className: 'attivio-globalmast-icon attivio-icon-arrow-down-blue' }) ), React.createElement( Dropdown.Menu, { onSelect: this.handleLogoutMenuItem }, React.createElement( MenuItem, null, 'Log Out' ) ) ), this.props.helpUri ? React.createElement( 'a', { href: this.props.helpUri, target: '_blank', style: { marginLeft: '8px' }, rel: 'noopener noreferrer' }, React.createElement('img', { src: 'img/vector/help.svg', title: 'On-line Help', alt: 'On-line Help' }) ) : null ); } if (this.props.username && this.props.username.length > 0) { return React.createElement( 'div', { className: 'attivio-globalmast-user attivio-globalmast-separator before' }, this.props.username, dropdown ); } return null; }; return MastheadUser; }(React.Component), _class.defaultProps = { username: null, logoutFunction: null, helpUri: null }, _class.displayName = 'MastheadUser', _temp); export { MastheadUser as default };