From f2d4e4b2a33da51bf1b43efb9373f41b57d79b40 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 20 May 2022 13:24:17 +0300 Subject: [PATCH] [PE][SSE] Bug 54642: handle several macros requests --- .../main/app/controller/Main.js | 54 ++++++++++++++---- apps/presentationeditor/main/locale/en.json | 1 + .../main/app/controller/Main.js | 55 +++++++++++++++---- apps/spreadsheeteditor/main/locale/en.json | 1 + 4 files changed, 88 insertions(+), 23 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 6a7d57c8bc..ecb54b58b9 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -152,6 +152,7 @@ define([ strongCompare : function(obj1, obj2){return obj1.type === obj2.type;}, weakCompare : function(obj1, obj2){return obj1.type === obj2.type;} }); + this.stackMacrosRequests = []; // Initialize viewport if (!Common.Utils.isBrowserSupported()){ @@ -393,6 +394,9 @@ define([ value = parseInt(value); Common.Utils.InternalSettings.set("pe-macros-mode", value); + value = Common.localStorage.getItem("pe-allow-macros-request"); + Common.Utils.InternalSettings.set("pe-allow-macros-request", (value !== null) ? parseInt(value) : 0); + this.appOptions.wopi = this.editorConfig.wopi; Common.Controllers.Desktop.init(this.appOptions); @@ -2282,17 +2286,44 @@ define([ }, onMacrosPermissionRequest: function(url, callback) { - Common.UI.warning({ - msg: this.textRequestMacros.replace('%1', url), - buttons: ['yes', 'no'], - primary: 'yes', - maxwidth: 600, - callback: function(btn){ - setTimeout(function() { - if (callback) callback(btn == 'yes'); - }, 1); + if (url && callback) { + this.stackMacrosRequests.push({url: url, callback: callback}); + if (this.stackMacrosRequests.length>1) { + return; } - }); + } else if (this.stackMacrosRequests.length>0) { + url = this.stackMacrosRequests[0].url; + callback = this.stackMacrosRequests[0].callback; + } else + return; + + var me = this; + var value = Common.Utils.InternalSettings.get("pe-allow-macros-request"); + if (value>0) { + callback && callback(value === 1); + this.stackMacrosRequests.shift(); + this.onMacrosPermissionRequest(); + } else { + Common.UI.warning({ + msg: this.textRequestMacros.replace('%1', url), + buttons: ['yes', 'no'], + primary: 'yes', + dontshow: true, + textDontShow: this.textRememberMacros, + maxwidth: 600, + callback: function(btn, dontshow){ + if (dontshow) { + Common.Utils.InternalSettings.set("pe-allow-macros-request", (btn == 'yes') ? 1 : 2); + Common.localStorage.setItem("pe-allow-macros-request", (btn == 'yes') ? 1 : 2); + } + setTimeout(function() { + if (callback) callback(btn == 'yes'); + me.stackMacrosRequests.shift(); + me.onMacrosPermissionRequest(); + }, 1); + } + }); + } }, loadAutoCorrectSettings: function() { @@ -2949,7 +2980,8 @@ define([ textApplyAll: 'Apply to all equations', textLearnMore: 'Learn More', textReconnect: 'Connection is restored', - textRequestMacros: 'A macro makes a request to URL. Do you want to allow the request to the %1?' + textRequestMacros: 'A macro makes a request to URL. Do you want to allow the request to the %1?', + textRememberMacros: 'Remember my choice for all macros' } })(), PE.Controllers.Main || {})) }); diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 590c888a09..66d8d05984 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -680,6 +680,7 @@ "PE.Controllers.Main.textPaidFeature": "Paid feature", "PE.Controllers.Main.textReconnect": "Connection is restored", "PE.Controllers.Main.textRemember": "Remember my choice for all files", + "PE.Controllers.Main.textRememberMacros": "Remember my choice for all macros", "PE.Controllers.Main.textRenameError": "User name must not be empty.", "PE.Controllers.Main.textRenameLabel": "Enter a name to be used for collaboration", "PE.Controllers.Main.textShape": "Shape", diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 3ab75dad51..778a8bc056 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -230,7 +230,7 @@ define([ strongCompare : this._compareActionWeak, weakCompare : this._compareActionWeak }); - + this.stackMacrosRequests = []; this.isShowOpenDialog = false; // Initialize api gateway @@ -463,6 +463,9 @@ define([ value = parseInt(value); Common.Utils.InternalSettings.set("sse-macros-mode", value); + value = Common.localStorage.getItem("sse-allow-macros-request"); + Common.Utils.InternalSettings.set("sse-allow-macros-request", (value !== null) ? parseInt(value) : 0); + this.appOptions.wopi = this.editorConfig.wopi; this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); @@ -2843,17 +2846,44 @@ define([ }, onMacrosPermissionRequest: function(url, callback) { - Common.UI.warning({ - msg: this.textRequestMacros.replace('%1', url), - buttons: ['yes', 'no'], - primary: 'yes', - maxwidth: 600, - callback: function(btn){ - setTimeout(function() { - if (callback) callback(btn == 'yes'); - }, 1); + if (url && callback) { + this.stackMacrosRequests.push({url: url, callback: callback}); + if (this.stackMacrosRequests.length>1) { + return; } - }); + } else if (this.stackMacrosRequests.length>0) { + url = this.stackMacrosRequests[0].url; + callback = this.stackMacrosRequests[0].callback; + } else + return; + + var me = this; + var value = Common.Utils.InternalSettings.get("sse-allow-macros-request"); + if (value>0) { + callback && callback(value === 1); + this.stackMacrosRequests.shift(); + this.onMacrosPermissionRequest(); + } else { + Common.UI.warning({ + msg: this.textRequestMacros.replace('%1', url), + buttons: ['yes', 'no'], + primary: 'yes', + dontshow: true, + textDontShow: this.textRememberMacros, + maxwidth: 600, + callback: function(btn, dontshow){ + if (dontshow) { + Common.Utils.InternalSettings.set("sse-allow-macros-request", (btn == 'yes') ? 1 : 2); + Common.localStorage.setItem("sse-allow-macros-request", (btn == 'yes') ? 1 : 2); + } + setTimeout(function() { + if (callback) callback(btn == 'yes'); + me.stackMacrosRequests.shift(); + me.onMacrosPermissionRequest(); + }, 1); + } + }); + } }, loadAutoCorrectSettings: function() { @@ -3553,7 +3583,8 @@ define([ textFormulaFilledFirstRowsOtherHaveData: 'Formula filled only first {0} rows have data by memory save reason. There are other {1} rows have data in this sheet. You can fill them manually.', textReconnect: 'Connection is restored', errorCannotUseCommandProtectedSheet: 'You cannot use this command on a protected sheet. To use this command, unprotect the sheet.
You might be requested to enter a password.', - textRequestMacros: 'A macro makes a request to URL. Do you want to allow the request to the %1?' + textRequestMacros: 'A macro makes a request to URL. Do you want to allow the request to the %1?', + textRememberMacros: 'Remember my choice for all macros' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 0316bf8207..527070c362 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -788,6 +788,7 @@ "SSE.Controllers.Main.textPleaseWait": "The operation might take more time than expected. Please wait...", "SSE.Controllers.Main.textReconnect": "Connection is restored", "SSE.Controllers.Main.textRemember": "Remember my choice for all files", + "SSE.Controllers.Main.textRememberMacros": "Remember my choice for all macros", "SSE.Controllers.Main.textRenameError": "User name must not be empty.", "SSE.Controllers.Main.textRenameLabel": "Enter a name to be used for collaboration", "SSE.Controllers.Main.textShape": "Shape",