var BindStoreMixin, Icon, Notification, NotificationActions, NotificationBar, NotificationStore, React, _, ref;
React = require('react');
_ = require('underscore');
Icon = require('../icon');
ref = require('../../flux/notifications'), NotificationStore = ref.NotificationStore, NotificationActions = ref.NotificationActions;
BindStoreMixin = require('../bind-store-mixin');
Notification = React.createClass({displayName: "Notification",
propTypes: {
notice: React.PropTypes.shape({
id: React.PropTypes.string.isRequired,
message: React.PropTypes.string.isRequired
}).isRequired
},
acknowledge: function() {
return NotificationActions.acknowledge(this.props.notice.id);
},
render: function() {
return React.createElement("div", {
"className": "notification"
}, React.createElement(Icon, {
"type": 'info-circle'
}), this.props.notice.message, React.createElement("a", {
"className": 'dismiss',
"onClick": this.acknowledge
}, "Dismiss"));
}
});
NotificationBar = React.createClass({displayName: "NotificationBar",
mixins: [BindStoreMixin],
bindStore: NotificationStore,
render: function() {
var notice, notifications;
notifications = NotificationStore.getActiveNotifications();
Eif (_.isEmpty(notifications)) {
return null;
}
return React.createElement("div", {
"className": "notifications-bar"
}, (function() {
var i, len, results;
results = [];
for (i = 0, len = notifications.length; i < len; i++) {
notice = notifications[i];
results.push(React.createElement(Notification, {
"key": notice.id,
"notice": notice
}));
}
return results;
})());
}
});
module.exports = NotificationBar;
|