From 29fe7ef1d86af55a8218c7282c936d99cf3294d2 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Wed, 28 Sep 2022 13:49:35 +0100 Subject: [PATCH 1/3] Add screen input to CloseScreenModal --- .../actions/CloseScreenModal.svelte | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte index 873c9ccf65..5f3b3ef639 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte @@ -1,16 +1,31 @@ +Navigate To screen, or leave blank. +
- This action doesn't require any additional settings. - - This action won't do anything if there isn't a screen modal open. - + + (parameters.url = value.detail)} + {bindings} + />
From df5d609298d7686b8a18d34c397bc6cf6fecbd9f Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Wed, 28 Sep 2022 13:50:23 +0100 Subject: [PATCH 2/3] Handle navigation on close modal --- packages/client/src/utils/buttonActions.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index a534ee8326..74c4504ca6 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -224,7 +224,27 @@ const changeFormStepHandler = async (action, context) => { ) } -const closeScreenModalHandler = () => { +const closeScreenModalHandler = action => { + let { url } = action.parameters + if (url) { + window.parent.addEventListener("message", event => { + const location = event.target.location + //remove any trailing slash + if (url.charAt(url.length - 1) === "/") { + url = url.substring(0, url.length - 1) + } + //need to reload if hash route has not changed + let shouldReload = + `#${url.substring(0, url.lastIndexOf("/"))}` === + location.hash?.substring(0, location.hash.lastIndexOf("/")) + + window.parent.location.href = `${location.origin}${location.pathname}#${url}` + if (shouldReload) { + window.parent.location.reload() + } + }) + } + // Emit this as a window event, so parent screens which are iframing us in // can close the modal window.parent.postMessage({ type: "close-screen-modal" }) From 9a9ea26cc4086bbf86d739f7770ce48b524b1599 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 29 Sep 2022 14:10:34 +0100 Subject: [PATCH 3/3] Navigate in PeekScreenDisplay --- .../overlay/PeekScreenDisplay.svelte | 3 +++ packages/client/src/utils/buttonActions.js | 21 +------------------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/client/src/components/overlay/PeekScreenDisplay.svelte b/packages/client/src/components/overlay/PeekScreenDisplay.svelte index d6da9ca3f0..b9f4914624 100644 --- a/packages/client/src/components/overlay/PeekScreenDisplay.svelte +++ b/packages/client/src/components/overlay/PeekScreenDisplay.svelte @@ -45,6 +45,9 @@ }, [MessageTypes.CLOSE_SCREEN_MODAL]: () => { peekStore.actions.hidePeek() + if (message.data?.url) { + routeStore.actions.navigate(message.data.url) + } }, [MessageTypes.INVALIDATE_DATASOURCE]: () => { proxyInvalidation(message.data) diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index 74c4504ca6..e44ed2451c 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -226,28 +226,9 @@ const changeFormStepHandler = async (action, context) => { const closeScreenModalHandler = action => { let { url } = action.parameters - if (url) { - window.parent.addEventListener("message", event => { - const location = event.target.location - //remove any trailing slash - if (url.charAt(url.length - 1) === "/") { - url = url.substring(0, url.length - 1) - } - //need to reload if hash route has not changed - let shouldReload = - `#${url.substring(0, url.lastIndexOf("/"))}` === - location.hash?.substring(0, location.hash.lastIndexOf("/")) - - window.parent.location.href = `${location.origin}${location.pathname}#${url}` - if (shouldReload) { - window.parent.location.reload() - } - }) - } - // Emit this as a window event, so parent screens which are iframing us in // can close the modal - window.parent.postMessage({ type: "close-screen-modal" }) + window.parent.postMessage({ type: "close-screen-modal", url }) } const updateStateHandler = action => {