From 288b52a10d78c54a628c19f21eeee8f0544ae804 Mon Sep 17 00:00:00 2001 From: Aman Agarwal Date: Mon, 4 Dec 2023 16:32:29 +0530 Subject: [PATCH] fix: added fetch env config to imitate the ee repo functionality (#29266) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description - Added the fetching of environment config for ee repo on create new app onboarding flow. - Imitated the `fetchingEnvironmentConfigs` function from ee to ce to provide consistency on both repos - Avoid the redirection from datasource sagas for changing the datasource form which was throwing error trying to create a redirection url. #### PR fixes following issue(s) Fixes #29231 > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed ## Summary by CodeRabbit - **New Features** - Implemented a new action to fetch environment configurations, enhancing the app's data management capabilities. - Updated application creation flow to automatically fetch environment configurations when a workspace ID is present. - **Enhancements** - Improved the logic for redirecting users in the data source creation process to be more context-aware. - **Bug Fixes** - Addressed an issue where users were being redirected incorrectly during the data source creation process. --- app/client/src/ce/actions/environmentAction.ts | 9 +++++++++ .../src/ce/pages/Applications/CreateNewAppsOption.tsx | 4 ++++ app/client/src/sagas/DatasourcesSagas.ts | 6 +++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/client/src/ce/actions/environmentAction.ts b/app/client/src/ce/actions/environmentAction.ts index 9736308933..ff48d6d747 100644 --- a/app/client/src/ce/actions/environmentAction.ts +++ b/app/client/src/ce/actions/environmentAction.ts @@ -6,3 +6,12 @@ export const setCurrentEditingEnvironmentID = (currentEditingId: string) => ({ type: "", payload: { currentEditingId }, }); + +// Redux action to fetch environments +export const fetchingEnvironmentConfigs = ( + workspaceId: string, + fetchDatasourceMeta = false, +) => ({ + type: "", + payload: { workspaceId, fetchDatasourceMeta }, +}); diff --git a/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx b/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx index c3acd055ec..2f77f60571 100644 --- a/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx +++ b/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx @@ -61,6 +61,7 @@ import { TEMP_DATASOURCE_ID } from "constants/Datasource"; import { fetchMockDatasources } from "actions/datasourceActions"; import DatasourceForm from "pages/Editor/SaaSEditor/DatasourceForm"; import type { Datasource } from "entities/Datasource"; +import { fetchingEnvironmentConfigs } from "@appsmith/actions/environmentAction"; const SectionWrapper = styled.div` display: flex; @@ -242,6 +243,9 @@ const CreateNewAppsOption = ({ if (isEnabledForStartWithData) { dispatch(fetchPlugins()); dispatch(fetchMockDatasources()); + if (application?.workspaceId) { + dispatch(fetchingEnvironmentConfigs(application?.workspaceId, true)); + } setUseType(START_WITH_TYPE.DATA); } } else { diff --git a/app/client/src/sagas/DatasourcesSagas.ts b/app/client/src/sagas/DatasourcesSagas.ts index 052863c0ca..91b0ff22c1 100644 --- a/app/client/src/sagas/DatasourcesSagas.ts +++ b/app/client/src/sagas/DatasourcesSagas.ts @@ -1157,6 +1157,9 @@ function* changeDatasourceSaga( const { datasource, shouldNotRedirect } = actionPayload.payload; const { id } = datasource; const draft: Record = yield select(getDatasourceDraft, id); + const currentApplicationIdForCreateNewApp: string | undefined = yield select( + getCurrentApplicationIdForCreateNewApp, + ); const pageId: string = yield select(getCurrentPageId); let data; if (isEmpty(draft)) { @@ -1173,7 +1176,8 @@ function* changeDatasourceSaga( ), ); // on reconnect modal, it shouldn't be redirected to datasource edit page - if (shouldNotRedirect) return; + // on create new app onboarding flow, it shouldn't redirect either + if (shouldNotRedirect || currentApplicationIdForCreateNewApp) return; // this redirects to the same route, so checking first. const datasourcePath = trimQueryString( datasourcesEditorIdURL({