var FormattedMessage = require('react-intl').FormattedMessage; var FormattedNumber = require('react-intl').FormattedNumber; var injectIntl = require('react-intl').injectIntl; var React = require('react'); var Button = require('../../components/forms/button.jsx'); var FlexRow = require('../../components/flex-row/flex-row.jsx'); var Form = require('../../components/forms/form.jsx'); var Select = require('../../components/forms/select.jsx'); var TitleBanner = require('../../components/title-banner/title-banner.jsx'); var messageStatuses = require('../../redux/messages').Status; // Message Components var AdminMessage = require('./message-rows/admin-message.jsx'); var BecomeManagerMessage = require('./message-rows/become-manager.jsx'); var CommentMessage = require('./message-rows/comment-message.jsx'); var CuratorInviteMessage = require('./message-rows/curator-invite.jsx'); var FavoriteProjectMessage = require('./message-rows/favorite-project.jsx'); var FollowUserMessage = require('./message-rows/follow-user.jsx'); var ForumPostMessage= require('./message-rows/forum-topic-post.jsx'); var LoveProjectMessage = require('./message-rows/love-project.jsx'); var RemixProjectMessage = require('./message-rows/remix-project.jsx'); var ScratcherInvite = require('./message-rows/scratcher-invite.jsx'); var StudioActivityMessage = require('./message-rows/studio-activity.jsx'); var UserJoinMessage = require('./message-rows/user-join.jsx'); require('./messages.scss'); var SocialMessagesList = React.createClass({ type: 'SocialMessagesList', propTypes: { loadStatus: React.PropTypes.string, messages: React.PropTypes.array.isRequired, numNewMessages: React.PropTypes.number, loadMore: React.PropTypes.bool.isRequired, loadMoreMethod: React.PropTypes.func }, getDefaultProps: function () { return { loadStatus: messageStatuses.FETCHING, numNewMessages: 0 }; }, getComponentForMessage: function (message, unread) { var className = (unread) ? 'mod-unread' : ''; var key = message.type + '_' + message.id; switch (message.type) { case 'followuser': return ; case 'loveproject': return ; case 'favoriteproject': return ; case 'addcomment': return ; case 'curatorinvite': return ; case 'remixproject': return ; case 'studioactivity': return ; case 'forumpost': return ; case 'becomeownerstudio': return ; case 'userjoin': return ; } }, renderSocialMessages: function (messages, unreadCount) { var messageList = []; for (var i in messages) { if (i <= unreadCount) { messageList.push(this.getComponentForMessage(messages[i], true)); } else { messageList.push(this.getComponentForMessage(messages[i], false)); } } return messageList; }, renderLoadMore: function (loadMore) { if (loadMore) { return ; } return null; }, renderMessageCounter: function (numNewMessages) { if (numNewMessages > 0) { return
; } return null; }, render: function () { if (this.props.loadStatus === messageStatuses.MESSAGES_ERROR) { return (

); } return (
{this.props.messages.length > 0 ? [

{this.renderMessageCounter(this.props.numNewMessages)}

,
    {this.renderSocialMessages(this.props.messages, (this.props.numNewMessages - 1))}
] : []} {this.renderLoadMore(this.props.loadMore)}
); } }); var MessagesPresentation = injectIntl(React.createClass({ type: 'MessagesPresentation', propTypes: { sessionStatus: React.PropTypes.string.isRequired, user: React.PropTypes.object.isRequired, messages: React.PropTypes.array.isRequired, adminMessages: React.PropTypes.array.isRequired, scratcherInvite: React.PropTypes.object.isRequired, numNewMessages: React.PropTypes.number, handleFilterClick: React.PropTypes.func.isRequired, handleAdminDismiss: React.PropTypes.func.isRequired, loadMore: React.PropTypes.bool.isRequired, loadMoreMethod: React.PropTypes.func, requestStatus: React.PropTypes.object.isRequired, filter: React.PropTypes.string }, getDefaultProps: function () { return { numNewMessages: 0, filterOpen: false, filter: '' }; }, render: function () { var adminMessageLength = this.props.adminMessages.length; if (Object.keys(this.props.scratcherInvite).length > 0) { adminMessageLength = adminMessageLength + 1; } var numNewSocialMessages = this.props.numNewMessages - adminMessageLength; if (numNewSocialMessages < 0) { numNewSocialMessages = 0; } return (