From 49d5615bfaf69341da2146677cc91b5a700b2b2f Mon Sep 17 00:00:00 2001 From: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:28:33 +0530 Subject: [PATCH] chore: add params for query instance (#30333) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Adding params for query module instance on action selector #### PR fixes following issue(s) Fixes # (issue number) > 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** - Enhanced action entity detection within the app for improved user experience. - **Refactor** - Streamlined action-related code for better performance and maintainability. - **Bug Fixes** - Resolved issues with incorrect action entity recognition in certain scenarios. --- .../src/ce/workers/Evaluation/evaluationUtils.ts | 4 ++++ .../editorComponents/ActionCreator/helpers.tsx | 12 ++++++------ .../editorComponents/ActionCreator/types.ts | 2 ++ app/client/src/sagas/selectors.tsx | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts index 3fcb5d57a8..1df27bf905 100644 --- a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts +++ b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts @@ -988,3 +988,7 @@ export const isAPathDynamicBindingPath = ( export const isNotEntity = (entity: DataTreeEntity) => { return !isAction(entity) && !isWidget(entity) && !isJSAction(entity); }; + +export const isEntityAction = (entity: DataTreeEntity) => { + return isAction(entity); +}; diff --git a/app/client/src/components/editorComponents/ActionCreator/helpers.tsx b/app/client/src/components/editorComponents/ActionCreator/helpers.tsx index b81640ebde..359e3ca3ae 100644 --- a/app/client/src/components/editorComponents/ActionCreator/helpers.tsx +++ b/app/client/src/components/editorComponents/ActionCreator/helpers.tsx @@ -11,7 +11,10 @@ import { setGlobalSearchCategory } from "actions/globalSearchActions"; import { createNewJSCollection } from "actions/jsPaneActions"; import { createModalAction } from "actions/widgetActions"; import type { AppState } from "@appsmith/reducers"; -import { getEntityNameAndPropertyPath } from "@appsmith/workers/Evaluation/evaluationUtils"; +import { + getEntityNameAndPropertyPath, + isEntityAction, +} from "@appsmith/workers/Evaluation/evaluationUtils"; import type { TreeDropdownOption } from "design-system-old"; import { Icon } from "design-system"; import { PluginType } from "entities/Action"; @@ -62,10 +65,7 @@ import { } from "./utils"; import store from "store"; import { selectEvaluationVersion } from "@appsmith/selectors/applicationSelectors"; -import { - isAction, - isJSAction, -} from "@appsmith/workers/Evaluation/evaluationUtils"; +import { isJSAction } from "@appsmith/workers/Evaluation/evaluationUtils"; import type { DataTreeEntity } from "entities/DataTree/dataTreeTypes"; import type { ModuleInstanceDataState } from "@appsmith/constants/ModuleInstanceConstants"; import { MODULE_TYPE } from "@appsmith/constants/ModuleConstants"; @@ -111,7 +111,7 @@ export function getFieldFromValue( const entity = dataTree && dataTree[entityProps.entityName]; if (entity && "ENTITY_TYPE" in entity) { - if (isAction(entity as DataTreeEntity)) { + if (isEntityAction(entity as DataTreeEntity)) { // get fields for API action return getActionEntityFields( fields, diff --git a/app/client/src/components/editorComponents/ActionCreator/types.ts b/app/client/src/components/editorComponents/ActionCreator/types.ts index 83110b7959..9d116ea54a 100644 --- a/app/client/src/components/editorComponents/ActionCreator/types.ts +++ b/app/client/src/components/editorComponents/ActionCreator/types.ts @@ -12,6 +12,7 @@ import type { AdditionalDynamicDataTree } from "utils/autocomplete/customTreeTyp import type { FieldType, ViewTypes, AppsmithFunction } from "./constants"; import type { APPSMITH_INTEGRATIONS } from "./constants"; import type { Variants } from "./constants"; +import type { MODULE_TYPE } from "@appsmith/constants/ModuleConstants"; export type GenericFunction = (...args: any[]) => any; @@ -162,6 +163,7 @@ export interface DataTreeForActionCreator { [key: string]: { ENTITY_TYPE?: EntityTypeValue; meta?: Record; + type?: MODULE_TYPE; }; } diff --git a/app/client/src/sagas/selectors.tsx b/app/client/src/sagas/selectors.tsx index f9b91b800d..2b0b413132 100644 --- a/app/client/src/sagas/selectors.tsx +++ b/app/client/src/sagas/selectors.tsx @@ -97,6 +97,7 @@ export const getDataTreeForActionCreator = memoize((state: AppState) => { dataTree[key] = { meta: value?.meta || null, ENTITY_TYPE: value?.ENTITY_TYPE || null, + type: value?.type || null, }; }); return dataTree;