From 36239e2545ae2c773124743d06dbb7c2a2d79636 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Mon, 25 Nov 2024 14:11:46 +0530 Subject: [PATCH] fix: Plugin Action Editor navigation issue with git (#37670) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Fixes the passing of wrong id when trying to trigger a changeQuery request. The scenario fixed was passing an actionId instead of a baseActionId. Later on, [a selector](https://github.com/appsmithorg/appsmith/blob/release/app/client/src/sagas/QueryPaneSagas.ts#L111) is not able to find the action as it expects a baseActionId and causes a navigation bug. ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: Cypress test results > [!IMPORTANT] > 🟣 🟣 🟣 Your tests are running. > Tests running at: > Commit: b4e3cb0c2902791e7f403f74a89a6e3a6e661f0f > Workflow: `PR Automation test suite` > Tags: `@tag.Sanity` > Spec: `` >
Mon, 25 Nov 2024 06:25:04 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No ## Summary by CodeRabbit - **New Features** - Enhanced logic for action and plugin state management in the Plugin Action Editor. - Improved handling of action IDs for more efficient query dispatching. - **Bug Fixes** - Simplified initial checks to improve control flow and performance. --- .../PluginActionForm/hooks/useChangeActionCall.test.tsx | 9 +++++---- .../PluginActionForm/hooks/useChangeActionCall.ts | 4 +--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.test.tsx b/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.test.tsx index 55029fbaef..83e645f6da 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.test.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.test.tsx @@ -33,7 +33,7 @@ describe("useChangeActionCall hook", () => { }); it("should dispatch changeApi when plugin type is API", () => { - const actionMock = { id: "actionId" }; + const actionMock = { id: "actionId", baseId: "baseActionId" }; const pluginMock = { id: "pluginId", type: PluginType.API }; // Mock the return values of usePluginActionContext @@ -53,6 +53,7 @@ describe("useChangeActionCall hook", () => { it("should dispatch changeQuery when plugin type is not API", () => { const actionMock = { id: "actionId", + baseId: "baseActionId", pageId: "pageId", applicationId: "applicationId", packageId: "packageId", @@ -72,7 +73,7 @@ describe("useChangeActionCall hook", () => { // Expect changeQuery to be called with the correct parameters expect(changeQuery).toHaveBeenCalledWith({ - baseQueryId: actionMock.id, + baseQueryId: actionMock.baseId, basePageId: actionMock.pageId, applicationId: actionMock.applicationId, packageId: actionMock.packageId, @@ -81,7 +82,7 @@ describe("useChangeActionCall hook", () => { }); expect(dispatchMock).toHaveBeenCalledWith( changeQuery({ - baseQueryId: actionMock.id, + baseQueryId: actionMock.baseId, basePageId: actionMock.pageId, applicationId: actionMock.applicationId, packageId: actionMock.packageId, @@ -106,7 +107,7 @@ describe("useChangeActionCall hook", () => { }); it("should not dispatch any action if the action Id has not changed", () => { - const actionMock = { id: "actionId" }; + const actionMock = { id: "actionId", baseId: "baseActionId" }; const pluginMock = { id: "pluginId", type: PluginType.API }; // First we mount, so it should be called as previous action id was undefined diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts b/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts index ac1620ddcb..79b5be0f72 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts +++ b/app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts @@ -11,8 +11,6 @@ export const useChangeActionCall = () => { const dispatch = useDispatch(); useEffect(() => { - if (!plugin?.id || !action) return; - if (prevActionId === action.id) return; switch (plugin?.type) { @@ -22,7 +20,7 @@ export const useChangeActionCall = () => { default: dispatch( changeQuery({ - baseQueryId: action?.id, + baseQueryId: action.baseId, basePageId: action.pageId, applicationId: action.applicationId, packageId: action.packageId,