fix: fixing redirect from ds modal after import (#31834)

## Description
Redirection issue on DS Reconfigure modal after user imports the
application

## Automation

/ok-to-test tags="@tag.Fork,@tag.ImportExport"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]  
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/8295348027>
> Commit: `16953d533498713ec3e3eefb943614b20bdd5b95`
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8295348027&attempt=2"
target="_blank">Click here!</a>
> All cypress tests have passed 🎉🎉🎉

<!-- end of auto-generated comment: Cypress test results  -->




<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Improved the redirection logic in the `ReconnectDatasourceModal` to
ensure users are navigated correctly based on their current application
context.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Rudraprasad Das 2024-03-15 17:40:30 +05:30 committed by Trisha Anand
parent 77bb2a4fdd
commit 635af92e2e

View File

@ -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();
};