From 59c658ecab0067ad1abb8d61ad6bdba0ccdc90ae Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 13 May 2021 00:57:01 +0300 Subject: [PATCH] Wopi: change config parameters and post messages --- apps/api/wopi/editor-wopi.ejs | 30 ++++++++++++------- .../main/lib/controller/ReviewChanges.js | 24 +++++++-------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/apps/api/wopi/editor-wopi.ejs b/apps/api/wopi/editor-wopi.ejs index 989622144..98f6881f8 100644 --- a/apps/api/wopi/editor-wopi.ejs +++ b/apps/api/wopi/editor-wopi.ejs @@ -68,6 +68,7 @@ div { var documentChanged; var sendNotificationTimer; var sessionId; + var fileInfo; var innerAlert = function (message) { if (console && console.log) @@ -165,15 +166,24 @@ div { }; var onRequestClose = function () { - _postMessage('UI_Close', {}); + if (fileInfo.ClosePostMessage) + _postMessage('UI_Close', {}); + else if (fileInfo.CloseUrl) + window.parent.location.href = fileInfo.CloseUrl; }; var onRequestEditRights = function () { - _postMessage('UI_Edit', {}); + if (fileInfo.EditModePostMessage) + _postMessage('UI_Edit', {}); + else if (fileInfo.HostEditUrl) + window.open(fileInfo.HostEditUrl, "_blank"); }; var requestSharingSettings = function (event) { - _postMessage('UI_Sharing', {}); + if (fileInfo.FileSharingPostMessage) + _postMessage('UI_Sharing', {}); + else if (fileInfo.FileSharingUrl) + window.open(fileInfo.FileSharingUrl, "_blank"); }; var onError = function (event) { @@ -182,9 +192,10 @@ div { }; var connectEditor = function () { - + + fileInfo = <%- JSON.stringify(fileInfo) %>; + var key = "<%- key %>"; - var fileInfo = <%- JSON.stringify(fileInfo) %>; var userAuth = <%- JSON.stringify(userAuth) %>; var token = "<%- token %>"; var queryParams = <%- JSON.stringify(queryParams) %>; @@ -208,7 +219,7 @@ div { "edit": !fileInfo.ReadOnly && fileInfo.UserCanWrite, "review": (fileInfo.SupportsReviewing===false) ? false : (fileInfo.UserCanReview===false ? false : fileInfo.UserCanReview), "copy": fileInfo.CopyPasteRestrictions!=="CurrentDocumentOnly" && fileInfo.CopyPasteRestrictions!=="BlockAll", - "print": !fileInfo.DisablePrint + "print": !fileInfo.DisablePrint && !fileInfo.HidePrintOption } }, "editorConfig": { @@ -216,7 +227,6 @@ div { "lang": queryParams.lang || queryParams.ui || "en-US", "region": queryParams.rs, "callbackUrl": JSON.stringify(userAuth), - "sharingSettingsUrl": fileInfo.FileSharingUrl, "user": { "id": fileInfo.UserId, "name": fileInfo.IsAnonymousUser ? "" : fileInfo.UserFriendlyName @@ -244,11 +254,11 @@ div { "events": { "onAppReady": onAppReady, "onDocumentStateChange": fileInfo.EditNotificationPostMessage ? onDocumentStateChange : undefined, - 'onRequestEditRights': fileInfo.EditModePostMessage ? onRequestEditRights : undefined, + 'onRequestEditRights': fileInfo.EditModePostMessage || fileInfo.HostEditUrl ? onRequestEditRights : undefined, "onError": onError, - "onRequestClose": fileInfo.ClosePostMessage ? onRequestClose : undefined, + "onRequestClose": fileInfo.ClosePostMessage || fileInfo.CloseUrl ? onRequestClose : undefined, "onRequestRename": fileInfo.SupportsRename && fileInfo.UserCanRename ? onRequestRename : undefined, - "onRequestSharingSettings": fileInfo.FileSharingPostMessage ? requestSharingSettings : undefined + "onRequestSharingSettings": fileInfo.FileSharingPostMessage || fileInfo.FileSharingUrl ? requestSharingSettings : undefined } }; diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 23e95988a..28b169af6 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -905,21 +905,17 @@ define([ if (this.appConfig.canRequestSharingSettings) { Common.Gateway.requestSharingSettings(); } else { - if (this.appConfig.wopi) { - window.open(this.appConfig.sharingSettingsUrl, "_blank"); - } else { - var me = this; - me._docAccessDlg = new Common.Views.DocumentAccessDialog({ - settingsurl: this.appConfig.sharingSettingsUrl - }); - me._docAccessDlg.on('accessrights', function(obj, rights){ - me.setSharingSettings({sharingSettings: rights}); - }).on('close', function(obj){ - me._docAccessDlg = undefined; - }); + var me = this; + me._docAccessDlg = new Common.Views.DocumentAccessDialog({ + settingsurl: this.appConfig.sharingSettingsUrl + }); + me._docAccessDlg.on('accessrights', function(obj, rights){ + me.setSharingSettings({sharingSettings: rights}); + }).on('close', function(obj){ + me._docAccessDlg = undefined; + }); - me._docAccessDlg.show(); - } + me._docAccessDlg.show(); } },