Merge pull request #967 from ONLYOFFICE/feature/access-to-comments
Feature/access to comments
This commit is contained in:
commit
60f2c149e3
|
@ -77,7 +77,7 @@ class CommentsController extends Component {
|
|||
const api = Common.EditorApi.get();
|
||||
/** coauthoring begin **/
|
||||
const isLiveCommenting = LocalStorage.getBool(`${window.editorType}-mobile-settings-livecomment`, true);
|
||||
const resolved = LocalStorage.getBool(`${window.editorType}-settings-resolvedcomment`, true);
|
||||
const resolved = LocalStorage.getBool(`${window.editorType}-settings-resolvedcomment`);
|
||||
this.storeApplicationSettings.changeDisplayComments(isLiveCommenting);
|
||||
this.storeApplicationSettings.changeDisplayResolved(resolved);
|
||||
isLiveCommenting ? api.asc_showComments(resolved) : api.asc_hideComments();
|
||||
|
@ -139,8 +139,9 @@ class CommentsController extends Component {
|
|||
changeComment.quote = data.asc_getQuoteText();
|
||||
changeComment.time = date.getTime();
|
||||
changeComment.date = dateToLocaleTimeString(date);
|
||||
changeComment.editable = this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId);
|
||||
changeComment.removable = this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId);
|
||||
changeComment.editable = (this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(name);
|
||||
changeComment.removable = (this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(name);
|
||||
changeComment.hide = !AscCommon.UserInfoParser.canViewComment(name);
|
||||
|
||||
let dateReply = null;
|
||||
const replies = [];
|
||||
|
@ -164,8 +165,8 @@ class CommentsController extends Component {
|
|||
reply: data.asc_getReply(i).asc_getText(),
|
||||
time: dateReply.getTime(),
|
||||
userInitials: this.usersStore.getInitials(parsedName),
|
||||
editable: this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId),
|
||||
removable: this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)
|
||||
editable: (this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(userName),
|
||||
removable: (this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(userName)
|
||||
});
|
||||
}
|
||||
changeComment.replies = replies;
|
||||
|
@ -197,8 +198,9 @@ class CommentsController extends Component {
|
|||
replies : [],
|
||||
groupName : (groupName && groupName.length>1) ? groupName[1] : null,
|
||||
userInitials : this.usersStore.getInitials(parsedName),
|
||||
editable : this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId),
|
||||
removable : this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId)
|
||||
editable : (this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(userName),
|
||||
removable : (this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(userName),
|
||||
hide : !AscCommon.UserInfoParser.canViewComment(userName),
|
||||
};
|
||||
if (comment) {
|
||||
const replies = this.readSDKReplies(data);
|
||||
|
@ -230,8 +232,8 @@ class CommentsController extends Component {
|
|||
reply : data.asc_getReply(i).asc_getText(),
|
||||
time : date.getTime(),
|
||||
userInitials : this.usersStore.getInitials(parsedName),
|
||||
editable : this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId),
|
||||
removable : this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)
|
||||
editable : (this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canEditComment(userName),
|
||||
removable : (this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)) && AscCommon.UserInfoParser.canDeleteComment(userName)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -493,6 +495,7 @@ class ViewCommentsController extends Component {
|
|||
});
|
||||
}
|
||||
const api = Common.EditorApi.get();
|
||||
api.asc_showComments(this.props.storeApplicationSettings.isResolvedComments);
|
||||
api.asc_changeComment(comment.uid, ascComment);
|
||||
|
||||
if(!this.props.storeApplicationSettings.isResolvedComments) {
|
||||
|
|
|
@ -80,6 +80,7 @@ export class storeComments {
|
|||
comment.editable = changeComment.editable;
|
||||
comment.removable = changeComment.removable;
|
||||
comment.replies = changeComment.replies;
|
||||
comment.hide =changeComment.hide;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -148,9 +148,9 @@ const CommentActions = ({comment, onCommentMenuClick, opened, openActionComment}
|
|||
<ActionsGroup>
|
||||
{comment && <Fragment>
|
||||
{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.textReopen}</ActionsButton>
|
||||
comment.editable && <ActionsButton onClick={() => {onCommentMenuClick('resolve', comment);}}>{_t.textReopen}</ActionsButton>
|
||||
}
|
||||
<ActionsButton onClick={() => {onCommentMenuClick('addReply', comment);}}>{_t.textAddReply}</ActionsButton>
|
||||
{comment.removable && <ActionsButton color='red' onClick={() => {onCommentMenuClick('deleteComment', comment);}}>{_t.textDeleteComment}</ActionsButton>}
|
||||
|
@ -635,7 +635,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
|||
|
||||
const viewMode = !storeAppOptions.canComments;
|
||||
const comments = storeComments.groupCollectionFilter || storeComments.collectionComments;
|
||||
const sortComments = comments.length > 0 ? [...comments].sort((a, b) => a.time > b.time ? 1 : -1) : null;
|
||||
const sortComments = comments.length > 0 ? [...comments].sort((a, b) => a.time > b.time ? -1 : 1) : null;
|
||||
|
||||
const [clickComment, setComment] = useState();
|
||||
const [commentActionsOpened, openActionComment] = useState(false);
|
||||
|
@ -659,6 +659,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
|||
<List className='comment-list'>
|
||||
{sortComments.map((comment, indexComment) => {
|
||||
return (
|
||||
!comment.hide &&
|
||||
<ListItem key={`comment-${indexComment}`} onClick={e => {
|
||||
!e.target.closest('.comment-menu') && !e.target.closest('.reply-menu') ? showComment(comment) : null}}>
|
||||
<div slot='header' className='comment-header'>
|
||||
|
@ -671,7 +672,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
|||
</div>
|
||||
{!viewMode &&
|
||||
<div className='right'>
|
||||
<div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'} /></div>
|
||||
{comment.editable && <div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'} /></div> }
|
||||
<div className='comment-menu'
|
||||
onClick={() => {setComment(comment); openActionComment(true);}}
|
||||
><Icon icon='icon-menu-comment'/></div>
|
||||
|
@ -699,7 +700,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
|||
<div className='reply-date'>{reply.date}</div>
|
||||
</div>
|
||||
</div>
|
||||
{!viewMode &&
|
||||
{!viewMode && reply.editable &&
|
||||
<div className='right'>
|
||||
<div className='reply-menu'
|
||||
onClick={() => {setComment(comment); setReply(reply); openActionReply(true);}}
|
||||
|
@ -800,7 +801,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
|
|||
</div>
|
||||
{!viewMode &&
|
||||
<div className='right'>
|
||||
<div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'} /></div>
|
||||
{comment.editable && <div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'}/></div>}
|
||||
<div className='comment-menu'
|
||||
onClick={() => {openActionComment(true);}}
|
||||
><Icon icon='icon-menu-comment'/></div>
|
||||
|
@ -828,7 +829,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
|
|||
<div className='reply-date'>{reply.date}</div>
|
||||
</div>
|
||||
</div>
|
||||
{!viewMode &&
|
||||
{!viewMode && reply.editable &&
|
||||
<div className='right'>
|
||||
<div className='reply-menu'
|
||||
onClick={() => {setReply(reply); openActionReply(true);}}
|
||||
|
|
|
@ -56,8 +56,11 @@
|
|||
padding-right: 16px;
|
||||
.right {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
justify-content: flex-end;
|
||||
width: 70px;
|
||||
.comment-resolve {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.reply-header {
|
||||
|
|
|
@ -51,7 +51,7 @@ class ApplicationSettingsController extends Component {
|
|||
}
|
||||
|
||||
switchDisplayResolved(value) {
|
||||
const displayComments = LocalStorage.getBool("de-mobile-settings-livecomment");
|
||||
const displayComments = LocalStorage.getBool("de-mobile-settings-livecomment",true);
|
||||
if (displayComments) {
|
||||
Common.EditorApi.get().asc_showComments(value);
|
||||
LocalStorage.setBool("de-settings-resolvedcomment", value);
|
||||
|
|
|
@ -113,6 +113,7 @@ export class storeAppOptions {
|
|||
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.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.canEditStyles = this.canLicense && this.canEdit;
|
||||
this.canPrint = (permissions.print !== false);
|
||||
|
@ -134,8 +135,11 @@ export class storeAppOptions {
|
|||
if ( this.isLightVersion ) {
|
||||
this.canUseHistory = this.canReview = this.isReviewOnly = false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
setCanViewReview (value) {
|
||||
this.canViewReview = value;
|
||||
|
|
|
@ -91,6 +91,7 @@ export class storeAppOptions {
|
|||
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.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.canEditStyles = this.canLicense && this.canEdit;
|
||||
this.canPrint = (permissions.print !== false);
|
||||
|
@ -104,6 +105,10 @@ export class storeAppOptions {
|
|||
this.canBranding = params.asc_getCustomization();
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ class ApplicationSettingsController extends Component {
|
|||
|
||||
onChangeDisplayResolved(value) {
|
||||
const api = Common.EditorApi.get();
|
||||
let displayComments = LocalStorage.getBool("sse-mobile-settings-livecomment");
|
||||
let displayComments = LocalStorage.getBool("sse-mobile-settings-livecomment",true);
|
||||
|
||||
if (displayComments) {
|
||||
api.asc_showComments(value);
|
||||
|
|
|
@ -91,6 +91,7 @@ export class storeAppOptions {
|
|||
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.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.canPrint = (permissions.print !== false);
|
||||
this.isRestrictedEdit = !this.isEdit && this.canComments;
|
||||
|
@ -99,6 +100,10 @@ export class storeAppOptions {
|
|||
this.canDownload = permissions.download !== false;
|
||||
this.canBranding = params.asc_getCustomization();
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue