@entando/menu
Version:
react components used to render menus in entando projects
205 lines (178 loc) • 7.79 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _reactBootstrap = require('react-bootstrap');
var _reactIntl = require('react-intl');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
var Notification = function (_Component) {
_inherits(Notification, _Component);
function Notification(props) {
_classCallCheck(this, Notification);
var _this = _possibleConstructorReturn(this, (Notification.__proto__ || Object.getPrototypeOf(Notification)).call(this, props));
_this.comment = null;
return _this;
}
_createClass(Notification, [{
key: 'render',
value: function render() {
var _this2 = this;
var _props = this.props,
id = _props.id,
username = _props.username,
notification = _props.notification,
targetName = _props.targetName,
onClickUsername = _props.onClickUsername,
onClickTargetName = _props.onClickTargetName,
onClickLike = _props.onClickLike,
modificationDate = _props.modificationDate;
var onSubmit = function onSubmit(ev) {
ev.preventDefault();
};
var onClickUsernameHandler = function onClickUsernameHandler(ev) {
ev.preventDefault();
onClickUsername(id);
};
var onClickTargetNameHandler = function onClickTargetNameHandler(ev) {
ev.preventDefault();
onClickTargetName(id);
};
var onClickTargetLikeHandler = function onClickTargetLikeHandler(ev) {
ev.preventDefault();
onClickLike(id);
};
return _react2.default.createElement(
'div',
{ className: 'Notification' },
_react2.default.createElement(
_reactBootstrap.Row,
{ className: 'Notification__top-row' },
_react2.default.createElement(
_reactBootstrap.Col,
{ md: 12 },
_react2.default.createElement('i', { className: 'Notification__user-icon fa fa-user fa-2x' }),
_react2.default.createElement(
'a',
{
href: '',
className: 'Notification__user',
onClick: onClickUsernameHandler
},
username
),
_react2.default.createElement(
'p',
{ className: 'Notification__notify' },
notification
),
_react2.default.createElement(
'a',
{
href: '',
className: 'Notification__link',
onClick: onClickTargetNameHandler
},
targetName
)
)
),
_react2.default.createElement(
_reactBootstrap.Row,
null,
_react2.default.createElement(
_reactBootstrap.Col,
{ md: 12 },
_react2.default.createElement(
'span',
{ className: 'Notification__date ' },
_react2.default.createElement(_reactIntl.FormattedRelative, { value: modificationDate })
),
_react2.default.createElement(
'a',
{
href: '',
className: 'Notification__like',
onClick: onClickTargetLikeHandler
},
_react2.default.createElement('i', { className: 'fa fa-thumbs-up' })
)
)
),
_react2.default.createElement(
_reactBootstrap.Panel,
{ className: 'Notification__panel-override' },
_react2.default.createElement(
_reactBootstrap.Row,
{ className: 'Notification__comment-section' },
_react2.default.createElement(
_reactBootstrap.Panel.Toggle,
{ componentClass: 'a', className: 'pull-right Notification__comment-section' },
_react2.default.createElement(_reactIntl.FormattedMessage, {
id: 'fl.menu.activityStream.writeComment'
})
)
),
_react2.default.createElement(
_reactBootstrap.Panel.Collapse,
null,
_react2.default.createElement(
_reactBootstrap.Panel.Body,
null,
_react2.default.createElement(
_reactBootstrap.Form,
{ onSubmit: onSubmit },
_react2.default.createElement(
_reactBootstrap.Col,
{ md: 12 },
_react2.default.createElement('textarea', {
className: 'Notification__text-area',
ref: function ref(comment) {
_this2.comment = comment;
}
})
),
_react2.default.createElement(
_reactBootstrap.Col,
{ md: 12 },
_react2.default.createElement(
_reactBootstrap.Button,
{ type: 'submit', className: 'pull-right', bsStyle: 'primary' },
_react2.default.createElement(_reactIntl.FormattedMessage, {
className: 'pull-right',
id: 'fl.menu.activityStream.submit'
})
)
)
)
)
)
)
);
}
}]);
return Notification;
}(_react.Component);
Notification.defaultProps = {
onClickUsername: function onClickUsername() {},
onClickTargetName: function onClickTargetName() {},
onClickLike: function onClickLike() {}
};
Notification.propTypes = {
id: _propTypes2.default.number.isRequired,
username: _propTypes2.default.string.isRequired,
notification: _propTypes2.default.string.isRequired,
targetName: _propTypes2.default.string.isRequired,
modificationDate: _propTypes2.default.instanceOf(Date).isRequired,
onClickTargetName: _propTypes2.default.func,
onClickUsername: _propTypes2.default.func,
onClickLike: _propTypes2.default.func
};
exports.default = Notification;