[DE PE SSE]Setting rights for comments

This commit is contained in:
ShimaginAndrey 2021-07-06 17:13:55 +03:00
parent 322f8930ec
commit 1486c12cd4
6 changed files with 33 additions and 15 deletions

View file

@ -139,8 +139,9 @@ class CommentsController extends Component {
changeComment.quote = data.asc_getQuoteText(); changeComment.quote = data.asc_getQuoteText();
changeComment.time = date.getTime(); changeComment.time = date.getTime();
changeComment.date = dateToLocaleTimeString(date); changeComment.date = dateToLocaleTimeString(date);
changeComment.editable = this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId); changeComment.editable = (this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName());
changeComment.removable = this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId); changeComment.removable = (this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName());
changeComment.hide = !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName());
let dateReply = null; let dateReply = null;
const replies = []; const replies = [];
@ -164,8 +165,8 @@ class CommentsController extends Component {
reply: data.asc_getReply(i).asc_getText(), reply: data.asc_getReply(i).asc_getText(),
time: dateReply.getTime(), time: dateReply.getTime(),
userInitials: this.usersStore.getInitials(parsedName), userInitials: this.usersStore.getInitials(parsedName),
editable: this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId), editable: (this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()),
removable: this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId) removable: (this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName())
}); });
} }
changeComment.replies = replies; changeComment.replies = replies;
@ -197,8 +198,9 @@ class CommentsController extends Component {
replies : [], replies : [],
groupName : (groupName && groupName.length>1) ? groupName[1] : null, groupName : (groupName && groupName.length>1) ? groupName[1] : null,
userInitials : this.usersStore.getInitials(parsedName), userInitials : this.usersStore.getInitials(parsedName),
editable : this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId), editable : (this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName()),
removable : this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId) removable : (this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName()),
hide : !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName()),
}; };
if (comment) { if (comment) {
const replies = this.readSDKReplies(data); const replies = this.readSDKReplies(data);
@ -230,8 +232,8 @@ class CommentsController extends Component {
reply : data.asc_getReply(i).asc_getText(), reply : data.asc_getReply(i).asc_getText(),
time : date.getTime(), time : date.getTime(),
userInitials : this.usersStore.getInitials(parsedName), userInitials : this.usersStore.getInitials(parsedName),
editable : this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId), editable : (this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()),
removable : this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId) removable : (this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName())
}); });
} }
} }

View file

@ -80,6 +80,7 @@ export class storeComments {
comment.editable = changeComment.editable; comment.editable = changeComment.editable;
comment.removable = changeComment.removable; comment.removable = changeComment.removable;
comment.replies = changeComment.replies; comment.replies = changeComment.replies;
comment.hide =changeComment.hide;
} }
} }

View file

@ -148,9 +148,9 @@ const CommentActions = ({comment, onCommentMenuClick, opened, openActionComment}
<ActionsGroup> <ActionsGroup>
{comment && <Fragment> {comment && <Fragment>
{comment.editable && <ActionsButton onClick={() => {onCommentMenuClick('editComment', comment);}}>{_t.textEdit}</ActionsButton>} {comment.editable && <ActionsButton onClick={() => {onCommentMenuClick('editComment', comment);}}>{_t.textEdit}</ActionsButton>}
{!comment.resolved ? {!comment.resolved && comment.editable ?
<ActionsButton onClick={() => {onCommentMenuClick('resolve', comment);}}>{_t.textResolve}</ActionsButton> : <ActionsButton onClick={() => {onCommentMenuClick('resolve', comment);}}>{_t.textResolve}</ActionsButton> :
<ActionsButton onClick={() => {onCommentMenuClick('resolve', comment);}}>{_t.textReopen}</ActionsButton> comment.editable && <ActionsButton onClick={() => {onCommentMenuClick('resolve', comment);}}>{_t.textReopen}</ActionsButton>
} }
<ActionsButton onClick={() => {onCommentMenuClick('addReply', comment);}}>{_t.textAddReply}</ActionsButton> <ActionsButton onClick={() => {onCommentMenuClick('addReply', comment);}}>{_t.textAddReply}</ActionsButton>
{comment.removable && <ActionsButton color='red' onClick={() => {onCommentMenuClick('deleteComment', comment);}}>{_t.textDeleteComment}</ActionsButton>} {comment.removable && <ActionsButton color='red' onClick={() => {onCommentMenuClick('deleteComment', comment);}}>{_t.textDeleteComment}</ActionsButton>}
@ -657,6 +657,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
<List className='comment-list'> <List className='comment-list'>
{sortComments.map((comment, indexComment) => { {sortComments.map((comment, indexComment) => {
return ( return (
!comment.hide &&
<ListItem key={`comment-${indexComment}`} onClick={e => { <ListItem key={`comment-${indexComment}`} onClick={e => {
!e.target.closest('.comment-menu') && !e.target.closest('.reply-menu') ? showComment(comment) : null}}> !e.target.closest('.comment-menu') && !e.target.closest('.reply-menu') ? showComment(comment) : null}}>
<div slot='header' className='comment-header'> <div slot='header' className='comment-header'>
@ -669,7 +670,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
</div> </div>
{!viewMode && {!viewMode &&
<div className='right'> <div className='right'>
<div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'} /></div> <div className='comment-resolve' onClick={() => {onResolveComment(comment);}}>{comment.editable && <Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'} />}</div>
<div className='comment-menu' <div className='comment-menu'
onClick={() => {setComment(comment); openActionComment(true);}} onClick={() => {setComment(comment); openActionComment(true);}}
><Icon icon='icon-menu-comment'/></div> ><Icon icon='icon-menu-comment'/></div>

View file

@ -113,6 +113,7 @@ export class storeAppOptions {
this.canComments = this.canComments && !((typeof (this.customization) == 'object') && this.customization.comments===false); this.canComments = this.canComments && !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canViewComments = this.canComments || !((typeof (this.customization) == 'object') && this.customization.comments===false); this.canViewComments = this.canComments || !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canEditComments = this.isOffline || !(typeof (this.customization) == 'object' && this.customization.commentAuthorOnly); this.canEditComments = this.isOffline || !(typeof (this.customization) == 'object' && this.customization.commentAuthorOnly);
this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
this.canChat = this.canLicense && !this.isOffline && !((typeof (this.customization) == 'object') && this.customization.chat === false); this.canChat = this.canLicense && !this.isOffline && !((typeof (this.customization) == 'object') && this.customization.chat === false);
this.canEditStyles = this.canLicense && this.canEdit; this.canEditStyles = this.canLicense && this.canEdit;
this.canPrint = (permissions.print !== false); this.canPrint = (permissions.print !== false);
@ -134,8 +135,11 @@ export class storeAppOptions {
if ( this.isLightVersion ) { if ( this.isLightVersion ) {
this.canUseHistory = this.canReview = this.isReviewOnly = false; this.canUseHistory = this.canReview = this.isReviewOnly = false;
} }
this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization
this.canUseReviewPermissions = this.canLicense && this.customization && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object'); && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object'));
this.canUseCommentPermissions = this.canLicense && !!permissions.commentGroups;
this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions);
this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups);
} }
setCanViewReview (value) { setCanViewReview (value) {
this.canViewReview = value; this.canViewReview = value;

View file

@ -91,6 +91,7 @@ export class storeAppOptions {
this.canComments = this.canComments && !((typeof (this.customization) == 'object') && this.customization.comments===false); this.canComments = this.canComments && !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canViewComments = this.canComments || !((typeof (this.customization) == 'object') && this.customization.comments===false); this.canViewComments = this.canComments || !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canEditComments = this.isOffline || !(typeof (this.customization) == 'object' && this.customization.commentAuthorOnly); this.canEditComments = this.isOffline || !(typeof (this.customization) == 'object' && this.customization.commentAuthorOnly);
this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
this.canChat = this.canLicense && !this.isOffline && !((typeof (this.customization) == 'object') && this.customization.chat === false); this.canChat = this.canLicense && !this.isOffline && !((typeof (this.customization) == 'object') && this.customization.chat === false);
this.canEditStyles = this.canLicense && this.canEdit; this.canEditStyles = this.canLicense && this.canEdit;
this.canPrint = (permissions.print !== false); this.canPrint = (permissions.print !== false);
@ -104,6 +105,10 @@ export class storeAppOptions {
this.canBranding = params.asc_getCustomization(); this.canBranding = params.asc_getCustomization();
this.canBrandingExt = params.asc_getCanBranding() && (typeof this.customization == 'object'); this.canBrandingExt = params.asc_getCanBranding() && (typeof this.customization == 'object');
this.canUseReviewPermissions = this.canLicense && this.customization && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object'); this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization
&& this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object'));
this.canUseCommentPermissions = this.canLicense && !!permissions.commentGroups;
this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions);
this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups);
} }
} }

View file

@ -91,6 +91,7 @@ export class storeAppOptions {
this.canComments = this.canComments && !((typeof (this.customization) == 'object') && this.customization.comments===false); this.canComments = this.canComments && !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canViewComments = this.canComments || !((typeof (this.customization) == 'object') && this.customization.comments===false); this.canViewComments = this.canComments || !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canEditComments = this.isOffline || !(typeof (this.customization) == 'object' && this.customization.commentAuthorOnly); this.canEditComments = this.isOffline || !(typeof (this.customization) == 'object' && this.customization.commentAuthorOnly);
this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
this.canChat = this.canLicense && !this.isOffline && !((typeof (this.customization) == 'object') && this.customization.chat === false); this.canChat = this.canLicense && !this.isOffline && !((typeof (this.customization) == 'object') && this.customization.chat === false);
this.canPrint = (permissions.print !== false); this.canPrint = (permissions.print !== false);
this.isRestrictedEdit = !this.isEdit && this.canComments; this.isRestrictedEdit = !this.isEdit && this.canComments;
@ -99,6 +100,10 @@ export class storeAppOptions {
this.canDownload = permissions.download !== false; this.canDownload = permissions.download !== false;
this.canBranding = params.asc_getCustomization(); this.canBranding = params.asc_getCustomization();
this.canBrandingExt = params.asc_getCanBranding() && (typeof this.customization == 'object'); this.canBrandingExt = params.asc_getCanBranding() && (typeof this.customization == 'object');
this.canUseReviewPermissions = this.canLicense && this.customization && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object'); this.canUseReviewPermissions = this.canLicense && (!!permissions.reviewGroups || this.customization
&& this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object'));
this.canUseCommentPermissions = this.canLicense && !!permissions.commentGroups;
this.canUseReviewPermissions && AscCommon.UserInfoParser.setReviewPermissions(permissions.reviewGroups, this.customization.reviewPermissions);
this.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(permissions.commentGroups);
} }
} }