PromucFlow_constructor/app/client/src/ce/sagas/helpers.ts

99 lines
3.2 KiB
TypeScript
Raw Normal View History

chore: Update integration modal (#39976) /ok-to-test tags="@tag.Datasource" <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Action creators now support optional callbacks and redirection controls to enhance query operations. - UI tabs can now be configured to remain persistently mounted, ensuring a smoother editing experience. - New functionality to add datasources to the existing list without complex tracking. - **Bug Fixes** - Simplified logic for determining the saving state of datasources, improving UI responsiveness. - **Refactor** - Datasource creation and saving state handling have been streamlined for improved reliability. - Enhanced management of action payloads and state updates enables more robust processing of user operations. - Improved type safety and clarity in action handling within sagas for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/14167301395> > Commit: be05d6bda56aff96421faf435804f56707a597ba > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14167301395&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Mon, 31 Mar 2025 09:14:22 UTC <!-- end of auto-generated comment: Cypress test results -->
2025-03-31 10:13:18 +00:00
import omit from "lodash/omit";
import merge from "lodash/merge";
import type { CreateNewActionKeyInterface } from "ee/entities/Engine/actionHelpers";
import { CreateNewActionKey } from "ee/entities/Engine/actionHelpers";
import type { DeleteErrorLogPayload } from "actions/debuggerActions";
chore: entity name generation refactor to include other entity types (#30316) ## Description When we create an entity (JS or Query or API), the name is always generated based the lookup of only that particular type. This leads to name clash if a different entity has the same name format. Example: If a js object has the name "Query1" then if a query is being created; the generated name would be "Query1" and it would fail to create as there is a name clash. To avoid this; all entities are considered to generate name. This PR also makes sure that the name generation logic is done at a central place (saga) rather than the creator of the entity. This avoid code duplication. #### PR fixes following issue(s) PR for https://github.com/appsmithorg/appsmith-ee/pull/3306 > 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. - Chore (housekeeping or task changes that don't impact user perception) ## 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** - Introduced a new action creation process with enhanced naming conventions. - Implemented a new selector to generate entity names based on existing entities. - **Improvements** - Streamlined action creation flow by integrating new helper functions. - **Refactor** - Updated various components to utilize the new entity naming selector. - Consolidated action creation logic across different parts of the application. - **Bug Fixes** - Fixed inconsistencies in action naming during the creation of APIs and Queries. - **Code Cleanup** - Removed unused code and imports related to deprecated naming utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-01-17 10:04:50 +00:00
import type { Action } from "entities/Action";
import type { Log } from "entities/AppsmithConsole";
2024-07-23 07:49:29 +00:00
import type { EvaluationError } from "utils/DynamicBindingUtils";
chore: Update integration modal (#39976) /ok-to-test tags="@tag.Datasource" <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Action creators now support optional callbacks and redirection controls to enhance query operations. - UI tabs can now be configured to remain persistently mounted, ensuring a smoother editing experience. - New functionality to add datasources to the existing list without complex tracking. - **Bug Fixes** - Simplified logic for determining the saving state of datasources, improving UI responsiveness. - **Refactor** - Datasource creation and saving state handling have been streamlined for improved reliability. - Enhanced management of action payloads and state updates enables more robust processing of user operations. - Improved type safety and clarity in action handling within sagas for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/14167301395> > Commit: be05d6bda56aff96421faf435804f56707a597ba > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14167301395&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Mon, 31 Mar 2025 09:14:22 UTC <!-- end of auto-generated comment: Cypress test results -->
2025-03-31 10:13:18 +00:00
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
import type { getConfigInitialValues } from "components/formControls/utils";
import type { CreateDatasourceConfig } from "ee/api/DatasourcesApi";
import type { Datasource } from "entities/Datasource";
chore: entity name generation refactor to include other entity types (#30316) ## Description When we create an entity (JS or Query or API), the name is always generated based the lookup of only that particular type. This leads to name clash if a different entity has the same name format. Example: If a js object has the name "Query1" then if a query is being created; the generated name would be "Query1" and it would fail to create as there is a name clash. To avoid this; all entities are considered to generate name. This PR also makes sure that the name generation logic is done at a central place (saga) rather than the creator of the entity. This avoid code duplication. #### PR fixes following issue(s) PR for https://github.com/appsmithorg/appsmith-ee/pull/3306 > 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. - Chore (housekeeping or task changes that don't impact user perception) ## 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** - Introduced a new action creation process with enhanced naming conventions. - Implemented a new selector to generate entity names based on existing entities. - **Improvements** - Streamlined action creation flow by integrating new helper functions. - **Refactor** - Updated various components to utilize the new entity naming selector. - Consolidated action creation logic across different parts of the application. - **Bug Fixes** - Fixed inconsistencies in action naming during the creation of APIs and Queries. - **Code Cleanup** - Removed unused code and imports related to deprecated naming utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-01-17 10:04:50 +00:00
export interface ResolveParentEntityMetadataReturnType {
parentEntityId?: string;
parentEntityKey?: CreateNewActionKeyInterface;
}
chore: refactor query duplication flow (#36915) ## Description This PR refactors the action duplication saga and action calls to remove dependency on pageID. As far as CE code is concerned, this PR doesn't change any functionality for the end user. Those changes are done for workflows editor in EE. Fixes https://github.com/appsmithorg/appsmith/issues/36886 ## Automation /test all ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11462274307> > Commit: 04dfbfbf910c789f4da4892497ce97be952bd2cd > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11462274307&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Tue, 22 Oct 2024 16:21:32 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new hook, `useHandleDuplicateClick`, enhancing action duplication functionality. - Added a new interface and function for generating destination ID information. - **Bug Fixes** - Updated action request structure to use `destinationEntityId` for consistency across components. - **Documentation** - Enhanced success message flexibility for action copy notifications. - **Tests** - Added unit tests for the `ActionEntityContextMenu` component to ensure proper functionality and rendering. - **Refactor** - Improved context menu handling based on entity types for better user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-10-24 08:31:00 +00:00
// This function is extended in EE. Please check the EE implementation before any modification.
export interface GenerateDestinationIdInfoReturnType {
pageId?: string;
}
// This function is extended in EE. Please check the EE implementation before any modification.
export function generateDestinationIdInfoForQueryDuplication(
destinationEntityId: string,
parentEntityKey: CreateNewActionKeyInterface,
): GenerateDestinationIdInfoReturnType {
if (parentEntityKey === CreateNewActionKey.PAGE) {
return { pageId: destinationEntityId };
}
return {};
}
chore: entity name generation refactor to include other entity types (#30316) ## Description When we create an entity (JS or Query or API), the name is always generated based the lookup of only that particular type. This leads to name clash if a different entity has the same name format. Example: If a js object has the name "Query1" then if a query is being created; the generated name would be "Query1" and it would fail to create as there is a name clash. To avoid this; all entities are considered to generate name. This PR also makes sure that the name generation logic is done at a central place (saga) rather than the creator of the entity. This avoid code duplication. #### PR fixes following issue(s) PR for https://github.com/appsmithorg/appsmith-ee/pull/3306 > 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. - Chore (housekeeping or task changes that don't impact user perception) ## 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** - Introduced a new action creation process with enhanced naming conventions. - Implemented a new selector to generate entity names based on existing entities. - **Improvements** - Streamlined action creation flow by integrating new helper functions. - **Refactor** - Updated various components to utilize the new entity naming selector. - Consolidated action creation logic across different parts of the application. - **Bug Fixes** - Fixed inconsistencies in action naming during the creation of APIs and Queries. - **Code Cleanup** - Removed unused code and imports related to deprecated naming utilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-01-17 10:04:50 +00:00
// This function is extended in EE. Please check the EE implementation before any modification.
export const resolveParentEntityMetadata = (
action: Partial<Action>,
): ResolveParentEntityMetadataReturnType => {
if (action.pageId) {
return {
parentEntityId: action.pageId,
parentEntityKey: CreateNewActionKey.PAGE,
};
}
return { parentEntityId: undefined, parentEntityKey: undefined };
};
export function* transformAddErrorLogsSaga(logs: Log[]) {
return logs;
}
export function* transformDeleteErrorLogsSaga(payload: DeleteErrorLogPayload) {
return payload;
}
2024-07-23 07:49:29 +00:00
export function* transformTriggerEvalErrors(errors: EvaluationError[]) {
return errors;
}
chore: Update integration modal (#39976) /ok-to-test tags="@tag.Datasource" <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Action creators now support optional callbacks and redirection controls to enhance query operations. - UI tabs can now be configured to remain persistently mounted, ensuring a smoother editing experience. - New functionality to add datasources to the existing list without complex tracking. - **Bug Fixes** - Simplified logic for determining the saving state of datasources, improving UI responsiveness. - **Refactor** - Datasource creation and saving state handling have been streamlined for improved reliability. - Enhanced management of action payloads and state updates enables more robust processing of user operations. - Improved type safety and clarity in action handling within sagas for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/14167301395> > Commit: be05d6bda56aff96421faf435804f56707a597ba > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14167301395&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Mon, 31 Mar 2025 09:14:22 UTC <!-- end of auto-generated comment: Cypress test results -->
2025-03-31 10:13:18 +00:00
interface CreateDatasourcePayloadFromActionParams {
currentEnvId: string;
actionPayload: Datasource | CreateDatasourceConfig;
initialValues: ReturnType<typeof getConfigInitialValues>;
}
export const createDatasourceAPIPayloadFromAction = (
props: CreateDatasourcePayloadFromActionParams,
) => {
const { actionPayload, currentEnvId, initialValues } = props;
let datasourceStoragePayload = actionPayload.datasourceStorages[currentEnvId];
datasourceStoragePayload = merge(initialValues, datasourceStoragePayload);
// in the datasourcestorages, we only need one key, the currentEnvironment
// we need to remove any other keys present
const datasourceStorages = {
[currentEnvId]: datasourceStoragePayload,
};
const payload = omit(
{
...actionPayload,
datasourceStorages,
},
["id", "new", "type", "datasourceConfiguration"],
);
if (payload.datasourceStorages) datasourceStoragePayload.isConfigured = true;
// remove datasourceId from payload if it is equal to TEMP_DATASOURCE_ID
if (datasourceStoragePayload.datasourceId === TEMP_DATASOURCE_ID)
datasourceStoragePayload.datasourceId = "";
return payload;
};