Plt 3475 - Post control improvements (#3538)
* Adding class to post when dropdown is active. * plt-3475 - Post controls improvements
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
e10a576b62
Коммит
075383e190
@@ -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}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Ссылка в новой задаче
Block a user