summaryrefslogtreecommitdiffstats
path: root/webapp/components/post_view
diff options
context:
space:
mode:
authorAsaad Mahmood <asaadmahmoodspin@users.noreply.github.com>2016-07-11 18:37:42 +0500
committerHarrison Healey <harrisonmhealey@gmail.com>2016-07-11 09:37:42 -0400
commit075383e190dd8b487dea5edd43863c3bb6af2042 (patch)
treee725f06c59e386207922d0ac1050fcc196f6177f /webapp/components/post_view
parente10a576b625a48e6e3e1161aa0e53c32397667dd (diff)
downloadchat-075383e190dd8b487dea5edd43863c3bb6af2042.tar.gz
chat-075383e190dd8b487dea5edd43863c3bb6af2042.tar.bz2
chat-075383e190dd8b487dea5edd43863c3bb6af2042.zip
Plt 3475 - Post control improvements (#3538)
* Adding class to post when dropdown is active. * plt-3475 - Post controls improvements
Diffstat (limited to 'webapp/components/post_view')
-rw-r--r--webapp/components/post_view/components/post.jsx28
-rw-r--r--webapp/components/post_view/components/post_header.jsx2
-rw-r--r--webapp/components/post_view/components/post_info.jsx15
3 files changed, 38 insertions, 7 deletions
diff --git a/webapp/components/post_view/components/post.jsx b/webapp/components/post_view/components/post.jsx
index 0a4840050..21d335a51 100644
--- a/webapp/components/post_view/components/post.jsx
+++ b/webapp/components/post_view/components/post.jsx
@@ -18,9 +18,12 @@ export default class Post extends React.Component {
super(props);
this.handleCommentClick = this.handleCommentClick.bind(this);
+ this.handleDropdownOpened = this.handleDropdownOpened.bind(this);
this.forceUpdateInfo = this.forceUpdateInfo.bind(this);
- this.state = {};
+ this.state = {
+ dropdownOpened: false
+ };
}
handleCommentClick(e) {
e.preventDefault();
@@ -35,11 +38,16 @@ export default class Post extends React.Component {
results: null
});
}
+ handleDropdownOpened(opened) {
+ this.setState({
+ dropdownOpened: opened
+ });
+ }
forceUpdateInfo() {
this.refs.info.forceUpdate();
this.refs.header.forceUpdate();
}
- shouldComponentUpdate(nextProps) {
+ shouldComponentUpdate(nextProps, nextState) {
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
}
@@ -88,6 +96,14 @@ export default class Post extends React.Component {
return true;
}
+ if (nextProps.emojis !== this.props.emojis) {
+ return true;
+ }
+
+ if (nextState.dropdownOpened !== this.state.dropdownOpened) {
+ return true;
+ }
+
return false;
}
render() {
@@ -187,11 +203,16 @@ export default class Post extends React.Component {
profilePicContainer = '';
}
+ let dropdownOpenedClass = '';
+ if (this.state.dropdownOpened) {
+ dropdownOpenedClass = 'post--hovered';
+ }
+
return (
<div>
<div
id={'post_' + post.id}
- className={'post ' + sameUserClass + ' ' + compactClass + ' ' + rootUser + ' ' + postType + ' ' + currentUserCss + ' ' + shouldHighlightClass + ' ' + systemMessageClass + ' ' + hideControls}
+ className={'post ' + sameUserClass + ' ' + compactClass + ' ' + rootUser + ' ' + postType + ' ' + currentUserCss + ' ' + shouldHighlightClass + ' ' + systemMessageClass + ' ' + hideControls + ' ' + dropdownOpenedClass}
>
<div className={'post__content ' + centerClass}>
{profilePicContainer}
@@ -202,6 +223,7 @@ export default class Post extends React.Component {
sameRoot={this.props.sameRoot}
commentCount={commentCount}
handleCommentClick={this.handleCommentClick}
+ handleDropdownOpened={this.handleDropdownOpened}
isLastComment={this.props.isLastComment}
sameUser={this.props.sameUser}
user={this.props.user}
diff --git a/webapp/components/post_view/components/post_header.jsx b/webapp/components/post_view/components/post_header.jsx
index 727b005e7..e76358304 100644
--- a/webapp/components/post_view/components/post_header.jsx
+++ b/webapp/components/post_view/components/post_header.jsx
@@ -64,6 +64,7 @@ export default class PostHeader extends React.Component {
post={post}
commentCount={this.props.commentCount}
handleCommentClick={this.props.handleCommentClick}
+ handleDropdownOpened={this.props.handleDropdownOpened}
allowReply='true'
isLastComment={this.props.isLastComment}
sameUser={this.props.sameUser}
@@ -90,6 +91,7 @@ PostHeader.propTypes = {
commentCount: React.PropTypes.number.isRequired,
isLastComment: React.PropTypes.bool.isRequired,
handleCommentClick: React.PropTypes.func.isRequired,
+ handleDropdownOpened: React.PropTypes.func.isRequired,
sameUser: React.PropTypes.bool.isRequired,
compactDisplay: React.PropTypes.bool,
displayNameType: React.PropTypes.string,
diff --git a/webapp/components/post_view/components/post_info.jsx b/webapp/components/post_view/components/post_info.jsx
index 76d4df1cc..d74be4c72 100644
--- a/webapp/components/post_view/components/post_info.jsx
+++ b/webapp/components/post_view/components/post_info.jsx
@@ -18,16 +18,20 @@ export default class PostInfo extends React.Component {
constructor(props) {
super(props);
- this.dropdownPosition = this.dropdownPosition.bind(this);
+ this.handleDropdownClick = this.handleDropdownClick.bind(this);
this.handlePermalink = this.handlePermalink.bind(this);
}
- dropdownPosition(e) {
+ handleDropdownClick(e) {
var position = $('#post-list').height() - $(e.target).offset().top;
var dropdown = $(e.target).closest('.col__reply').find('.dropdown-menu');
if (position < dropdown.height()) {
dropdown.addClass('bottom');
}
}
+ componentDidMount() {
+ $('#post_dropdown' + this.props.post.id).on('shown.bs.dropdown', () => this.props.handleDropdownOpened(true));
+ $('#post_dropdown' + this.props.post.id).on('hidden.bs.dropdown', () => this.props.handleDropdownOpened(false));
+ }
createDropdown() {
var post = this.props.post;
var isOwner = this.props.currentUser.id === post.user_id;
@@ -140,14 +144,16 @@ export default class PostInfo extends React.Component {
}
return (
- <div>
+ <div
+ id={'post_dropdown' + this.props.post.id}
+ >
<a
href='#'
className='dropdown-toggle post__dropdown theme'
type='button'
data-toggle='dropdown'
aria-expanded='false'
- onClick={this.dropdownPosition}
+ onClick={this.handleDropdownClick}
/>
<ul
className='dropdown-menu'
@@ -231,6 +237,7 @@ PostInfo.propTypes = {
isLastComment: React.PropTypes.bool.isRequired,
allowReply: React.PropTypes.string.isRequired,
handleCommentClick: React.PropTypes.func.isRequired,
+ handleDropdownOpened: React.PropTypes.func.isRequired,
sameUser: React.PropTypes.bool.isRequired,
currentUser: React.PropTypes.object.isRequired,
compactDisplay: React.PropTypes.bool,