From d02582e18b7ba9d1ff0af99d19c1edeb4b0a0fa2 Mon Sep 17 00:00:00 2001 From: Rodrigo Quelca Date: Thu, 1 Aug 2024 14:33:41 -0400 Subject: [PATCH 1/2] FOUR-17488: Back redirection on element destination with external URL is not correct --- src/components/task.vue | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/components/task.vue b/src/components/task.vue index 507ae99ab..bc1a30f90 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -455,6 +455,7 @@ export default { const elementDestinationUrl = elementDestination.value; if (elementDestinationUrl) { + sessionStorage.setItem('sessionUrlActionBlocker', document.referrer); return elementDestinationUrl; } @@ -797,6 +798,30 @@ export default { requestIdNode.setAttribute('content', this.requestId); } }, + /** + * Checks for the presence of a URL action blocker in sessionStorage and handles it. + * + * This method retrieves the 'sessionUrlActionBlocker' value from sessionStorage, + * and if present, removes it and emits a 'closed' event with the task id and + * the source of the redirection. It returns false if the blocker was handled, + * and true otherwise. + * + * @returns {boolean} Returns false if the 'sessionUrlActionBlocker' was found and handled, true otherwise. + */ + hasUrlActionBloker() { + // Retrieve the 'sessionUrlActionBlocker' value from sessionStorage + const redirectedFrom = sessionStorage.getItem("sessionUrlActionBlocker"); + + if (redirectedFrom) { + // Remove 'sessionUrlActionBlocker' from sessionStorage after retrieving its value + sessionStorage.removeItem("sessionUrlActionBlocker"); + + // Emit a 'closed' event with the task id and the source of the redirection + this.$emit("closed", this.task?.id, redirectedFrom); + return true; + } + return false; + }, }, mounted() { @@ -807,7 +832,9 @@ export default { this.nodeId = this.initialNodeId; this.requestData = this.value; this.loopContext = this.initialLoopContext; - this.loadTask(); + if (!this.hasUrlActionBloker()) { + this.loadTask(); + } }, destroyed() { this.unsubscribeSocketListeners(); From e083ed7cd8278c084633259af099ff0261ccdf01 Mon Sep 17 00:00:00 2001 From: Rodrigo Quelca Date: Thu, 1 Aug 2024 21:01:28 -0400 Subject: [PATCH 2/2] fix code review notes --- src/components/task.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/task.vue b/src/components/task.vue index bc1a30f90..7a0bf3bd7 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -455,6 +455,7 @@ export default { const elementDestinationUrl = elementDestination.value; if (elementDestinationUrl) { + // Save the referring URL to sessionStorage for future verification sessionStorage.setItem('sessionUrlActionBlocker', document.referrer); return elementDestinationUrl; } @@ -808,7 +809,7 @@ export default { * * @returns {boolean} Returns false if the 'sessionUrlActionBlocker' was found and handled, true otherwise. */ - hasUrlActionBloker() { + hasUrlActionBlocker() { // Retrieve the 'sessionUrlActionBlocker' value from sessionStorage const redirectedFrom = sessionStorage.getItem("sessionUrlActionBlocker"); @@ -832,7 +833,7 @@ export default { this.nodeId = this.initialNodeId; this.requestData = this.value; this.loopContext = this.initialLoopContext; - if (!this.hasUrlActionBloker()) { + if (!this.hasUrlActionBlocker()) { this.loadTask(); } },