From 939cd2a21707e7fd807244b13b0e9e78f01a1241 Mon Sep 17 00:00:00 2001 From: Druthi Polisetty Date: Fri, 1 Sep 2023 17:43:24 +0530 Subject: [PATCH] fix: Passsing dataTreePath to CodeEditor for AI events (#26601) ## Description Fixed issue where the propertyPath, widgetType was not being passed to the AI events. ##PR fixes following issue(s) Fixes #26690 #### Media #### Type of change - Bug fix (non-breaking change which fixes an issue) ## 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 --- .../ActionSelector_JsToNonJSMode_2_spec.ts | 2 +- .../editorComponents/ActionCreator/Field/index.tsx | 2 ++ .../ActionCreator/FieldGroup/index.tsx | 1 + .../editorComponents/ActionCreator/index.tsx | 1 + .../editorComponents/ActionCreator/types.ts | 3 +++ .../viewComponents/Action/ActionSelector.tsx | 11 ++++++++++- .../viewComponents/Action/ActionTree.test.tsx | 2 ++ .../viewComponents/Action/ActionTree.tsx | 3 +++ .../ActionCreator/viewComponents/Action/index.tsx | 2 ++ .../ActionCreator/viewComponents/TextView/index.tsx | 1 + .../components/editorComponents/CodeEditor/index.tsx | 3 ++- .../propertyControls/ActionSelectorControl.tsx | 9 ++++++++- .../propertyControls/ColumnActionSelectorControl.tsx | 1 + 13 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_2_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_2_spec.ts index 3e6657afd0..b129d73e37 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_2_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_2_spec.ts @@ -508,7 +508,7 @@ describe("JS to non-JS mode in Action Selector", () => { propPane.ToggleJSMode("onClick"); propPane.ValidatePropertyFieldValue( "onClick", - `{{copyToClipboard('line1\\nline2\\nline3a');}}`, + `{{copyToClipboard('aline1\\nline2\\nline3');}}`, ); }); diff --git a/app/client/src/components/editorComponents/ActionCreator/Field/index.tsx b/app/client/src/components/editorComponents/ActionCreator/Field/index.tsx index e250d0ba00..7d35a6ef3f 100644 --- a/app/client/src/components/editorComponents/ActionCreator/Field/index.tsx +++ b/app/client/src/components/editorComponents/ActionCreator/Field/index.tsx @@ -217,6 +217,7 @@ export function Field(props: FieldProps) { }, value: value, additionalAutoComplete: props.additionalAutoComplete, + dataTreePath: props.dataTreePath, }); break; case FieldType.CALLBACK_FUNCTION_API_AND_QUERY: @@ -235,6 +236,7 @@ export function Field(props: FieldProps) { }, value: value, additionalAutoComplete: props.additionalAutoComplete, + dataTreePath: props.dataTreePath, }); break; default: diff --git a/app/client/src/components/editorComponents/ActionCreator/FieldGroup/index.tsx b/app/client/src/components/editorComponents/ActionCreator/FieldGroup/index.tsx index 2e4c47f92f..5d80eb4bd1 100644 --- a/app/client/src/components/editorComponents/ActionCreator/FieldGroup/index.tsx +++ b/app/client/src/components/editorComponents/ActionCreator/FieldGroup/index.tsx @@ -79,6 +79,7 @@ function FieldGroup(props: FieldGroupProps) {
  • ( & SwitcherProps; @@ -77,6 +78,7 @@ export type ActionCreatorProps = { propertyName: string; widgetType: string; widgetName: string; + dataTreePath: string | undefined; }; export type Field = { @@ -114,6 +116,7 @@ export type FieldProps = { navigateToSwitches: Array; activeTabApiAndQueryCallback: SwitchType; apiAndQueryCallbackTabSwitches: SwitchType[]; + dataTreePath?: string | undefined; }; export type FieldGroupProps = Omit< diff --git a/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionSelector.tsx b/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionSelector.tsx index cd1015828b..aacc686a1c 100644 --- a/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionSelector.tsx +++ b/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionSelector.tsx @@ -23,6 +23,7 @@ export default function ActionSelector(props: { open: boolean; id: string; level: number; + dataTreePath: string | undefined; onChange: (actionBlock: TActionBlock, del?: boolean) => void; }) { const action = props.action; @@ -43,7 +44,13 @@ export default function ActionSelector(props: { } + content={ + + } isOpen={props.open} minimal popoverClassName={popoverClassName} @@ -60,6 +67,7 @@ type TActionSelectorFormProps = { action: TActionBlock; onChange: (actionBlock: TActionBlock, del?: boolean) => void; additionalAutoComplete?: AdditionalDynamicDataTree; + dataTreePath: string | undefined; }; const pathClassList = [ @@ -176,6 +184,7 @@ function ActionSelectorForm(props: TActionSelectorFormProps) {
    { { @@ -59,6 +60,7 @@ describe("tests for Action Tree in Action Selector", () => { { diff --git a/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionTree.tsx b/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionTree.tsx index 9e5b5f44e6..7907c81dae 100644 --- a/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionTree.tsx +++ b/app/client/src/components/editorComponents/ActionCreator/viewComponents/Action/ActionTree.tsx @@ -53,6 +53,7 @@ export default function ActionTree(props: { widgetName: string; propertyName: string; widgetType: string; + dataTreePath: string | undefined; }) { const { id } = props; const [actionBlock, setActionBlock] = React.useState(props.actionBlock); @@ -175,6 +176,7 @@ export default function ActionTree(props: {
    { evaluated = evaluatedValue; if (dataTreePath) { - evaluated = pathEvaluatedValue; + evaluated = + pathEvaluatedValue !== undefined ? pathEvaluatedValue : evaluated; } const entityInformation = this.getEntityInformation(); diff --git a/app/client/src/components/propertyControls/ActionSelectorControl.tsx b/app/client/src/components/propertyControls/ActionSelectorControl.tsx index 36dcf4d0fa..8fa14a121b 100644 --- a/app/client/src/components/propertyControls/ActionSelectorControl.tsx +++ b/app/client/src/components/propertyControls/ActionSelectorControl.tsx @@ -61,7 +61,13 @@ class ActionSelectorControl extends BaseControl { }; render() { - const { label, propertyName, propertyValue, widgetProperties } = this.props; + const { + dataTreePath, + label, + propertyName, + propertyValue, + widgetProperties, + } = this.props; return ( { additionalControlData={ this.props.additionalControlData as Record } + dataTreePath={dataTreePath} onValueChange={this.handleValueUpdate} propertyName={propertyName} ref={this.componentRef} diff --git a/app/client/src/components/propertyControls/ColumnActionSelectorControl.tsx b/app/client/src/components/propertyControls/ColumnActionSelectorControl.tsx index e909236f82..c202dcafdb 100644 --- a/app/client/src/components/propertyControls/ColumnActionSelectorControl.tsx +++ b/app/client/src/components/propertyControls/ColumnActionSelectorControl.tsx @@ -60,6 +60,7 @@ class ColumnActionSelectorControl extends BaseControl