Merge pull request #1707 from ONLYOFFICE/feature/fix-bug-react
Feature/fix bug react
This commit is contained in:
		
						commit
						991777e72f
					
				| 
						 | 
					@ -639,7 +639,7 @@ const ViewComments = inject("storeComments", "storeAppOptions", "storeReview")(o
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const viewMode = !storeAppOptions.canComments;
 | 
					    const viewMode = !storeAppOptions.canComments;
 | 
				
			||||||
    const comments = storeComments.groupCollectionFilter || storeComments.collectionComments;
 | 
					    const comments = storeComments.groupCollectionFilter || storeComments.collectionComments;
 | 
				
			||||||
    const isEdit = storeAppOptions.isEdit;
 | 
					    const isEdit = storeAppOptions.isEdit || storeAppOptions.isRestrictedEdit;
 | 
				
			||||||
    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 [clickComment, setComment] = useState();
 | 
				
			||||||
| 
						 | 
					@ -749,7 +749,7 @@ const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(ob
 | 
				
			||||||
    const displayMode = storeReview.displayMode;
 | 
					    const displayMode = storeReview.displayMode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const viewMode = !storeAppOptions.canComments;
 | 
					    const viewMode = !storeAppOptions.canComments;
 | 
				
			||||||
    const isEdit = storeAppOptions.isEdit;
 | 
					    const isEdit = storeAppOptions.isEdit || storeAppOptions.isRestrictedEdit;
 | 
				
			||||||
    const comments = storeComments.showComments;
 | 
					    const comments = storeComments.showComments;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [currentIndex, setCurrentIndex] = useState(0);
 | 
					    const [currentIndex, setCurrentIndex] = useState(0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -114,15 +114,20 @@ export class storeAppOptions {
 | 
				
			||||||
        this.canComments = this.canLicense && (permissions.comment === undefined ? this.isEdit : permissions.comment) && (this.config.mode !== 'view');
 | 
					        this.canComments = this.canLicense && (permissions.comment === undefined ? this.isEdit : permissions.comment) && (this.config.mode !== 'view');
 | 
				
			||||||
        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 || !permissions.editCommentAuthorOnly;
 | 
				
			||||||
        this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
 | 
					        this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
 | 
				
			||||||
 | 
					        if ((typeof (this.customization) == 'object') && this.customization.commentAuthorOnly===true) {
 | 
				
			||||||
 | 
					            console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
 | 
				
			||||||
 | 
					            if (permissions.editCommentAuthorOnly===undefined && permissions.deleteCommentAuthorOnly===undefined)
 | 
				
			||||||
 | 
					                this.canEditComments = this.canDeleteComments = this.isOffline;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        this.canChat = this.canLicense && !this.isOffline && (permissions.chat !== false);
 | 
					        this.canChat = this.canLicense && !this.isOffline && (permissions.chat !== false);
 | 
				
			||||||
        this.canEditStyles = this.canLicense && this.canEdit;
 | 
					        this.canEditStyles = this.canLicense && this.canEdit;
 | 
				
			||||||
        this.canPrint = (permissions.print !== false);
 | 
					        this.canPrint = (permissions.print !== false);
 | 
				
			||||||
        this.fileKey = document.key;
 | 
					        this.fileKey = document.key;
 | 
				
			||||||
        const typeForm = /^(?:(oform))$/.exec(document.fileType); // can fill forms only in oform format
 | 
					        const typeForm = /^(?:(oform))$/.exec(document.fileType); // can fill forms only in oform format
 | 
				
			||||||
        this.canFillForms = this.canLicense && !!(typeForm && typeof typeForm[1] === 'string') && ((permissions.fillForms===undefined) ? this.isEdit : permissions.fillForms) && (this.config.mode !== 'view');
 | 
					        this.canFillForms = this.canLicense && !!(typeForm && typeof typeForm[1] === 'string') && ((permissions.fillForms===undefined) ? this.isEdit : permissions.fillForms) && (this.config.mode !== 'view');
 | 
				
			||||||
        this.isRestrictedEdit = !this.isEdit && (this.canComments || this.canFillForms);
 | 
					        this.isRestrictedEdit = !this.isEdit && (this.canComments || this.canFillForms) && isSupportEditFeature;
 | 
				
			||||||
        if (this.isRestrictedEdit && this.canComments && this.canFillForms) // must be one restricted mode, priority for filling forms
 | 
					        if (this.isRestrictedEdit && this.canComments && this.canFillForms) // must be one restricted mode, priority for filling forms
 | 
				
			||||||
            this.canComments = false;
 | 
					            this.canComments = false;
 | 
				
			||||||
        this.trialMode = params.asc_getLicenseMode();
 | 
					        this.trialMode = params.asc_getLicenseMode();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,12 +94,17 @@ export class storeAppOptions {
 | 
				
			||||||
        this.canComments = this.canLicense && (permissions.comment === undefined ? this.isEdit : permissions.comment) && (this.config.mode !== 'view');
 | 
					        this.canComments = this.canLicense && (permissions.comment === undefined ? this.isEdit : permissions.comment) && (this.config.mode !== 'view');
 | 
				
			||||||
        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 || !permissions.editCommentAuthorOnly;
 | 
				
			||||||
        this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
 | 
					        this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
 | 
				
			||||||
 | 
					        if ((typeof (this.customization) == 'object') && this.customization.commentAuthorOnly===true) {
 | 
				
			||||||
 | 
					            console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
 | 
				
			||||||
 | 
					            if (permissions.editCommentAuthorOnly===undefined && permissions.deleteCommentAuthorOnly===undefined)
 | 
				
			||||||
 | 
					                this.canEditComments = this.canDeleteComments = this.isOffline;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        this.canChat = this.canLicense && !this.isOffline && (permissions.chat !== false);
 | 
					        this.canChat = this.canLicense && !this.isOffline && (permissions.chat !== false);
 | 
				
			||||||
        this.canEditStyles = this.canLicense && this.canEdit;
 | 
					        this.canEditStyles = this.canLicense && this.canEdit;
 | 
				
			||||||
        this.canPrint = (permissions.print !== false);
 | 
					        this.canPrint = (permissions.print !== false);
 | 
				
			||||||
        this.isRestrictedEdit = !this.isEdit && this.canComments;
 | 
					        this.isRestrictedEdit = !this.isEdit && this.canComments && isSupportEditFeature;
 | 
				
			||||||
        this.trialMode = params.asc_getLicenseMode();
 | 
					        this.trialMode = params.asc_getLicenseMode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType);
 | 
					        const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,7 @@ import EditorUIController from '../lib/patch';
 | 
				
			||||||
    canComments: stores.storeAppOptions.canComments,
 | 
					    canComments: stores.storeAppOptions.canComments,
 | 
				
			||||||
    canViewComments: stores.storeAppOptions.canViewComments,
 | 
					    canViewComments: stores.storeAppOptions.canViewComments,
 | 
				
			||||||
    canCoAuthoring: stores.storeAppOptions.canCoAuthoring,
 | 
					    canCoAuthoring: stores.storeAppOptions.canCoAuthoring,
 | 
				
			||||||
 | 
					    isRestrictedEdit: stores.storeAppOptions.isRestrictedEdit,
 | 
				
			||||||
    users: stores.users,
 | 
					    users: stores.users,
 | 
				
			||||||
    isDisconnected: stores.users.isDisconnected,
 | 
					    isDisconnected: stores.users.isDisconnected,
 | 
				
			||||||
    storeSheets: stores.sheets,
 | 
					    storeSheets: stores.sheets,
 | 
				
			||||||
| 
						 | 
					@ -215,12 +216,12 @@ class ContextMenu extends ContextMenuController {
 | 
				
			||||||
        const { t } = this.props;
 | 
					        const { t } = this.props;
 | 
				
			||||||
        const _t = t("ContextMenu", { returnObjects: true });
 | 
					        const _t = t("ContextMenu", { returnObjects: true });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const { isEdit, isDisconnected } = this.props;
 | 
					        const { isEdit, isRestrictedEdit, isDisconnected } = this.props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isEdit && EditorUIController.ContextMenu) {
 | 
					        if (isEdit && EditorUIController.ContextMenu) {
 | 
				
			||||||
            return EditorUIController.ContextMenu.mapMenuItems(this);
 | 
					            return EditorUIController.ContextMenu.mapMenuItems(this);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            const {canViewComments} = this.props;
 | 
					            const {canViewComments, canCoAuthoring, canComments} = this.props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const api = Common.EditorApi.get();
 | 
					            const api = Common.EditorApi.get();
 | 
				
			||||||
            const cellinfo = api.asc_getCellInfo();
 | 
					            const cellinfo = api.asc_getCellInfo();
 | 
				
			||||||
| 
						 | 
					@ -262,6 +263,13 @@ class ContextMenu extends ContextMenuController {
 | 
				
			||||||
                            event: 'viewcomment'
 | 
					                            event: 'viewcomment'
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (iscellmenu && !api.isCellEdited && isRestrictedEdit && canCoAuthoring && canComments && hasComments && hasComments.length<1) {
 | 
				
			||||||
 | 
					                        itemsText.push({
 | 
				
			||||||
 | 
					                            caption: _t.menuAddComment,
 | 
				
			||||||
 | 
					                            event: 'addcomment'
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return itemsIcon.concat(itemsText);
 | 
					            return itemsIcon.concat(itemsText);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,11 +94,16 @@ export class storeAppOptions {
 | 
				
			||||||
        this.canComments = this.canLicense && (permissions.comment === undefined ? this.isEdit : permissions.comment) && (this.config.mode !== 'view');
 | 
					        this.canComments = this.canLicense && (permissions.comment === undefined ? this.isEdit : permissions.comment) && (this.config.mode !== 'view');
 | 
				
			||||||
        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 || !permissions.editCommentAuthorOnly;
 | 
				
			||||||
        this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
 | 
					        this.canDeleteComments= this.isOffline || !permissions.deleteCommentAuthorOnly;
 | 
				
			||||||
 | 
					        if ((typeof (this.customization) == 'object') && this.customization.commentAuthorOnly===true) {
 | 
				
			||||||
 | 
					            console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
 | 
				
			||||||
 | 
					            if (permissions.editCommentAuthorOnly===undefined && permissions.deleteCommentAuthorOnly===undefined)
 | 
				
			||||||
 | 
					                this.canEditComments = this.canDeleteComments = this.isOffline;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        this.canChat = this.canLicense && !this.isOffline && (permissions.chat !== false);
 | 
					        this.canChat = this.canLicense && !this.isOffline && (permissions.chat !== false);
 | 
				
			||||||
        this.canPrint = (permissions.print !== false);
 | 
					        this.canPrint = (permissions.print !== false);
 | 
				
			||||||
        this.isRestrictedEdit = !this.isEdit && this.canComments;
 | 
					        this.isRestrictedEdit = !this.isEdit && this.canComments && isSupportEditFeature;
 | 
				
			||||||
        this.trialMode = params.asc_getLicenseMode();
 | 
					        this.trialMode = params.asc_getLicenseMode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType);
 | 
					        const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue