From 97b374c1ef8e54e2924277dbe40b414a68692d01 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Mon, 24 Mar 2025 14:08:43 +0530 Subject: [PATCH] chore: Introduce action isDirty map (#39872) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description The server now adds a isDirty map in the action object to signify if any aspect of the action is not saved (is dirty) This is needed for the EE change https://github.com/appsmithorg/appsmith-ee/pull/6713 https://www.notion.so/appsmith/Implement-save-button-for-AI-Query-1b9fe271b0e2808285dcc797ad281141?pvs=4 ## Automation /ok-to-test tags="@tag.Datasource" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 4321d95d427a1dfd07aedecd3731390ed0a4688e > Cypress dashboard. > Tags: `@tag.Datasource` > Spec: >
Mon, 24 Mar 2025 07:51:29 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Added a capability that improves how the app retrieves a specific action from a collection based on unique identifiers, ensuring smoother interaction. - Enhanced state management in actions by introducing a new property to track the update status of schema generation, supporting more robust workflow handling. --- .../transformers/RestActionTransformers.test.ts | 3 +++ app/client/src/ce/selectors/entitiesSelector.ts | 14 ++++++++++++++ .../src/components/editorComponents/utils.test.ts | 3 +++ .../src/entities/Action/actionProperties.test.ts | 3 +++ app/client/src/entities/Action/index.ts | 3 +++ app/client/src/pages/Editor/JSEditor/utils.test.ts | 3 +++ .../src/sagas/BuildingBlockSagas/tests/fixtures.ts | 3 +++ app/client/test/factories/Actions/API.ts | 3 +++ .../test/factories/Actions/GoogleSheetFactory.ts | 4 ++++ app/client/test/factories/Actions/JSObject.ts | 6 ++++++ app/client/test/factories/Actions/Postgres.ts | 3 +++ 11 files changed, 48 insertions(+) diff --git a/app/client/src/PluginActionEditor/transformers/RestActionTransformers.test.ts b/app/client/src/PluginActionEditor/transformers/RestActionTransformers.test.ts index 95f5ee8a6d..3a375877f9 100644 --- a/app/client/src/PluginActionEditor/transformers/RestActionTransformers.test.ts +++ b/app/client/src/PluginActionEditor/transformers/RestActionTransformers.test.ts @@ -40,6 +40,9 @@ const BASE_ACTION: ApiAction = { }, timeoutInMillisecond: 5000, }, + isDirtyMap: { + SCHEMA_GENERATION: false, + }, jsonPathKeys: [], messages: [], }; diff --git a/app/client/src/ce/selectors/entitiesSelector.ts b/app/client/src/ce/selectors/entitiesSelector.ts index 348b0c1abd..7868eac45b 100644 --- a/app/client/src/ce/selectors/entitiesSelector.ts +++ b/app/client/src/ce/selectors/entitiesSelector.ts @@ -834,6 +834,20 @@ export const getJsCollectionByBaseId = ( return jsaction && jsaction.config; }; +export const getJSCollectionAction = ( + state: AppState, + collectionId: string, + actionId: string, +) => { + const jsCollection = getJSCollection(state, collectionId); + + if (jsCollection) { + return jsCollection.actions.find((action) => action.id === actionId); + } + + return null; +}; + /** * * getJSCollectionFromAllEntities is used to get the js collection from all jsAction entities (including module instance entities) ) diff --git a/app/client/src/components/editorComponents/utils.test.ts b/app/client/src/components/editorComponents/utils.test.ts index e13d4e436a..d0cb4f1247 100644 --- a/app/client/src/components/editorComponents/utils.test.ts +++ b/app/client/src/components/editorComponents/utils.test.ts @@ -47,6 +47,9 @@ const TEST_JS_FUNCTION = { userPermissions: ["read:actions", "execute:actions", "manage:actions"], validName: "JSObject1.myFun234y", cacheResponse: "", + isDirtyMap: { + SCHEMA_GENERATION: false, + }, }; describe("GetJSResponseViewState", () => { diff --git a/app/client/src/entities/Action/actionProperties.test.ts b/app/client/src/entities/Action/actionProperties.test.ts index d153be3ba4..54b695bc9e 100644 --- a/app/client/src/entities/Action/actionProperties.test.ts +++ b/app/client/src/entities/Action/actionProperties.test.ts @@ -23,6 +23,9 @@ const DEFAULT_ACTION: Action = { pluginId: "", messages: [], pluginType: PluginType.DB, + isDirtyMap: { + SCHEMA_GENERATION: false, + }, }; describe("getReactivePathsOfAction", () => { diff --git a/app/client/src/entities/Action/index.ts b/app/client/src/entities/Action/index.ts index 2343a49a64..1cca0fadc0 100644 --- a/app/client/src/entities/Action/index.ts +++ b/app/client/src/entities/Action/index.ts @@ -166,6 +166,9 @@ export interface BaseAction { visualization?: { result: VisualizationElements; }; + isDirtyMap: { + SCHEMA_GENERATION: boolean; + }; } interface BaseApiAction extends BaseAction { diff --git a/app/client/src/pages/Editor/JSEditor/utils.test.ts b/app/client/src/pages/Editor/JSEditor/utils.test.ts index 7c6926fd5f..b5e876566f 100644 --- a/app/client/src/pages/Editor/JSEditor/utils.test.ts +++ b/app/client/src/pages/Editor/JSEditor/utils.test.ts @@ -61,6 +61,9 @@ const BASE_JS_ACTION = (useLiterals = false) => { timeoutInMillisecond: 1000, jsArguments: [], }, + isDirtyMap: { + SCHEMA_GENERATION: false, + }, }; }; diff --git a/app/client/src/sagas/BuildingBlockSagas/tests/fixtures.ts b/app/client/src/sagas/BuildingBlockSagas/tests/fixtures.ts index e95cfcb062..f756e3b5b9 100644 --- a/app/client/src/sagas/BuildingBlockSagas/tests/fixtures.ts +++ b/app/client/src/sagas/BuildingBlockSagas/tests/fixtures.ts @@ -152,5 +152,8 @@ export const newlyCreatedActions: Action[] = [ "execute:actions", "manage:actions", ], + isDirtyMap: { + SCHEMA_GENERATION: false, + }, }, ]; diff --git a/app/client/test/factories/Actions/API.ts b/app/client/test/factories/Actions/API.ts index a874c09fcc..f62d2f423f 100644 --- a/app/client/test/factories/Actions/API.ts +++ b/app/client/test/factories/Actions/API.ts @@ -75,4 +75,7 @@ export const APIFactory = Factory.Sync.makeFactory({ "manage:actions", ], confirmBeforeExecute: false, + isDirtyMap: { + SCHEMA_GENERATION: false, + }, }); diff --git a/app/client/test/factories/Actions/GoogleSheetFactory.ts b/app/client/test/factories/Actions/GoogleSheetFactory.ts index 483218bb6c..c9eab37041 100644 --- a/app/client/test/factories/Actions/GoogleSheetFactory.ts +++ b/app/client/test/factories/Actions/GoogleSheetFactory.ts @@ -4,8 +4,12 @@ import { PluginPackageName, PluginType } from "entities/Plugin"; import { PluginIDs } from "test/factories/MockPluginsState"; const pageId = "0123456789abcdef00000000"; + export const GoogleSheetFactory = Factory.Sync.makeFactory({ dynamicBindingPathList: [], + isDirtyMap: { + SCHEMA_GENERATION: false, + }, id: "api_id", baseId: "api_base_id", workspaceId: "workspaceID", diff --git a/app/client/test/factories/Actions/JSObject.ts b/app/client/test/factories/Actions/JSObject.ts index c0b1c72997..c9d546c3dd 100644 --- a/app/client/test/factories/Actions/JSObject.ts +++ b/app/client/test/factories/Actions/JSObject.ts @@ -51,6 +51,9 @@ export const JSObjectFactory = Factory.Sync.makeFactory({ "manage:actions", ], cacheResponse: "", + isDirtyMap: { + SCHEMA_GENERATION: false, + }, }, { id: "myFunc2_id", @@ -88,6 +91,9 @@ export const JSObjectFactory = Factory.Sync.makeFactory({ "manage:actions", ], cacheResponse: "", + isDirtyMap: { + SCHEMA_GENERATION: false, + }, }, ], body: "export default {\n\tmyVar1: [],\n\tmyVar2: {},\n\tmyFun1 () {\n\t\t//\twrite code here\n\t\t//\tthis.myVar1 = [1,2,3]\n\t},\n\tasync myFun2 () {\n\t\t//\tuse async-await or promises\n\t\t//\tawait storeValue('varName', 'hello world')\n\t}\n}", diff --git a/app/client/test/factories/Actions/Postgres.ts b/app/client/test/factories/Actions/Postgres.ts index f9690a7332..ecf1068b63 100644 --- a/app/client/test/factories/Actions/Postgres.ts +++ b/app/client/test/factories/Actions/Postgres.ts @@ -44,4 +44,7 @@ export const PostgresFactory = Factory.Sync.makeFactory({ "execute:actions", "manage:actions", ], + isDirtyMap: { + SCHEMA_GENERATION: false, + }, });