fix: added fetch env config to imitate the ee repo functionality (#29266)

## 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


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

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aman Agarwal 2023-12-04 16:32:29 +05:30 committed by GitHub
parent 6f8227e5bc
commit 288b52a10d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

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

View File

@ -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 {

View File

@ -1157,6 +1157,9 @@ function* changeDatasourceSaga(
const { datasource, shouldNotRedirect } = actionPayload.payload;
const { id } = datasource;
const draft: Record<string, unknown> = 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({