Merge pull request #1707 from ONLYOFFICE/feature/fix-bug-react

Feature/fix bug react
This commit is contained in:
maxkadushkin 2022-04-20 15:00:14 +03:00 committed by GitHub
commit 991777e72f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 10 deletions

View file

@ -639,7 +639,7 @@ const ViewComments = inject("storeComments", "storeAppOptions", "storeReview")(o
const viewMode = !storeAppOptions.canComments;
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 [clickComment, setComment] = useState();
@ -749,7 +749,7 @@ const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(ob
const displayMode = storeReview.displayMode;
const viewMode = !storeAppOptions.canComments;
const isEdit = storeAppOptions.isEdit;
const isEdit = storeAppOptions.isEdit || storeAppOptions.isRestrictedEdit;
const comments = storeComments.showComments;
const [currentIndex, setCurrentIndex] = useState(0);

View file

@ -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.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;
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.canEditStyles = this.canLicense && this.canEdit;
this.canPrint = (permissions.print !== false);
this.fileKey = document.key;
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.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
this.canComments = false;
this.trialMode = params.asc_getLicenseMode();

View file

@ -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.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;
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.canEditStyles = this.canLicense && this.canEdit;
this.canPrint = (permissions.print !== false);
this.isRestrictedEdit = !this.isEdit && this.canComments;
this.isRestrictedEdit = !this.isEdit && this.canComments && isSupportEditFeature;
this.trialMode = params.asc_getLicenseMode();
const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType);

View file

@ -14,6 +14,7 @@ import EditorUIController from '../lib/patch';
canComments: stores.storeAppOptions.canComments,
canViewComments: stores.storeAppOptions.canViewComments,
canCoAuthoring: stores.storeAppOptions.canCoAuthoring,
isRestrictedEdit: stores.storeAppOptions.isRestrictedEdit,
users: stores.users,
isDisconnected: stores.users.isDisconnected,
storeSheets: stores.sheets,
@ -215,12 +216,12 @@ class ContextMenu extends ContextMenuController {
const { t } = this.props;
const _t = t("ContextMenu", { returnObjects: true });
const { isEdit, isDisconnected } = this.props;
const { isEdit, isRestrictedEdit, isDisconnected } = this.props;
if (isEdit && EditorUIController.ContextMenu) {
return EditorUIController.ContextMenu.mapMenuItems(this);
} else {
const {canViewComments} = this.props;
const {canViewComments, canCoAuthoring, canComments} = this.props;
const api = Common.EditorApi.get();
const cellinfo = api.asc_getCellInfo();
@ -262,6 +263,13 @@ class ContextMenu extends ContextMenuController {
event: 'viewcomment'
});
}
if (iscellmenu && !api.isCellEdited && isRestrictedEdit && canCoAuthoring && canComments && hasComments && hasComments.length<1) {
itemsText.push({
caption: _t.menuAddComment,
event: 'addcomment'
});
}
}
return itemsIcon.concat(itemsText);

View file

@ -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.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;
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.canPrint = (permissions.print !== false);
this.isRestrictedEdit = !this.isEdit && this.canComments;
this.isRestrictedEdit = !this.isEdit && this.canComments && isSupportEditFeature;
this.trialMode = params.asc_getLicenseMode();
const type = /^(?:(pdf|djvu|xps|oxps))$/.exec(document.fileType);