diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-11-06 09:05:32 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-11-06 09:05:32 -0500 |
commit | 1ecad4301e6e511a426da5884a54111c5bb7a4fd (patch) | |
tree | 114dea884f0a08729f5b6b5f9e45d2e470bedc71 /web/react/components/post_body_additional_content.jsx | |
parent | 6417d4728dc9351d5bf3180e458be8ce6e1e642f (diff) | |
parent | 195728b949a4f3aee75e01f4b0e4a0b2f67850da (diff) | |
download | chat-1ecad4301e6e511a426da5884a54111c5bb7a4fd.tar.gz chat-1ecad4301e6e511a426da5884a54111c5bb7a4fd.tar.bz2 chat-1ecad4301e6e511a426da5884a54111c5bb7a4fd.zip |
Merge pull request #1327 from florianorben/PLT-857-2
PLT-857: Support `attachments` for Incoming Webhooks
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 |