PromucFlow_constructor/app/client/src/sagas/ActionExecution/PluginActionSaga.ts

1054 lines
31 KiB
TypeScript
Raw Normal View History

import { all, call, put, select, take, takeLatest } from "redux-saga/effects";
import {
executePluginActionError,
executePluginActionRequest,
executePluginActionSuccess,
runAction,
updateAction,
} from "actions/pluginActionActions";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type {
ApplicationPayload,
ReduxAction,
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
} from "@appsmith/constants/ReduxActionConstants";
import {
ReduxActionErrorTypes,
ReduxActionTypes,
} from "@appsmith/constants/ReduxActionConstants";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type {
ActionExecutionResponse,
ActionResponse,
ExecuteActionRequest,
PaginationField,
} from "api/ActionAPI";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import ActionAPI from "api/ActionAPI";
import {
getAction,
getCurrentPageNameByActionId,
getPlugin,
isActionDirty,
isActionSaving,
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
getJSCollection,
} from "selectors/entitiesSelector";
import { getIsGitSyncModalOpen } from "selectors/gitSyncSelectors";
import {
getAppMode,
getCurrentApplication,
} from "selectors/applicationSelectors";
import { get, isArray, isString, set, find, isNil, flatten } from "lodash";
import AppsmithConsole from "utils/AppsmithConsole";
import { ENTITY_TYPE, PLATFORM_ERROR } from "entities/AppsmithConsole";
import { validateResponse } from "sagas/ErrorSagas";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { EventName } from "utils/AnalyticsUtil";
import AnalyticsUtil from "utils/AnalyticsUtil";
import type { Action } from "entities/Action";
import { PluginType } from "entities/Action";
import LOG_TYPE from "entities/AppsmithConsole/logtype";
feat: Renamed design system package (#19854) ## Description This PR includes changes for renaming design system package. Since we are building new package for the refactored design system components, the old package is renaming to design-system-old. Fixes #19536 ## Type of change - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-01-23 03:50:47 +00:00
import { Toaster, Variant } from "design-system-old";
import {
createMessage,
ERROR_ACTION_EXECUTE_FAIL,
ERROR_FAIL_ON_PAGE_LOAD_ACTIONS,
ERROR_PLUGIN_ACTION_EXECUTE,
ACTION_EXECUTION_CANCELLED,
ACTION_EXECUTION_FAILED,
refactor: admin settings (#9906) * refactor admin settings feature * separated save-restart bar to separate component * created new CE dir to facilitate code split * created separate ee dir and exporting everything we have in ce file. * little mod * minor fix * splitting settings types config * using object literals for category types instead of enums * CE: support use of component for each category * minor style fix * authentication page UI changes implemented * github signup doc url added back * removed comments * routing updates * made subcategories listing in left pane optional * added muted saml to auth listing * added breadcrumbs and enabled button * created separate component for auth page and auth config * added callout and disconnect components * updated breadcrumbs component * minor updates to common components * updated warning callout and added icon * ce: test cases fixed * updated test file name * warning banner callout added on auth page * updated callout banner for form login * CE: Split config files * CE: moved the window declaration in EE file as its dependency will be updated in EE * CE: Splitting ApiConstants and SocialLogin constants * CE: split login page * CE: moved getSocialLoginButtonProps func to EE file as it's dependencies will be updated in EE * added key icon * CE: created a factory class to share social auths list * Minor style fix for social btns * Updated the third party auth styles * Small fixes to styling * ce: splitting forms constants * breadcrumbs implemented for all pages in admin settings * Settings breadcrumbs separated * splitted settings breadcrumbs between ce and ee * renamed default import * minor style fix * added login form config. * updated login/signup pages to use form login disabled config * removed common functionality outside * implemented breadcrumb component from scratch without using blueprint * removed unwanted code * Small style update * updated breadcrumb categories file name and breadcrumb icon * added cypress tests for admin settings auth page * added comments * update locator for upgrade button * added link for intercom on upgrade button * removed unnecessary file * minor style fix * style fix for auth option cards * split messages constant * fixed imports for message constants splitting. * added message constants * updated unit test cases * fixed messages import in cypress index * fixed messages import again, cypress fails to read re-exported objs. * added OIDC auth method on authentication page * updated import statements from ee to @appsmith * removed dead code * updated read more link UI * PR comments fixes * some UI fixes * used color and fonts from theme * fixed some imports * fixed some imports * removed warning imports * updated OIDC logo and auth method desc copies * css changes * css changes * css changes * updated cypress test for breadcrumb * moved callout component to ads as calloutv2 * UI changes for form fields * updated css for spacing between form fields * added sub-text on auth pages * added active class for breadcrumb item * added config for disable signup toggle and fixed UI issues of restart banner * fixed admin settings page bugs * assigned true as default state for signup * fixed messages import statements * updated code for PR comments related suggestions * reverted file path change in cypress support * updated cypress test * updated cypress test Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2022-02-11 18:08:46 +00:00
} from "@appsmith/constants/messages";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type {
LayoutOnLoadActionErrors,
PageAction,
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
} from "constants/AppsmithActionConstants/ActionConstants";
import {
EventType,
RESP_HEADER_DATATYPE,
} from "constants/AppsmithActionConstants/ActionConstants";
import {
getCurrentPageId,
getIsSavingEntity,
getLayoutOnLoadActions,
getLayoutOnLoadIssues,
} from "selectors/editorSelectors";
import PerformanceTracker, {
PerformanceTransactionName,
} from "utils/PerformanceTracker";
import * as log from "loglevel";
import { EMPTY_RESPONSE } from "components/editorComponents/ApiResponseView";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { AppState } from "@appsmith/reducers";
import { DEFAULT_EXECUTE_ACTION_TIMEOUT_MS } from "@appsmith/constants/ApiConstants";
import { evaluateActionBindings } from "sagas/EvaluationsSaga";
import { isBlobUrl, parseBlobUrl } from "utils/AppsmithUtils";
import { getType, Types } from "utils/TypeHelpers";
import { matchPath } from "react-router";
import {
feat: adding slug names in urls (#10957) * Init commit clean urls * Changes to builder route * Refactored URLs * Remove default params from url builder functions. * Fixed more urls * Changed selector name * Minor url correction * Type fixes * Jest fixes * Fixed routing for old published apps * Fixed url slug replace * page-1 -> page1 as default page slug name * Remove application id from init editor calls * Use default page slug * Added comments and placeholder values for slug names * variable rename * Removed redirection and added back the old routes * Prevent page slug name recompute * Fixed home page load in view mode * Added null checks * Fixed jest test * Fixed jest test * Update URL slugs when app/page name changes * Added unit tests and updates types * Removed unused code * * Removed duplication fetch page call. * Fixes #11354 * Fixed sign up flow * Refactored initializeEditorSaga * Fixed warnings * Fixed integrations screen URL bugs * Cypress fixes * Fixed slug names in copy/move operations and pages screen * Minor refactor * Fixed page highlight bug in published apps * Added new url factory and middleware to store url params * Changed store to default export and fix unit tests * Fixed slugs unit test * Minor fixes * Fixes #11379 * Fixed set as home page feature * Updated types * app id adjustments for cypress * Fixed bad merge * Refactored routes to functional component * * Fixed EE active entity highlight. * Remove unused code in editor router. * jest fix * Mock history to prevent security errors * constant rename * Removed console logs * Fixed page id regex * Do not check for /pages in url * Fixed missing pageId on quick edit/deploy clicks * Missed files from previous commit * Fixed warnings * Fixed jest test * New api integration * feat: Add applicationVersion property to Application (#11626) Added a new property to Application object - applicationVersion. This property can be used to identity when there is a breaking change and can not be solved with migration. FE will use this property to detect such conditions. Another API is added to migrate the applicationVersion to latest version when user migrates the breaking changes. * Added manual upgrade modal. * Test fix * Fixed jest test * function rename * Fix deploy error * Added null check * Changes to persist URL search params when redirecting * Added updates tooltip * More unit test cases * Fixed git url redirection * Fix warning * Fixed evaluation on upgrade * Fixed warnings * File rename * Added cypress for clean urls * Fixed import/export/fork cypress * Cypress api server fixes * Fixed mongo spec * Fixed replay spec * Fixed comments spec * More cypress fixes * Fixed tooltip in update btn * Text size changes * Minor fixes * Jest test fix * Fixed type error * Fixed warnings * Fixed todo comments * Moved description to constants file * Fixed cypress CI run crash * Fixes git cypress failures * Import/Export cypress test fixes * Import export fork cypress fixes * Explorer test fix * Switch branch test fix * Added applicationVersion in export app json * Calls plugin forms in parallel * Fixed warnings * Fixed warning * Import export CI fixes * Reverts previous changes * Fixes import export * Fixed import export cypress URL verification * Pass applicationVersion when duplicating application * Cypress fix * Dummy commit Co-authored-by: Nayan <nayan@appsmith.com>
2022-03-25 10:43:26 +00:00
API_EDITOR_BASE_PATH,
API_EDITOR_ID_PATH,
API_EDITOR_PATH_WITH_SELECTED_PAGE_ID,
INTEGRATION_EDITOR_PATH,
QUERIES_EDITOR_BASE_PATH,
QUERIES_EDITOR_ID_PATH,
CURL_IMPORT_PAGE_PATH,
} from "constants/routes";
feat: adding slug names in urls (#10957) * Init commit clean urls * Changes to builder route * Refactored URLs * Remove default params from url builder functions. * Fixed more urls * Changed selector name * Minor url correction * Type fixes * Jest fixes * Fixed routing for old published apps * Fixed url slug replace * page-1 -> page1 as default page slug name * Remove application id from init editor calls * Use default page slug * Added comments and placeholder values for slug names * variable rename * Removed redirection and added back the old routes * Prevent page slug name recompute * Fixed home page load in view mode * Added null checks * Fixed jest test * Fixed jest test * Update URL slugs when app/page name changes * Added unit tests and updates types * Removed unused code * * Removed duplication fetch page call. * Fixes #11354 * Fixed sign up flow * Refactored initializeEditorSaga * Fixed warnings * Fixed integrations screen URL bugs * Cypress fixes * Fixed slug names in copy/move operations and pages screen * Minor refactor * Fixed page highlight bug in published apps * Added new url factory and middleware to store url params * Changed store to default export and fix unit tests * Fixed slugs unit test * Minor fixes * Fixes #11379 * Fixed set as home page feature * Updated types * app id adjustments for cypress * Fixed bad merge * Refactored routes to functional component * * Fixed EE active entity highlight. * Remove unused code in editor router. * jest fix * Mock history to prevent security errors * constant rename * Removed console logs * Fixed page id regex * Do not check for /pages in url * Fixed missing pageId on quick edit/deploy clicks * Missed files from previous commit * Fixed warnings * Fixed jest test * New api integration * feat: Add applicationVersion property to Application (#11626) Added a new property to Application object - applicationVersion. This property can be used to identity when there is a breaking change and can not be solved with migration. FE will use this property to detect such conditions. Another API is added to migrate the applicationVersion to latest version when user migrates the breaking changes. * Added manual upgrade modal. * Test fix * Fixed jest test * function rename * Fix deploy error * Added null check * Changes to persist URL search params when redirecting * Added updates tooltip * More unit test cases * Fixed git url redirection * Fix warning * Fixed evaluation on upgrade * Fixed warnings * File rename * Added cypress for clean urls * Fixed import/export/fork cypress * Cypress api server fixes * Fixed mongo spec * Fixed replay spec * Fixed comments spec * More cypress fixes * Fixed tooltip in update btn * Text size changes * Minor fixes * Jest test fix * Fixed type error * Fixed warnings * Fixed todo comments * Moved description to constants file * Fixed cypress CI run crash * Fixes git cypress failures * Import/Export cypress test fixes * Import export fork cypress fixes * Explorer test fix * Switch branch test fix * Added applicationVersion in export app json * Calls plugin forms in parallel * Fixed warnings * Fixed warning * Import export CI fixes * Reverts previous changes * Fixes import export * Fixed import export cypress URL verification * Pass applicationVersion when duplicating application * Cypress fix * Dummy commit Co-authored-by: Nayan <nayan@appsmith.com>
2022-03-25 10:43:26 +00:00
import { SAAS_EDITOR_API_ID_PATH } from "pages/Editor/SaaSEditor/constants";
import { APP_MODE } from "entities/App";
import { FileDataTypes } from "widgets/constants";
import { hideDebuggerErrors } from "actions/debuggerActions";
import {
ActionValidationError,
getErrorAsString,
PluginActionExecutionError,
PluginTriggerFailureError,
UserCancelledActionExecutionError,
} from "sagas/ActionExecution/errorUtils";
import { shouldBeDefined, trimQueryString } from "utils/helpers";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { JSCollection } from "entities/JSCollection";
import { requestModalConfirmationSaga } from "sagas/UtilSagas";
import { ModalType } from "reducers/uiReducers/modalActionReducer";
import { getFormNames, getFormValues } from "redux-form";
import { CURL_IMPORT_FORM } from "@appsmith/constants/forms";
import { submitCurlImportForm } from "actions/importActions";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { curlImportFormValues } from "pages/Editor/APIEditor/helpers";
import { matchBasePath } from "@appsmith/pages/Editor/Explorer/helpers";
import {
isTrueObject,
findDatatype,
} from "@appsmith/workers/Evaluation/evaluationUtils";
import { handleExecuteJSFunctionSaga } from "sagas/JSPaneSagas";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { Plugin } from "api/PluginApi";
import { setDefaultActionDisplayFormat } from "./PluginActionSagaUtils";
import { checkAndLogErrorsIfCyclicDependency } from "sagas/helper";
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { TRunDescription } from "workers/Evaluation/fns/actionFns";
enum ActionResponseDataTypes {
BINARY = "BINARY",
}
export const getActionTimeout = (
state: AppState,
actionId: string,
): number | undefined => {
const action = find(state.entities.actions, (a) => a.config.id === actionId);
if (action) {
const timeout = get(
action,
"config.actionConfiguration.timeoutInMillisecond",
DEFAULT_EXECUTE_ACTION_TIMEOUT_MS,
);
if (timeout) {
// Extra timeout padding to account for network calls
return timeout + 5000;
}
return undefined;
}
return undefined;
};
const createActionExecutionResponse = (
response: ActionExecutionResponse,
): ActionResponse => {
const payload = response.data;
if (payload.statusCode === "200 OK" && payload.hasOwnProperty("headers")) {
const respHeaders = payload.headers;
if (
respHeaders.hasOwnProperty(RESP_HEADER_DATATYPE) &&
respHeaders[RESP_HEADER_DATATYPE].length > 0 &&
respHeaders[RESP_HEADER_DATATYPE][0] === ActionResponseDataTypes.BINARY &&
getType(payload.body) === Types.STRING
) {
// Decoding from base64 to handle the binary files because direct
// conversion of binary files to string causes corruption in the final output
// this is to only handle the download of binary files
payload.body = atob(payload.body as string);
}
}
return {
...payload,
...response.clientMeta,
};
};
const isErrorResponse = (response: ActionExecutionResponse) => {
return !response.data.isExecutionSuccess;
};
/**
*
* @param blobUrl string A blob url with type added a query param
* @returns promise that resolves to file content
*/
function* readBlob(blobUrl: string): any {
const [url, fileType] = parseBlobUrl(blobUrl);
const file = yield fetch(url).then((r) => r.blob());
return yield new Promise((resolve) => {
const reader = new FileReader();
if (fileType === FileDataTypes.Base64) {
reader.readAsDataURL(file);
} else if (fileType === FileDataTypes.Binary) {
reader.readAsBinaryString(file);
} else {
reader.readAsText(file);
}
reader.onloadend = () => {
resolve(reader.result);
};
});
}
/**
* This function resolves :
* - individual objects containing blob urls
* - blob urls directly
* - else returns the value unchanged
* - finds datatype of evaluated value
* - binds dataype to payload
*
* @param value
*/
function* resolvingBlobUrls(
value: any,
executeActionRequest: ExecuteActionRequest,
index: number,
isArray?: boolean,
arrDatatype?: string[],
) {
//Get datatypes of evaluated value.
const dataType: string = findDatatype(value);
//If array elements then dont push datatypes to payload.
isArray
? arrDatatype?.push(dataType)
: (executeActionRequest.paramProperties[`k${index}`] = dataType);
if (isTrueObject(value)) {
const blobUrlPaths: string[] = [];
Object.keys(value).forEach((propertyName) => {
if (isBlobUrl(value[propertyName])) {
blobUrlPaths.push(propertyName);
}
});
for (const blobUrlPath of blobUrlPaths) {
const blobUrl = value[blobUrlPath] as string;
const resolvedBlobValue: unknown = yield call(readBlob, blobUrl);
set(value, blobUrlPath, resolvedBlobValue);
}
} else if (isBlobUrl(value)) {
// @ts-expect-error: Values can take many types
value = yield call(readBlob, value);
}
return value;
}
/**
* Api1
* URL: https://example.com/{{Text1.text}}
* Body: {
* "name": "{{this.params.name}}",
* "age": {{this.params.age}},
* "gender": {{Dropdown1.selectedOptionValue}}
* }
*
* If you call
* Api1.run(undefined, undefined, { name: "Hetu", age: Input1.text });
*
* executionParams is { name: "Hetu", age: Input1.text }
* bindings is [
* "Text1.text",
* "Dropdown1.selectedOptionValue",
* "this.params.name",
* "this.params.age",
* ]
*
* Return will be [
* { key: "Text1.text", value: "updateUser" },
* { key: "Dropdown1.selectedOptionValue", value: "M" },
* { key: "this.params.name", value: "Hetu" },
* { key: "this.params.age", value: 26 },
* ]
* @param bindings
* @param executionParams
*/
function* evaluateActionParams(
bindings: string[] | undefined,
formData: FormData,
executeActionRequest: ExecuteActionRequest,
executionParams?: Record<string, any> | string,
) {
if (isNil(bindings) || bindings.length === 0) {
formData.append("executeActionDTO", JSON.stringify(executeActionRequest));
return [];
}
// Evaluated all bindings of the actions. Pass executionParams if any
// @ts-expect-error: Values can take many types
const values = yield call(evaluateActionBindings, bindings, executionParams);
const bindingsMap: Record<string, string> = {};
const bindingBlob = [];
// Add keys values to formData for the multipart submission
for (let i = 0; i < bindings.length; i++) {
const key = bindings[i];
let value = values[i];
if (isArray(value)) {
const tempArr = [];
const arrDatatype: string[] = [];
// array of objects containing blob urls that is loops and individual object is checked for resolution of blob urls.
for (const val of value) {
const newVal: unknown = yield call(
resolvingBlobUrls,
val,
executeActionRequest,
i,
true,
arrDatatype,
);
tempArr.push(newVal);
}
//Adding array datatype along with the datatype of first element of the array
executeActionRequest.paramProperties[`k${i}`] = {
array: [arrDatatype[0]],
};
value = tempArr;
} else {
// @ts-expect-error: Values can take many types
value = yield call(resolvingBlobUrls, value, executeActionRequest, i);
}
if (typeof value === "object") {
value = JSON.stringify(value);
}
value = new Blob([value], { type: "text/plain" });
bindingsMap[key] = `k${i}`;
bindingBlob.push({ name: `k${i}`, value: value });
}
formData.append("executeActionDTO", JSON.stringify(executeActionRequest));
formData.append("parameterMap", JSON.stringify(bindingsMap));
bindingBlob?.forEach((item) => formData.append(item.name, item.value));
}
export default function* executePluginActionTriggerSaga(
fix: access outer scope variables inside callbacks (#20168) ## Description Any platform function that accepts a callback were unable to access the variables declared in its parent scopes. This was a implementation miss when we originally designed platform functions and again when we turned almost every platform function into a Promise. This PR fixes this limitation along with some other edge cases. - Access outer scope variables inside the callback of run, postMessage, setInterval, getGeoLocation and watchGeolocation functions. - Fixes certain edge cases where functions with callbacks when called inside the then block doesn't get executed. Eg `showAlert.then(() => /* Doesn't execute */ Api1.run(() => {}))` - Changes the implementation of all the platform function in appsmith to maintain the execution metadata (info on from where a function was invoked, event associated with it etc) #### Refactor changes - Added a new folder **_fns_** that would now hold all the platform functions. - Introduced a new ExecutionMetadata singleton class that is now responsible for hold all the meta data related to the current evaluation. - Remove TRIGGER_COLLECTOR array where all callback based platform functions were batched and introduced an Event Emitter based implementation to handle batched fn calls. - All callback based functions now emits event when invoked. These events have handlers attached to the TriggerEmitter object. These handler does the job of batching these invocations and telling the main thread. It also ensures that platform fn calls that gets triggered out the the context of a request/response cycle work. #### Architecture <img width="751" alt="Screenshot 2023-02-07 at 10 04 26" src="https://user-images.githubusercontent.com/32433245/217259200-5eac71bc-f0d3-4d3c-9b69-2a8dc81351bc.png"> Fixes #13156 Fixes #20225 ## Type of change - Bug fix (non-breaking change which fixes an issue) - Refactor ## How Has This Been Tested? - Jest - Cypress - Manual ### Test Plan - [ ] https://github.com/appsmithorg/TestSmith/issues/2181 - [ ] https://github.com/appsmithorg/TestSmith/issues/2182 - [ ] Post message - https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/post-msg-app/page1-635fcfba2987b442a739b938/edit - [ ] Apps: https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/earworm-1/home-630c9d85b4658d0f257c4987/edit - [ ] https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/automation-test-cases/page-1-630c6b90d4ecd573f6bb01e9/edit#0hmn8m90ei ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reviewing all Cypress test
2023-02-11 18:33:20 +00:00
pluginAction: TRunDescription,
eventType: EventType,
) {
fix: access outer scope variables inside callbacks (#20168) ## Description Any platform function that accepts a callback were unable to access the variables declared in its parent scopes. This was a implementation miss when we originally designed platform functions and again when we turned almost every platform function into a Promise. This PR fixes this limitation along with some other edge cases. - Access outer scope variables inside the callback of run, postMessage, setInterval, getGeoLocation and watchGeolocation functions. - Fixes certain edge cases where functions with callbacks when called inside the then block doesn't get executed. Eg `showAlert.then(() => /* Doesn't execute */ Api1.run(() => {}))` - Changes the implementation of all the platform function in appsmith to maintain the execution metadata (info on from where a function was invoked, event associated with it etc) #### Refactor changes - Added a new folder **_fns_** that would now hold all the platform functions. - Introduced a new ExecutionMetadata singleton class that is now responsible for hold all the meta data related to the current evaluation. - Remove TRIGGER_COLLECTOR array where all callback based platform functions were batched and introduced an Event Emitter based implementation to handle batched fn calls. - All callback based functions now emits event when invoked. These events have handlers attached to the TriggerEmitter object. These handler does the job of batching these invocations and telling the main thread. It also ensures that platform fn calls that gets triggered out the the context of a request/response cycle work. #### Architecture <img width="751" alt="Screenshot 2023-02-07 at 10 04 26" src="https://user-images.githubusercontent.com/32433245/217259200-5eac71bc-f0d3-4d3c-9b69-2a8dc81351bc.png"> Fixes #13156 Fixes #20225 ## Type of change - Bug fix (non-breaking change which fixes an issue) - Refactor ## How Has This Been Tested? - Jest - Cypress - Manual ### Test Plan - [ ] https://github.com/appsmithorg/TestSmith/issues/2181 - [ ] https://github.com/appsmithorg/TestSmith/issues/2182 - [ ] Post message - https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/post-msg-app/page1-635fcfba2987b442a739b938/edit - [ ] Apps: https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/earworm-1/home-630c9d85b4658d0f257c4987/edit - [ ] https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/automation-test-cases/page-1-630c6b90d4ecd573f6bb01e9/edit#0hmn8m90ei ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reviewing all Cypress test
2023-02-11 18:33:20 +00:00
const { payload: pluginPayload } = pluginAction;
const { actionId, onError, params } = pluginPayload;
if (getType(params) !== Types.OBJECT) {
throw new ActionValidationError(
"RUN_PLUGIN_ACTION",
"params",
Types.OBJECT,
getType(params),
);
}
PerformanceTracker.startAsyncTracking(
PerformanceTransactionName.EXECUTE_ACTION,
{
actionId: actionId,
},
actionId,
);
const appMode: APP_MODE | undefined = yield select(getAppMode);
const action = shouldBeDefined<Action>(
yield select(getAction, actionId),
`Action not found for id - ${actionId}`,
);
const currentApp: ApplicationPayload = yield select(getCurrentApplication);
AnalyticsUtil.logEvent("EXECUTE_ACTION", {
type: action?.pluginType,
name: action?.name,
pageId: action?.pageId,
appId: currentApp.id,
appMode: appMode,
appName: currentApp.name,
isExampleApp: currentApp.appIsExample,
});
const pagination =
eventType === EventType.ON_NEXT_PAGE
? "NEXT"
: eventType === EventType.ON_PREV_PAGE
? "PREV"
: undefined;
AppsmithConsole.info({
text: "Execution started from widget request",
source: {
type: ENTITY_TYPE.ACTION,
name: action.name,
id: actionId,
},
state: action.actionConfiguration,
});
const executePluginActionResponse: ExecutePluginActionResponse = yield call(
executePluginActionSaga,
action.id,
pagination,
params,
);
const { isError, payload } = executePluginActionResponse;
if (isError) {
AppsmithConsole.addErrors([
{
payload: {
id: actionId,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
iconId: action.pluginId,
logType: LOG_TYPE.ACTION_EXECUTION_ERROR,
text: `Execution failed with status ${payload.statusCode}`,
source: {
type: ENTITY_TYPE.ACTION,
name: action.name,
id: actionId,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
httpMethod: action.actionConfiguration.httpMethod,
pluginType: action.pluginType,
},
state: payload.request,
messages: [
{
// Need to stringify cause this gets rendered directly
// and rendering objects can crash the app
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
message: {
name: "PluginExecutionError",
message: !isString(payload.body)
? JSON.stringify(payload.body)
: payload.body,
},
type: PLATFORM_ERROR.PLUGIN_EXECUTION,
subType: payload.errorType,
},
],
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
pluginErrorDetails: payload.pluginErrorDetails,
},
},
]);
if (onError) {
throw new PluginTriggerFailureError(
createMessage(ERROR_ACTION_EXECUTE_FAIL, action.name),
[payload.body, params],
);
} else {
throw new PluginTriggerFailureError(
createMessage(ERROR_PLUGIN_ACTION_EXECUTE, action.name),
fix: access outer scope variables inside callbacks (#20168) ## Description Any platform function that accepts a callback were unable to access the variables declared in its parent scopes. This was a implementation miss when we originally designed platform functions and again when we turned almost every platform function into a Promise. This PR fixes this limitation along with some other edge cases. - Access outer scope variables inside the callback of run, postMessage, setInterval, getGeoLocation and watchGeolocation functions. - Fixes certain edge cases where functions with callbacks when called inside the then block doesn't get executed. Eg `showAlert.then(() => /* Doesn't execute */ Api1.run(() => {}))` - Changes the implementation of all the platform function in appsmith to maintain the execution metadata (info on from where a function was invoked, event associated with it etc) #### Refactor changes - Added a new folder **_fns_** that would now hold all the platform functions. - Introduced a new ExecutionMetadata singleton class that is now responsible for hold all the meta data related to the current evaluation. - Remove TRIGGER_COLLECTOR array where all callback based platform functions were batched and introduced an Event Emitter based implementation to handle batched fn calls. - All callback based functions now emits event when invoked. These events have handlers attached to the TriggerEmitter object. These handler does the job of batching these invocations and telling the main thread. It also ensures that platform fn calls that gets triggered out the the context of a request/response cycle work. #### Architecture <img width="751" alt="Screenshot 2023-02-07 at 10 04 26" src="https://user-images.githubusercontent.com/32433245/217259200-5eac71bc-f0d3-4d3c-9b69-2a8dc81351bc.png"> Fixes #13156 Fixes #20225 ## Type of change - Bug fix (non-breaking change which fixes an issue) - Refactor ## How Has This Been Tested? - Jest - Cypress - Manual ### Test Plan - [ ] https://github.com/appsmithorg/TestSmith/issues/2181 - [ ] https://github.com/appsmithorg/TestSmith/issues/2182 - [ ] Post message - https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/post-msg-app/page1-635fcfba2987b442a739b938/edit - [ ] Apps: https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/earworm-1/home-630c9d85b4658d0f257c4987/edit - [ ] https://appsmith-git-chore-outer-scope-variable-access-get-appsmith.vercel.app/app/automation-test-cases/page-1-630c6b90d4ecd573f6bb01e9/edit#0hmn8m90ei ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reviewing all Cypress test
2023-02-11 18:33:20 +00:00
[],
);
}
} else {
AppsmithConsole.info({
logType: LOG_TYPE.ACTION_EXECUTION_SUCCESS,
text: "Executed successfully from widget request",
timeTaken: payload.duration,
source: {
type: ENTITY_TYPE.ACTION,
name: action.name,
id: actionId,
},
state: {
response: payload.body,
request: payload.request,
},
});
}
return [payload.body, params];
}
function* runActionShortcutSaga() {
const pathname = window.location.pathname;
const baseMatch = matchBasePath(pathname);
if (!baseMatch) return;
// get gitSyncModal status
const isGitSyncModalOpen: boolean = yield select(getIsGitSyncModalOpen);
// if git sync modal is open, prevent action from being executed via shortcut keys.
if (isGitSyncModalOpen) return;
const { path } = baseMatch;
const match: any = matchPath(pathname, {
path: [
trimQueryString(`${path}${API_EDITOR_BASE_PATH}`),
trimQueryString(`${path}${API_EDITOR_ID_PATH}`),
trimQueryString(`${path}${QUERIES_EDITOR_BASE_PATH}`),
trimQueryString(`${path}${QUERIES_EDITOR_ID_PATH}`),
trimQueryString(`${path}${API_EDITOR_PATH_WITH_SELECTED_PAGE_ID}`),
trimQueryString(`${path}${INTEGRATION_EDITOR_PATH}`),
trimQueryString(`${path}${SAAS_EDITOR_API_ID_PATH}`),
`${path}${CURL_IMPORT_PAGE_PATH}`,
],
exact: true,
strict: false,
});
// get the current form name
const currentFormNames: string[] = yield select(getFormNames());
if (!match || !match.params) return;
const { apiId, pageId, queryId } = match.params;
const actionId = apiId || queryId;
if (actionId) {
const trackerId = apiId
? PerformanceTransactionName.RUN_API_SHORTCUT
: PerformanceTransactionName.RUN_QUERY_SHORTCUT;
PerformanceTracker.startTracking(trackerId, {
actionId,
pageId,
});
AnalyticsUtil.logEvent(trackerId as EventName, {
actionId,
});
yield put(runAction(actionId));
} else if (
!!currentFormNames &&
currentFormNames.includes(CURL_IMPORT_FORM) &&
!actionId
) {
// if the current form names include the curl form and there are no actionIds i.e. its not an api or query
// get the form values and call the submit curl import form function with its data
const formValues: curlImportFormValues = yield select(
getFormValues(CURL_IMPORT_FORM),
);
// if the user has not edited the curl input field, assign an empty string to it, so it doesnt throw an error.
if (!formValues?.curl) formValues["curl"] = "";
yield put(submitCurlImportForm(formValues));
} else {
return;
}
}
function* runActionSaga(
reduxAction: ReduxAction<{
id: string;
paginationField: PaginationField;
}>,
) {
const actionId = reduxAction.payload.id;
const isSaving: boolean = yield select(isActionSaving(actionId));
const isDirty: boolean = yield select(isActionDirty(actionId));
const isSavingEntity: boolean = yield select(getIsSavingEntity);
if (isSaving || isDirty || isSavingEntity) {
if (isDirty && !isSaving) {
yield put(updateAction({ id: actionId }));
yield take(ReduxActionTypes.UPDATE_ACTION_SUCCESS);
}
}
const actionObject = shouldBeDefined<Action>(
yield select(getAction, actionId),
`action not found for id - ${actionId}`,
);
const datasourceUrl = get(
actionObject,
"datasource.datasourceConfiguration.url",
);
AppsmithConsole.info({
text: "Execution started from user request",
source: {
type: ENTITY_TYPE.ACTION,
name: actionObject.name,
id: actionId,
},
state: {
...actionObject.actionConfiguration,
...(datasourceUrl && {
url: datasourceUrl,
}),
},
});
const { id, paginationField } = reduxAction.payload;
let payload = EMPTY_RESPONSE;
let isError = true;
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
let error = { name: "", message: "" };
try {
const executePluginActionResponse: ExecutePluginActionResponse = yield call(
executePluginActionSaga,
id,
paginationField,
);
payload = executePluginActionResponse.payload;
isError = executePluginActionResponse.isError;
} catch (e) {
// When running from the pane, we just want to end the saga if the user has
// cancelled the call. No need to log any errors
if (e instanceof UserCancelledActionExecutionError) {
// cancel action but do not throw any error.
yield put({
type: ReduxActionErrorTypes.RUN_ACTION_ERROR,
payload: {
error: e.name,
id: reduxAction.payload.id,
show: false,
},
});
Toaster.show({
text: createMessage(ACTION_EXECUTION_CANCELLED, actionObject.name),
variant: Variant.danger,
});
return;
}
log.error(e);
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
error = { name: (e as Error).name, message: (e as Error).message };
}
// Error should be readable error if present.
// Otherwise, payload's body.
// Default to "An unexpected error occurred" if none is available
const readableError = payload.readableError
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
? {
name: "PluginExecutionError",
message: getErrorAsString(payload.readableError),
}
: undefined;
const payloadBodyError = payload.body
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
? {
name: "PluginExecutionError",
message: getErrorAsString(payload.body),
}
: undefined;
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
const defaultError = {
name: "PluginExecutionError",
message: "An unexpected error occurred",
};
if (isError) {
error = readableError || payloadBodyError || defaultError;
// In case of debugger, both the current error message
// and the readableError needs to be present,
// since the readableError may be malformed for certain errors.
const appsmithConsoleErrorMessageList = [
{
message: error,
type: PLATFORM_ERROR.PLUGIN_EXECUTION,
subType: payload.errorType,
},
];
if (error === readableError && !!payloadBodyError) {
appsmithConsoleErrorMessageList.push({
message: payloadBodyError,
type: PLATFORM_ERROR.PLUGIN_EXECUTION,
subType: payload.errorType,
});
}
AppsmithConsole.addErrors([
{
payload: {
id: actionId,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
iconId: actionObject.pluginId,
logType: LOG_TYPE.ACTION_EXECUTION_ERROR,
text: `Execution failed${
payload.statusCode ? ` with status ${payload.statusCode}` : ""
}`,
source: {
type: ENTITY_TYPE.ACTION,
name: actionObject.name,
id: actionId,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
httpMethod: actionObject.actionConfiguration.httpMethod,
pluginType: actionObject.pluginType,
},
messages: appsmithConsoleErrorMessageList,
state: payload.request,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
pluginErrorDetails: payload.pluginErrorDetails,
},
},
]);
Toaster.show({
text: createMessage(ERROR_ACTION_EXECUTE_FAIL, actionObject.name),
variant: Variant.danger,
});
yield put({
type: ReduxActionErrorTypes.RUN_ACTION_ERROR,
payload: {
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
error: appsmithConsoleErrorMessageList[0].message,
id: reduxAction.payload.id,
},
});
return;
}
const pageName: string = yield select(getCurrentPageNameByActionId, actionId);
let eventName: EventName = "RUN_API";
if (actionObject.pluginType === PluginType.DB) {
eventName = "RUN_QUERY";
}
if (actionObject.pluginType === PluginType.SAAS) {
eventName = "RUN_SAAS_API";
}
AnalyticsUtil.logEvent(eventName, {
actionId,
actionName: actionObject.name,
pageName: pageName,
responseTime: payload.duration,
apiType: "INTERNAL",
});
yield put({
type: ReduxActionTypes.RUN_ACTION_SUCCESS,
payload: { [actionId]: payload },
});
if (payload.isExecutionSuccess) {
AppsmithConsole.info({
logType: LOG_TYPE.ACTION_EXECUTION_SUCCESS,
text: "Executed successfully from user request",
timeTaken: payload.duration,
source: {
type: ENTITY_TYPE.ACTION,
name: actionObject.name,
id: actionId,
},
state: {
response: payload.body,
request: payload.request,
},
});
}
}
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
function* executeOnPageLoadJSAction(pageAction: PageAction) {
const collectionId = pageAction.collectionId;
if (collectionId) {
const collection: JSCollection = yield select(
getJSCollection,
collectionId,
);
const jsAction = collection.actions.find(
(action) => action.id === pageAction.id,
);
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
if (!!jsAction) {
if (jsAction.confirmBeforeExecute) {
const modalPayload = {
name: pageAction.name,
modalOpen: true,
modalType: ModalType.RUN_ACTION,
};
const confirmed: unknown = yield call(
requestModalConfirmationSaga,
modalPayload,
);
if (!confirmed) {
yield put({
type: ReduxActionTypes.RUN_ACTION_CANCELLED,
payload: { id: pageAction.id },
});
Toaster.show({
text: createMessage(
ACTION_EXECUTION_CANCELLED,
`${collection.name}.${jsAction.name}`,
),
variant: Variant.danger,
});
// Don't proceed to executing the js function
return;
}
}
const data = {
collectionName: collection.name,
action: jsAction,
collectionId: collectionId,
};
yield call(handleExecuteJSFunctionSaga, data);
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
}
}
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
}
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
function* executePageLoadAction(pageAction: PageAction) {
if (pageAction.hasOwnProperty("collectionId")) {
yield call(executeOnPageLoadJSAction, pageAction);
} else {
const pageId: string | undefined = yield select(getCurrentPageId);
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
let currentApp: ApplicationPayload = yield select(getCurrentApplication);
currentApp = currentApp || {};
const appMode: APP_MODE | undefined = yield select(getAppMode);
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
AnalyticsUtil.logEvent("EXECUTE_ACTION", {
type: pageAction.pluginType,
name: pageAction.name,
pageId: pageId,
appMode: appMode,
appId: currentApp.id,
onPageLoad: true,
appName: currentApp.name,
isExampleApp: currentApp.appIsExample,
});
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
// action is required to fetch the pluginId and pluginType.
const action = shouldBeDefined<Action>(
yield select(getAction, pageAction.id),
`action not found for id - ${pageAction.id}`,
);
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
let payload = EMPTY_RESPONSE;
let isError = true;
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
let error = {
name: "PluginExecutionError",
message: createMessage(ACTION_EXECUTION_FAILED, pageAction.name),
};
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
try {
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com> ## Description This PR upgrades Prettier to v2 + enforces TypeScript’s [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax where applicable. It’s submitted as a separate PR so we can merge it easily. As a part of this PR, we reformat the codebase heavily: - add `import type` everywhere where it’s required, and - re-format the code to account for Prettier 2’s breaking changes: https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes This PR is submitted against `release` to make sure all new code by team members will adhere to new formatting standards, and we’ll have fewer conflicts when merging `bundle-optimizations` into `release`. (I’ll merge `release` back into `bundle-optimizations` once this PR is merged.) ### Why is this needed? This PR is needed because, for the Lodash optimization from https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3, we need to use `import type`. Otherwise, `babel-plugin-lodash` complains that `LoDashStatic` is not a lodash function. However, just using `import type` in the current codebase will give you this: <img width="962" alt="Screenshot 2023-03-08 at 17 45 59" src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png"> That’s because Prettier 1 can’t parse `import type` at all. To parse it, we need to upgrade to Prettier 2. ### Why enforce `import type`? Apart from just enabling `import type` support, this PR enforces specifying `import type` everywhere it’s needed. (Developers will get immediate TypeScript and ESLint errors when they forget to do so.) I’m doing this because I believe `import type` improves DX and makes refactorings easier. Let’s say you had a few imports like below. Can you tell which of these imports will increase the bundle size? (Tip: it’s not all of them!) ```ts // app/client/src/workers/Linting/utils.ts import { Position } from "codemirror"; import { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` It’s pretty hard, right? What about now? ```ts // app/client/src/workers/Linting/utils.ts import type { Position } from "codemirror"; import type { LintError as JSHintError, LintOptions } from "jshint"; import { get, isEmpty, isNumber, keys, last, set } from "lodash"; ``` Now, it’s clear that only `lodash` will be bundled. This helps developers to see which imports are problematic, but it _also_ helps with refactorings. Now, if you want to see where `codemirror` is bundled, you can just grep for `import \{.*\} from "codemirror"` – and you won’t get any type-only imports. This also helps (some) bundlers. Upon transpiling, TypeScript erases type-only imports completely. In some environment (not ours), this makes the bundle smaller, as the bundler doesn’t need to bundle type-only imports anymore. ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? This was tested to not break the build. ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
const executePluginActionResponse: ExecutePluginActionResponse =
yield call(executePluginActionSaga, pageAction);
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
payload = executePluginActionResponse.payload;
isError = executePluginActionResponse.isError;
} catch (e) {
log.error(e);
if (e instanceof UserCancelledActionExecutionError) {
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
error = {
name: "PluginExecutionError",
message: createMessage(ACTION_EXECUTION_CANCELLED, pageAction.name),
};
}
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
}
if (isError) {
AppsmithConsole.addErrors([
{
payload: {
id: pageAction.id,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
iconId: action.pluginId,
logType: LOG_TYPE.ACTION_EXECUTION_ERROR,
text: `Execution failed with status ${payload.statusCode}`,
source: {
type: ENTITY_TYPE.ACTION,
name: pageAction.name,
id: pageAction.id,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
httpMethod: action.actionConfiguration.httpMethod,
pluginType: action.pluginType,
},
state: payload.request,
messages: [
{
message: error,
type: PLATFORM_ERROR.PLUGIN_EXECUTION,
subType: payload.errorType,
},
],
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
pluginErrorDetails: payload.pluginErrorDetails,
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
},
},
]);
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
yield put(
executePluginActionError({
actionId: pageAction.id,
isPageLoad: true,
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
error: { message: error.message },
feat: Settings js editor (#9984) * POC * Closing channels * WIP * v1 * get working with JS editor * autocomplete * added comments * try removing an import * different way of import * dependency map added to body * triggers can be part of js editor functions hence * removed unwanted lines * new flow chnages * Resolve conflicts * small css changes for empty state * Fix prettier * Fixes * flow changes part 2 * Mock web worker for testing * Throw errors during evaluation * Action execution should be non blocking on the main thread to evaluation of further actions * WIP * Fix build issue * Fix warnings * Rename * Refactor and add tests for worker util * Fix response flow post refactor * added settings icon for js editor * WIP * WIP * WIP * Tests for promises * settings for each function of js object added * Error handling * Error handing action validation * Update test * Passing callback data in the eval trigger flow * log triggers to be executed * WIP * confirm before execution * Remove debugging * Fix backwards compatibility * Avoid passing trigger meta around * fix button loading * handle error callbacks * fix tests * tests * fix console error when checking for async * Fix async function check * Fix async function check again * fix bad commit * Add some comments * added clientSideExecution flag for js functions * css changes for settings icon * unsued code removed * on page load PART 1 * onPageLoad rest iof changes * corrected async badge * removed duplicate test cases * added confirm modal for js functions * removed unused code * small chnage * dependency was not getting created * Fix confirmation modal * unused code removed * replaced new confirmsaga * confirmaton box changes * Fixing JSEditor Run butn locator * corrected property * dependency map was failing * changed key for confirmation box Co-authored-by: hetunandu <hetu@appsmith.com> Co-authored-by: Hetu Nandu <hetunandu@gmail.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-03-17 12:05:17 +00:00
data: payload,
}),
);
PerformanceTracker.stopAsyncTracking(
PerformanceTransactionName.EXECUTE_ACTION,
{
failed: true,
},
pageAction.id,
);
} else {
PerformanceTracker.stopAsyncTracking(
PerformanceTransactionName.EXECUTE_ACTION,
undefined,
pageAction.id,
);
yield put(
executePluginActionSuccess({
id: pageAction.id,
response: payload,
isPageLoad: true,
}),
);
yield take(ReduxActionTypes.SET_EVALUATED_TREE);
}
}
}
function* executePageLoadActionsSaga() {
try {
const pageActions: PageAction[][] = yield select(getLayoutOnLoadActions);
const layoutOnLoadActionErrors: LayoutOnLoadActionErrors[] = yield select(
getLayoutOnLoadIssues,
);
const actionCount = flatten(pageActions).length;
// when cyclical depedency issue is there,
// none of the page load actions would be executed
PerformanceTracker.startAsyncTracking(
PerformanceTransactionName.EXECUTE_PAGE_LOAD_ACTIONS,
{ numActions: actionCount },
);
for (const actionSet of pageActions) {
// Load all sets in parallel
// @ts-expect-error: no idea how to type this
yield* yield all(
actionSet.map((apiAction) => call(executePageLoadAction, apiAction)),
);
}
PerformanceTracker.stopAsyncTracking(
PerformanceTransactionName.EXECUTE_PAGE_LOAD_ACTIONS,
);
// We show errors in the debugger once onPageLoad actions
// are executed
yield put(hideDebuggerErrors(false));
checkAndLogErrorsIfCyclicDependency(layoutOnLoadActionErrors);
} catch (e) {
log.error(e);
Toaster.show({
text: createMessage(ERROR_FAIL_ON_PAGE_LOAD_ACTIONS),
variant: Variant.danger,
});
}
}
type ExecutePluginActionResponse = {
payload: ActionResponse;
isError: boolean;
};
/*
* This saga handles the complete plugin action execution flow. It will respond with a
* payload and isError property which indicates if the response is of an error type.
* In case of the execution was not completed, it will throw errors of type
* PluginActionExecutionError which needs to be handled by any saga that calls this.
* */
function* executePluginActionSaga(
actionOrActionId: PageAction | string,
paginationField?: PaginationField,
params?: Record<string, unknown>,
) {
let pluginAction;
let actionId;
if (isString(actionOrActionId)) {
// @ts-expect-error: plugin Action can take many types
pluginAction = yield select(getAction, actionOrActionId);
actionId = actionOrActionId;
} else {
pluginAction = shouldBeDefined<Action>(
yield select(getAction, actionOrActionId.id),
`Action not found for id -> ${actionOrActionId.id}`,
);
actionId = actionOrActionId.id;
}
if (pluginAction.confirmBeforeExecute) {
const modalPayload = {
name: pluginAction.name,
modalOpen: true,
modalType: ModalType.RUN_ACTION,
};
const confirmed: unknown = yield call(
requestModalConfirmationSaga,
modalPayload,
);
if (!confirmed) {
yield put({
type: ReduxActionTypes.RUN_ACTION_CANCELLED,
payload: { id: actionId },
});
throw new UserCancelledActionExecutionError();
}
}
PerformanceTracker.startAsyncTracking(
PerformanceTransactionName.EXECUTE_ACTION,
{
actionId: actionId,
},
actionId,
);
yield put(executePluginActionRequest({ id: actionId }));
const appMode: APP_MODE | undefined = yield select(getAppMode);
const timeout: number | undefined = yield select(getActionTimeout, actionId);
const executeActionRequest: ExecuteActionRequest = {
actionId: actionId,
viewMode: appMode === APP_MODE.PUBLISHED,
paramProperties: {},
};
if (paginationField) {
executeActionRequest.paginationField = paginationField;
}
const formData = new FormData();
yield call(
evaluateActionParams,
pluginAction.jsonPathKeys,
formData,
executeActionRequest,
params,
);
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
let payload = EMPTY_RESPONSE;
let response: ActionExecutionResponse;
try {
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
response = yield ActionAPI.executeAction(formData, timeout);
PerformanceTracker.stopAsyncTracking(
PerformanceTransactionName.EXECUTE_ACTION,
);
yield validateResponse(response);
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
payload = createActionExecutionResponse(response);
yield put(
executePluginActionSuccess({
id: actionId,
response: payload,
}),
);
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
// TODO: Plugins are not always fetched before on page load actions are executed.
try {
let plugin: Plugin | undefined;
if (!!pluginAction.pluginId) {
plugin = shouldBeDefined<Plugin>(
yield select(getPlugin, pluginAction.pluginId),
`Plugin not found for id - ${pluginAction.pluginId}`,
);
}
feat: Error handling phase 1 (#20629) ## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
2023-02-18 12:55:46 +00:00
// sets the default display format for action response e.g Raw, Json or Table
yield setDefaultActionDisplayFormat(actionId, plugin, payload);
} catch (e) {
log.error("plugin no found", e);
}
return {
payload,
isError: isErrorResponse(response),
};
} catch (e) {
yield put(
executePluginActionSuccess({
id: actionId,
response: EMPTY_RESPONSE,
}),
);
if (e instanceof UserCancelledActionExecutionError) {
throw new UserCancelledActionExecutionError();
}
throw new PluginActionExecutionError("Response not valid", false);
}
}
export function* watchPluginActionExecutionSagas() {
yield all([
takeLatest(ReduxActionTypes.RUN_ACTION_REQUEST, runActionSaga),
takeLatest(
ReduxActionTypes.RUN_ACTION_SHORTCUT_REQUEST,
runActionShortcutSaga,
),
takeLatest(
ReduxActionTypes.EXECUTE_PAGE_LOAD_ACTIONS,
executePageLoadActionsSaga,
),
]);
}