From 0f3593af2424c4c5b2b2d5e3d05952ee0628c763 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Thu, 28 Nov 2024 10:49:17 +0530 Subject: [PATCH] fix: [Plugin Action Editor] Avoid multiple init of Form Eval (#37780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Noticed that we are causing the evaluation of the form twice because `changeQuery` also initiates the eval. Since the `changeQuery` also handles other aspects, will defer to that and not initiate again for UQI Forms. Fixes #37772 ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: f531f842f5eeb4d77ccce034466cab6d1fe169a6 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Thu, 28 Nov 2024 05:14:17 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Bug Fixes** - Removed the `useInitFormEvaluation` hook from the `UQIEditorForm`, streamlining the form initialization process. - Updated the `useChangeActionCall` hook to directly access the `action.id`, enhancing reliability in action dispatching. --- .../components/UQIEditor/UQIEditorForm.tsx | 3 --- .../UQIEditor/hooks/useInitFormEvaluation.ts | 21 ------------------- .../hooks/useChangeActionCall.ts | 2 +- 3 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/hooks/useInitFormEvaluation.ts diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx b/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx index 44750c91be..99f303d954 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx @@ -6,7 +6,6 @@ import { reduxForm } from "redux-form"; import { Flex } from "@appsmith/ads"; import { useGoogleSheetsSetDefaultProperty } from "./hooks/useGoogleSheetsSetDefaultProperty"; import { useFormData } from "./hooks/useFormData"; -import { useInitFormEvaluation } from "./hooks/useInitFormEvaluation"; const UQIEditorForm = () => { const { @@ -14,8 +13,6 @@ const UQIEditorForm = () => { plugin: { uiComponent }, } = usePluginActionContext(); - useInitFormEvaluation(); - // Set default values for Google Sheets useGoogleSheetsSetDefaultProperty(); diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/hooks/useInitFormEvaluation.ts b/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/hooks/useInitFormEvaluation.ts deleted file mode 100644 index 5c52cdfa89..0000000000 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/hooks/useInitFormEvaluation.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { useEffect } from "react"; -import { initFormEvaluations } from "actions/evaluationActions"; -import { useDispatch } from "react-redux"; -import { usePluginActionContext } from "../../../../../PluginActionContext"; - -export const useInitFormEvaluation = () => { - const dispatch = useDispatch(); - - const { - action: { baseId }, - editorConfig, - settingsConfig, - } = usePluginActionContext(); - - useEffect( - function formEvaluationInit() { - dispatch(initFormEvaluations(editorConfig, settingsConfig, baseId)); - }, - [baseId, dispatch, editorConfig, settingsConfig], - ); -}; diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts b/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts index 79b5be0f72..bd1eb8faa3 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts +++ b/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts @@ -15,7 +15,7 @@ export const useChangeActionCall = () => { switch (plugin?.type) { case PluginType.API: - dispatch(changeApi(action?.id, false)); + dispatch(changeApi(action.id, false)); break; default: dispatch(