From 54f822003c1f5c539a08f3641f7f3a5bc49b175a Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Tue, 11 Jun 2024 20:02:09 +0530 Subject: [PATCH 1/7] fix: Fix for regression in js query refactor in modules --- app/client/src/sagas/JSPaneSagas.ts | 37 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/app/client/src/sagas/JSPaneSagas.ts b/app/client/src/sagas/JSPaneSagas.ts index 60571f757d92..12c309480d52 100644 --- a/app/client/src/sagas/JSPaneSagas.ts +++ b/app/client/src/sagas/JSPaneSagas.ts @@ -58,6 +58,7 @@ import { createNewJSCollection, jsSaveActionComplete, jsSaveActionStart, + refactorJSCollectionAction, } from "actions/jsPaneActions"; import { getCurrentWorkspaceId } from "@appsmith/selectors/selectedWorkspaceSelectors"; import { getPluginIdOfPackageName } from "sagas/selectors"; @@ -205,21 +206,22 @@ function* handleEachUpdateJSCollection(update: JSUpdate) { const parsedBody = update.parsedBody; if (parsedBody && !!jsAction) { const jsActionTobeUpdated = JSON.parse(JSON.stringify(jsAction)); - // jsActionTobeUpdated.body = jsAction.body; const data = getDifferenceInJSCollection(parsedBody, jsAction); + if (data.nameChangedActions.length) { for (let i = 0; i < data.nameChangedActions.length; i++) { - yield call( - handleRefactorJSActionNameSaga, - { - actionId: data.nameChangedActions[i].id, - collectionName: jsAction.name, - pageId: data.nameChangedActions[i].pageId, - moduleId: data.nameChangedActions[i].moduleId, - oldName: data.nameChangedActions[i].oldName, - newName: data.nameChangedActions[i].newName, - }, - jsActionTobeUpdated, + yield put( + refactorJSCollectionAction({ + refactorAction: { + actionId: data.nameChangedActions[i].id, + collectionName: jsAction.name, + pageId: data.nameChangedActions[i].pageId || "", + moduleId: data.nameChangedActions[i].moduleId, + oldName: data.nameChangedActions[i].oldName, + newName: data.nameChangedActions[i].newName, + }, + actionCollection: jsActionTobeUpdated, + }), ); } } else { @@ -640,9 +642,12 @@ function* handleUpdateJSCollectionBody( } function* handleRefactorJSActionNameSaga( - refactorAction: RefactorAction, - actionCollection: JSCollection, + data: ReduxAction<{ + refactorAction: RefactorAction; + actionCollection: JSCollection; + }>, ) { + const { actionCollection, refactorAction } = data.payload; const { pageId } = refactorAction; const layoutId: string | undefined = yield select(getCurrentLayoutId); if (!pageId || !layoutId) { @@ -829,6 +834,10 @@ export default function* root() { ReduxActionTypes.START_EXECUTE_JS_FUNCTION, handleStartExecuteJSFunctionSaga, ), + takeEvery( + ReduxActionTypes.REFACTOR_JS_ACTION_NAME, + handleRefactorJSActionNameSaga, + ), debounce( 100, ReduxActionTypes.UPDATE_JS_ACTION_BODY_INIT, From e75d21b32ba2c5630ab3ab4c3b2ec6a77d6cbed7 Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Tue, 11 Jun 2024 21:11:00 +0530 Subject: [PATCH 2/7] Add loading actions to update and refactor js action sagas --- app/client/src/sagas/JSPaneSagas.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/client/src/sagas/JSPaneSagas.ts b/app/client/src/sagas/JSPaneSagas.ts index 12c309480d52..a6f20923cf2f 100644 --- a/app/client/src/sagas/JSPaneSagas.ts +++ b/app/client/src/sagas/JSPaneSagas.ts @@ -295,23 +295,11 @@ export function* makeUpdateJSCollection( ) { const jsUpdates: Record = action.payload || {}; - yield all( - Object.keys(jsUpdates).map((key) => - put(jsSaveActionStart({ id: jsUpdates[key].id })), - ), - ); - yield all( Object.keys(jsUpdates).map((key) => call(handleEachUpdateJSCollection, jsUpdates[key]), ), ); - - yield all( - Object.keys(jsUpdates).map((key) => - put(jsSaveActionComplete({ id: jsUpdates[key].id })), - ), - ); } function* updateJSCollection(data: { @@ -328,6 +316,7 @@ function* updateJSCollection(data: { try { const { deletedActions, jsCollection, newActions } = data; if (jsCollection) { + yield put(jsSaveActionStart({ id: jsCollection.id })); const response: JSCollectionCreateUpdateResponse = yield call( updateJSCollectionAPICall, jsCollection, @@ -367,6 +356,8 @@ function* updateJSCollection(data: { type: ReduxActionErrorTypes.UPDATE_JS_ACTION_ERROR, payload: { error, data: jsAction }, }); + } finally { + yield put(jsSaveActionComplete({ id: data.jsCollection.id })); } } @@ -661,6 +652,7 @@ function* handleRefactorJSActionNameSaga( }; // call to refactor action try { + yield put(jsSaveActionStart({ id: actionCollection.id })); const refactorResponse: ApiResponse = yield JSActionAPI.updateJSCollectionActionRefactor(requestData); @@ -688,6 +680,8 @@ function* handleRefactorJSActionNameSaga( type: ReduxActionErrorTypes.REFACTOR_JS_ACTION_NAME_ERROR, payload: { collectionId: actionCollection.id }, }); + } finally { + yield put(jsSaveActionComplete({ id: actionCollection.id })); } } From 82d07fda520148cf518e29b90763d7baa196bd98 Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Wed, 12 Jun 2024 15:12:13 +0530 Subject: [PATCH 3/7] Fix mismatch in evaluated value and initial value of actions in js object creation --- app/client/src/utils/JSPaneUtils.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/client/src/utils/JSPaneUtils.tsx b/app/client/src/utils/JSPaneUtils.tsx index 0b359f0c60ab..bb1e1834f507 100644 --- a/app/client/src/utils/JSPaneUtils.tsx +++ b/app/client/src/utils/JSPaneUtils.tsx @@ -219,7 +219,7 @@ export const createDummyJSCollectionActions = ( workspaceId, executeOnLoad: false, actionConfiguration: { - body: "function (){\n\t\t//\twrite code here\n\t\t//\tthis.myVar1 = [1,2,3]\n\t}", + body: "function () {}", timeoutInMillisecond: 0, jsArguments: [], }, @@ -231,7 +231,7 @@ export const createDummyJSCollectionActions = ( workspaceId, executeOnLoad: false, actionConfiguration: { - body: "async function () {\n\t\t//\tuse async-await or promises\n\t\t//\tawait storeValue('varName', 'hello world')\n\t}", + body: "async function () {}", timeoutInMillisecond: 0, jsArguments: [], }, @@ -243,11 +243,11 @@ export const createDummyJSCollectionActions = ( const variables = [ { name: "myVar1", - value: [], + value: "[]", }, { name: "myVar2", - value: {}, + value: "{}", }, ]; @@ -271,7 +271,7 @@ export const createSingleFunctionJsCollection = ( workspaceId, executeOnLoad: false, actionConfiguration: { - body: "function (){\n\t\t//\twrite code here\n\t}", + body: "function () {}", timeoutInMillisecond: 0, jsArguments: [], }, From 375a6e8b591b021f6ca4f506515154139924562a Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Wed, 12 Jun 2024 18:43:35 +0530 Subject: [PATCH 4/7] Replace assertion of update js object call to create js object call --- app/client/cypress/support/Pages/JSEditor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress/support/Pages/JSEditor.ts b/app/client/cypress/support/Pages/JSEditor.ts index 4ac86c773fb3..9dd23707580c 100644 --- a/app/client/cypress/support/Pages/JSEditor.ts +++ b/app/client/cypress/support/Pages/JSEditor.ts @@ -112,7 +112,7 @@ export class JSEditor { Cypress.env("MESSAGES").ADD_QUERY_JS_TOOLTIP(), ); //Checking JS object was created successfully - this.assertHelper.AssertNetworkStatus("@jsCollections", 200); + this.assertHelper.AssertNetworkStatus("@createNewJSCollection", 200); this.agHelper.AssertElementVisibility(this._jsObjTxt); // Assert that the name of the JS Object is focused when newly created this.agHelper.PressEnter(); From e6c719564e2e28bc6585745228a7abe2371c15b2 Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Thu, 13 Jun 2024 10:16:23 +0530 Subject: [PATCH 5/7] Change the network status to 201 --- app/client/cypress/support/Pages/JSEditor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress/support/Pages/JSEditor.ts b/app/client/cypress/support/Pages/JSEditor.ts index 9dd23707580c..c870c001c009 100644 --- a/app/client/cypress/support/Pages/JSEditor.ts +++ b/app/client/cypress/support/Pages/JSEditor.ts @@ -112,7 +112,7 @@ export class JSEditor { Cypress.env("MESSAGES").ADD_QUERY_JS_TOOLTIP(), ); //Checking JS object was created successfully - this.assertHelper.AssertNetworkStatus("@createNewJSCollection", 200); + this.assertHelper.AssertNetworkStatus("@createNewJSCollection", 201); this.agHelper.AssertElementVisibility(this._jsObjTxt); // Assert that the name of the JS Object is focused when newly created this.agHelper.PressEnter(); From 3b7c67d7d82c4d15d7129f09a023d6475b835600 Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Thu, 13 Jun 2024 10:18:31 +0530 Subject: [PATCH 6/7] Update limited tests --- app/client/cypress/limited-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress/limited-tests.txt b/app/client/cypress/limited-tests.txt index 31c0c0253fef..f54ce8364dec 100644 --- a/app/client/cypress/limited-tests.txt +++ b/app/client/cypress/limited-tests.txt @@ -1,5 +1,5 @@ # To run only limited tests - give the spec names in below format: -cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js +cypress/e2e/Regression/ClientSide/Autocomplete/JS_AC2_spec.ts # For running all specs - uncomment below: #cypress/e2e/**/**/* From dae185d7c59e1715e3050b56150a8e5f9f1c708b Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Thu, 13 Jun 2024 11:40:34 +0530 Subject: [PATCH 7/7] Revert "Update limited tests" This reverts commit 3b7c67d7d82c4d15d7129f09a023d6475b835600. --- app/client/cypress/limited-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress/limited-tests.txt b/app/client/cypress/limited-tests.txt index f54ce8364dec..31c0c0253fef 100644 --- a/app/client/cypress/limited-tests.txt +++ b/app/client/cypress/limited-tests.txt @@ -1,5 +1,5 @@ # To run only limited tests - give the spec names in below format: -cypress/e2e/Regression/ClientSide/Autocomplete/JS_AC2_spec.ts +cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js # For running all specs - uncomment below: #cypress/e2e/**/**/*