d2-ui
Version:
76 lines (59 loc) • 3.58 kB
JavaScript
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, { Component } from 'react';
import PropTypes from 'prop-types';
import { config } from 'd2/lib/d2';
import IconButton from 'material-ui/IconButton';
import Badge from 'material-ui/Badge';
import NotificationItem from './NotificationItem';
import getBaseUrlFromD2ApiUrl from '../utils/getBaseUrlFromD2ApiUrl';
import SvgIcon from '../../svg-icon/SvgIcon';
import styles from '../header-bar-styles';
config.i18n.strings.add('interpretations');
config.i18n.strings.add('messages');
var Notifications = function (_Component) {
_inherits(Notifications, _Component);
function Notifications() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Notifications);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Notifications.__proto__ || Object.getPrototypeOf(Notifications)).call.apply(_ref, [this].concat(args))), _this), _this.getBaseUrl = function () {
return getBaseUrlFromD2ApiUrl(_this.context.d2);
}, _this.render = function () {
var _this$props$notificat = _this.props.notifications,
unreadInterpretations = _this$props$notificat.unreadInterpretations,
unreadMessageConversations = _this$props$notificat.unreadMessageConversations;
var interpretationsHref = _this.getBaseUrl() + '/dhis-web-interpretation/index.html';
var messagesHref = _this.getBaseUrl() + '/dhis-web-messaging/message.action';
return React.createElement(
'div',
{ style: styles.notifications },
React.createElement(NotificationItem, {
icon: 'Message',
href: interpretationsHref,
count: unreadInterpretations,
tooltip: _this.context.d2.i18n.getTranslation('interpretations'),
style: { top: 2 } // Message icon quick fix
}),
React.createElement(NotificationItem, {
icon: 'Email',
href: messagesHref,
count: unreadMessageConversations,
tooltip: _this.context.d2.i18n.getTranslation('messages')
})
);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
return Notifications;
}(Component);
Notifications.propTypes = {
notifications: PropTypes.object.isRequired
};
Notifications.contextTypes = {
d2: PropTypes.object.isRequired
};
export default Notifications;