fix: Plugin Action Editor navigation issue with git (#37670)
## 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" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!IMPORTANT] > 🟣 🟣 🟣 Your tests are running. > Tests running at: <https://github.com/appsmithorg/appsmith/actions/runs/12004477441> > Commit: b4e3cb0c2902791e7f403f74a89a6e3a6e661f0f > Workflow: `PR Automation test suite` > Tags: `@tag.Sanity` > Spec: `` > <hr>Mon, 25 Nov 2024 06:25:04 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** - 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
b9ce30ef97
commit
36239e2545
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user