From 635af92e2e408da0bb37e0bb314199b0e8bb9498 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Fri, 15 Mar 2024 17:40:30 +0530 Subject: [PATCH] fix: fixing redirect from ds modal after import (#31834) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Redirection issue on DS Reconfigure modal after user imports the application ## Automation /ok-to-test tags="@tag.Fork,@tag.ImportExport" ### :mag: Cypress test results > [!IMPORTANT] > Workflow run: > Commit: `16953d533498713ec3e3eefb943614b20bdd5b95` > Cypress dashboard url: Click here! > All cypress tests have passed 🎉🎉🎉 ## Summary by CodeRabbit - **Refactor** - Improved the redirection logic in the `ReconnectDatasourceModal` to ensure users are navigated correctly based on their current application context. --- .../pages/Editor/gitSync/ReconnectDatasourceModal.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/client/src/pages/Editor/gitSync/ReconnectDatasourceModal.tsx b/app/client/src/pages/Editor/gitSync/ReconnectDatasourceModal.tsx index 25fd58eb90..6a732e4095 100644 --- a/app/client/src/pages/Editor/gitSync/ReconnectDatasourceModal.tsx +++ b/app/client/src/pages/Editor/gitSync/ReconnectDatasourceModal.tsx @@ -75,7 +75,6 @@ import { getFetchedWorkspaces } from "@appsmith/selectors/workspaceSelectors"; import { getApplicationsOfWorkspace } from "@appsmith/selectors/selectedWorkspaceSelectors"; import useReconnectModalData from "@appsmith/pages/Editor/gitSync/useReconnectModalData"; import { resetImportData } from "@appsmith/actions/workspaceActions"; -import history from "utils/history"; const Section = styled.div` display: flex; @@ -439,6 +438,11 @@ function ReconnectDatasourceModal() { // If either the close button or the overlay was clicked close the modal if (shouldClose) { onClose(); + const isInsideApplication = + window.location.pathname.split("/")[1] === "app"; + if (isInsideApplication && editorURL) { + window.location.href = editorURL; + } } } }; @@ -563,7 +567,10 @@ function ReconnectDatasourceModal() { const onSkipBtnClick = () => { AnalyticsUtil.logEvent("RECONNECTING_SKIP_TO_APPLICATION_BUTTON_CLICK"); localStorage.setItem("importedAppPendingInfo", "null"); - editorURL && history.push(editorURL); + if (editorURL) { + // window location because history push changes routes shallowly and some side effects needed for page loading might not run + window.location.href = editorURL; + } onClose(); };