diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-07-31 09:16:07 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-07-31 09:16:07 -0400 |
commit | d0865b78b776714139f3a6e39527e00fb05b8ea6 (patch) | |
tree | 2580907a7bce3648dc3a00c3effe04a679f22314 /web/react/components/file_attachment_list.jsx | |
parent | c85a852146a7eb079c62917f99663725e9dc06da (diff) | |
parent | 2e5528542d532adb81b038cf14c0bae696fec03a (diff) | |
download | chat-d0865b78b776714139f3a6e39527e00fb05b8ea6.tar.gz chat-d0865b78b776714139f3a6e39527e00fb05b8ea6.tar.bz2 chat-d0865b78b776714139f3a6e39527e00fb05b8ea6.zip |
Merge pull request #271 from hmhealey/mm1656
MM-1656 Updated file UI
Diffstat (limited to 'web/react/components/file_attachment_list.jsx')
-rw-r--r-- | web/react/components/file_attachment_list.jsx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/web/react/components/file_attachment_list.jsx b/web/react/components/file_attachment_list.jsx new file mode 100644 index 000000000..b92442957 --- /dev/null +++ b/web/react/components/file_attachment_list.jsx @@ -0,0 +1,49 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +var ViewImageModal = require('./view_image.jsx'); +var FileAttachment = require('./file_attachment.jsx'); +var Constants = require('../utils/constants.jsx'); + +module.exports = React.createClass({ + displayName: "FileAttachmentList", + propTypes: { + // a list of file pathes displayed by this + filenames: React.PropTypes.arrayOf(React.PropTypes.string).isRequired, + // the identifier of the modal dialog used to preview files + modalId: React.PropTypes.string.isRequired, + // the channel that this is part of + channelId: React.PropTypes.string, + // the user that owns the post that this is attached to + userId: React.PropTypes.string + }, + getInitialState: function() { + return {startImgId: 0}; + }, + render: function() { + var filenames = this.props.filenames; + var modalId = this.props.modalId; + + var postFiles = []; + for (var i = 0; i < filenames.length && i < Constants.MAX_DISPLAY_FILES; i++) { + postFiles.push(<FileAttachment key={i} filenames={filenames} index={i} modalId={modalId} handleImageClick={this.handleImageClick} />); + } + + return ( + <div> + <div className="post-image__columns"> + {postFiles} + </div> + <ViewImageModal + channelId={this.props.channelId} + userId={this.props.userId} + modalId={modalId} + startId={this.state.startImgId} + filenames={filenames} /> + </div> + ); + }, + handleImageClick: function(e) { + this.setState({startImgId: parseInt($(e.target.parentNode).attr('data-img-id'))}); + } +}); |