summaryrefslogtreecommitdiffstats
path: root/web/react/components/post_body_additional_content.jsx
diff options
context:
space:
mode:
authorAlan Mooiman <amooiman@gmail.com>2016-02-25 16:33:27 -0800
committerAlan Mooiman <amooiman@gmail.com>2016-02-25 16:41:03 -0800
commit8e3455943142da74be8b13632c0127f8248618cd (patch)
treea28cfb974e8029d021aee8c0a62ced5c5343d297 /web/react/components/post_body_additional_content.jsx
parentb30b4a429318ec80e2adb41b742298a4899e61d0 (diff)
downloadchat-8e3455943142da74be8b13632c0127f8248618cd.tar.gz
chat-8e3455943142da74be8b13632c0127f8248618cd.tar.bz2
chat-8e3455943142da74be8b13632c0127f8248618cd.zip
Add ability to toggle embed visibility
Diffstat (limited to 'web/react/components/post_body_additional_content.jsx')
-rw-r--r--web/react/components/post_body_additional_content.jsx40
1 files changed, 37 insertions, 3 deletions
diff --git a/web/react/components/post_body_additional_content.jsx b/web/react/components/post_body_additional_content.jsx
index a76c59fb3..c2a928f3b 100644
--- a/web/react/components/post_body_additional_content.jsx
+++ b/web/react/components/post_body_additional_content.jsx
@@ -16,16 +16,28 @@ export default class PostBodyAdditionalContent extends React.Component {
this.getSlackAttachment = this.getSlackAttachment.bind(this);
this.getOEmbedProvider = this.getOEmbedProvider.bind(this);
+ this.generateEmbed = this.generateEmbed.bind(this);
+ this.toggleEmbedVisibility = this.toggleEmbedVisibility.bind(this);
+
+ this.state = {
+ embedVisible: true
+ };
}
- shouldComponentUpdate(nextProps) {
+ shouldComponentUpdate(nextProps, nextState) {
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
}
-
+ if (nextState.embedVisible !== this.state.embedVisible) {
+ return true;
+ }
return false;
}
+ toggleEmbedVisibility() {
+ this.setState({embedVisible: !this.state.embedVisible});
+ }
+
getSlackAttachment() {
let attachments = [];
if (this.props.post.props && this.props.post.props.attachments) {
@@ -51,7 +63,7 @@ export default class PostBodyAdditionalContent extends React.Component {
return null;
}
- render() {
+ generateEmbed() {
if (this.props.post.type === 'slack_attachment') {
return this.getSlackAttachment();
}
@@ -98,6 +110,28 @@ export default class PostBodyAdditionalContent extends React.Component {
return null;
}
+
+ render() {
+ var generateEmbed = this.generateEmbed();
+ if (generateEmbed) {
+ return (
+ <div>
+ <a className='post__embed-visibility'
+ data-expanded={this.state.embedVisible}
+ aria-label='Toggle Embed Visibility'
+ onClick={this.toggleEmbedVisibility}
+ >
+ </a>
+ <div className='post__embed-container'
+ hidden={!this.state.embedVisible}
+ >
+ {generateEmbed}
+ </div>
+ </div>
+ );
+ }
+ return null;
+ }
}
PostBodyAdditionalContent.propTypes = {