reformatting and minor refactoring of post_*.jsx to match style guide
Этот коммит содержится в:
@@ -74,9 +74,9 @@ module.exports = React.createClass({
|
|||||||
var parentPost = this.props.parentPost;
|
var parentPost = this.props.parentPost;
|
||||||
var posts = this.props.posts;
|
var posts = this.props.posts;
|
||||||
|
|
||||||
var type = "Post";
|
var type = 'Post';
|
||||||
if (post.root_id && post.root_id.length > 0) {
|
if (post.root_id && post.root_id.length > 0) {
|
||||||
type = "Comment";
|
type = 'Comment';
|
||||||
}
|
}
|
||||||
|
|
||||||
var commentCount = 0;
|
var commentCount = 0;
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ module.exports = React.createClass({
|
|||||||
var name = "...";
|
var name = "...";
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
if (profile.username.slice(-1) === 's') {
|
if (profile.username.slice(-1) === 's') {
|
||||||
apostrophe = "'";
|
apostrophe = '\'';
|
||||||
} else {
|
} else {
|
||||||
apostrophe = "'s";
|
apostrophe = '\'s';
|
||||||
}
|
}
|
||||||
name = <a className="theme" onClick={function(){ utils.searchForTerm(profile.username); }}>{profile.username}</a>;
|
name = <a className="theme" onClick={function(){ utils.searchForTerm(profile.username); }}>{profile.username}</a>;
|
||||||
}
|
}
|
||||||
@@ -62,11 +62,11 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
var loading;
|
var loading;
|
||||||
if (post.state === Constants.POST_FAILED) {
|
if (post.state === Constants.POST_FAILED) {
|
||||||
postClass += " post-fail";
|
postClass += ' post-fail';
|
||||||
loading = <a className="theme post-retry pull-right" href="#" onClick={this.props.retryPost}>Retry</a>;
|
loading = <a className='theme post-retry pull-right' href='#' onClick={this.props.retryPost}>Retry</a>;
|
||||||
} else if (post.state === Constants.POST_LOADING) {
|
} else if (post.state === Constants.POST_LOADING) {
|
||||||
postClass += " post-waiting";
|
postClass += ' post-waiting';
|
||||||
loading = <img className="post-loading-gif pull-right" src="/static/images/load.gif"/>;
|
loading = <img className='post-loading-gif pull-right' src='/static/images/load.gif'/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
var embed;
|
var embed;
|
||||||
|
|||||||
@@ -12,41 +12,65 @@ module.exports = React.createClass({
|
|||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
var isOwner = UserStore.getCurrentId() == post.user_id;
|
var isOwner = UserStore.getCurrentId() === post.user_id;
|
||||||
var isAdmin = UserStore.getCurrentUser().roles.indexOf("admin") > -1
|
var isAdmin = UserStore.getCurrentUser().roles.indexOf('admin') > -1;
|
||||||
|
|
||||||
var type = "Post";
|
var type = 'Post';
|
||||||
if (post.root_id && post.root_id.length > 0) {
|
if (post.root_id && post.root_id.length > 0) {
|
||||||
type = "Comment";
|
type = 'Comment';
|
||||||
|
}
|
||||||
|
|
||||||
|
var comments = '';
|
||||||
|
var lastCommentClass = ' comment-icon__container__hide';
|
||||||
|
if (this.props.isLastComment) {
|
||||||
|
lastCommentClass = ' comment-icon__container__show';
|
||||||
}
|
}
|
||||||
|
|
||||||
var comments = "";
|
|
||||||
var lastCommentClass = this.props.isLastComment ? " comment-icon__container__show" : " comment-icon__container__hide";
|
|
||||||
if (this.props.commentCount >= 1 && post.state !== Constants.POST_FAILED && post.state !== Constants.POST_LOADING) {
|
if (this.props.commentCount >= 1 && post.state !== Constants.POST_FAILED && post.state !== Constants.POST_LOADING) {
|
||||||
comments = <a href="#" className={"comment-icon__container theme" + lastCommentClass} onClick={this.props.handleCommentClick}><span className="comment-icon" dangerouslySetInnerHTML={{__html: Constants.COMMENT_ICON }} />{this.props.commentCount}</a>;
|
comments = <a href='#' className={'comment-icon__container theme' + lastCommentClass} onClick={this.props.handleCommentClick}><span className='comment-icon' dangerouslySetInnerHTML={{__html: Constants.COMMENT_ICON}} />{this.props.commentCount}</a>;
|
||||||
}
|
}
|
||||||
|
|
||||||
var show_dropdown = isOwner || (this.props.allowReply === "true" && type != "Comment");
|
var showDropdown = isOwner || (this.props.allowReply === 'true' && type !== 'Comment');
|
||||||
if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING) show_dropdown = false;
|
if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING) {
|
||||||
|
showDropdown = false;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
var dropdownContents = [];
|
||||||
<ul className="post-header post-info">
|
var dropdown;
|
||||||
<li className="post-header-col"><time className="post-profile-time">{ utils.displayDateTime(post.create_at) }</time></li>
|
if (showDropdown) {
|
||||||
<li className="post-header-col post-header__reply">
|
var dataComments = 0;
|
||||||
<div className="dropdown">
|
if (type === 'Post') {
|
||||||
{ show_dropdown ?
|
dataComments = this.props.commentCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOwner) {
|
||||||
|
dropdownContents.push(<li role='presentation'><a href='#' role='menuitem' data-toggle='modal' data-target='#edit_post' data-title={type} data-message={post.message} data-postid={post.id} data-channelid={post.channel_id} data-comments={dataComments}>Edit</a></li>);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOwner || isAdmin) {
|
||||||
|
dropdownContents.push(<li role='presentation'><a href='#' role='menuitem' data-toggle='modal' data-target='#delete_post' data-title={type} data-postid={post.id} data-channelid={post.channel_id} data-comments={dataComments}>Delete</a></li>);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.props.allowReply === 'true') {
|
||||||
|
dropdownContents.push(<li role='presentation'><a className='reply-link theme' href='#' onClick={this.props.handleCommentClick}>Reply</a></li>);
|
||||||
|
}
|
||||||
|
|
||||||
|
dropdown = (
|
||||||
<div>
|
<div>
|
||||||
<a href="#" className="dropdown-toggle theme" type="button" data-toggle="dropdown" aria-expanded="false" />
|
<a href='#' className='dropdown-toggle theme' type='button' data-toggle='dropdown' aria-expanded='false' />
|
||||||
<ul className="dropdown-menu" role="menu">
|
<ul className='dropdown-menu' role='menu'>
|
||||||
{ isOwner ? <li role="presentation"><a href="#" role="menuitem" data-toggle="modal" data-target="#edit_post" data-title={type} data-message={post.message} data-postid={post.id} data-channelid={post.channel_id} data-comments={type === "Post" ? this.props.commentCount : 0}>Edit</a></li>
|
{dropdownContents}
|
||||||
: "" }
|
|
||||||
{ isOwner || isAdmin ? <li role="presentation"><a href="#" role="menuitem" data-toggle="modal" data-target="#delete_post" data-title={type} data-postid={post.id} data-channelid={post.channel_id} data-comments={type === "Post" ? this.props.commentCount : 0}>Delete</a></li>
|
|
||||||
: "" }
|
|
||||||
{ this.props.allowReply === "true" ? <li role="presentation"><a className="reply-link theme" href="#" onClick={this.props.handleCommentClick}>Reply</a></li>
|
|
||||||
: "" }
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
: "" }
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ul className='post-header post-info'>
|
||||||
|
<li className='post-header-col'><time className='post-profile-time'>{utils.displayDateTime(post.create_at)}</time></li>
|
||||||
|
<li className='post-header-col post-header__reply'>
|
||||||
|
<div className='dropdown'>
|
||||||
|
{dropdown}
|
||||||
</div>
|
</div>
|
||||||
{comments}
|
{comments}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user