diff options
author | Florian Orben <florian.orben@gmail.com> | 2015-11-05 23:32:44 +0100 |
---|---|---|
committer | Florian Orben <florian.orben@gmail.com> | 2015-11-05 23:33:21 +0100 |
commit | b085bc2d56bdc98101b8cb50848aee248d42af28 (patch) | |
tree | 9e19e790ed53aa1fbaa4b5c0c5574e03ae801577 /web/react/components/post_body_additional_content.jsx | |
parent | 4b6eb56415c2085bc9078836b70b833b1e01a60d (diff) | |
download | chat-b085bc2d56bdc98101b8cb50848aee248d42af28.tar.gz chat-b085bc2d56bdc98101b8cb50848aee248d42af28.tar.bz2 chat-b085bc2d56bdc98101b8cb50848aee248d42af28.zip |
PLT-857: Support for Incoming Webhooks - Try #2
Diffstat (limited to 'web/react/components/post_body_additional_content.jsx')
-rw-r--r-- | web/react/components/post_body_additional_content.jsx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/web/react/components/post_body_additional_content.jsx b/web/react/components/post_body_additional_content.jsx new file mode 100644 index 000000000..8189ba2d3 --- /dev/null +++ b/web/react/components/post_body_additional_content.jsx @@ -0,0 +1,56 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +const PostAttachmentList = require('./post_attachment_list.jsx'); + +export default class PostBodyAdditionalContent extends React.Component { + constructor(props) { + super(props); + + this.getSlackAttachment = this.getSlackAttachment.bind(this); + this.getComponent = this.getComponent.bind(this); + } + + componentWillMount() { + this.setState({type: this.props.post.type, shouldRender: Boolean(this.props.post.type)}); + } + + getSlackAttachment() { + const attachments = this.props.post.props && this.props.post.props.attachments || []; + return ( + <PostAttachmentList + key={'post_body_additional_content' + this.props.post.id} + attachments={attachments} + /> + ); + } + + getComponent() { + switch (this.state.type) { + case 'slack_attachment': + return this.getSlackAttachment(); + } + } + + render() { + let content = []; + + if (this.state.shouldRender) { + const component = this.getComponent(); + + if (component) { + content = component; + } + } + + return ( + <div> + {content} + </div> + ); + } +} + +PostBodyAdditionalContent.propTypes = { + post: React.PropTypes.object.isRequired +};
\ No newline at end of file |