2021-12-07 09:45:18 +00:00
|
|
|
import {
|
2023-01-28 02:17:06 +00:00
|
|
|
all,
|
|
|
|
|
call,
|
|
|
|
|
delay,
|
2021-12-07 09:45:18 +00:00
|
|
|
put,
|
|
|
|
|
select,
|
2023-01-28 02:17:06 +00:00
|
|
|
takeEvery,
|
2021-12-07 09:45:18 +00:00
|
|
|
takeLatest,
|
|
|
|
|
} from "redux-saga/effects";
|
2021-09-21 07:55:56 +00:00
|
|
|
|
|
|
|
|
import * as Sentry from "@sentry/react";
|
|
|
|
|
import log from "loglevel";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
getCurrentWidgetId,
|
2023-01-28 02:17:06 +00:00
|
|
|
getIsPropertyPaneVisible,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "selectors/propertyPaneSelectors";
|
2021-11-23 08:01:46 +00:00
|
|
|
import { closePropertyPane } from "actions/widgetActions";
|
2023-01-28 02:17:06 +00:00
|
|
|
import { selectWidgetInitAction } from "actions/widgetSelectionActions";
|
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 {
|
2021-12-07 09:45:18 +00:00
|
|
|
ReduxAction,
|
2021-09-21 07:55:56 +00:00
|
|
|
ReplayReduxActionTypes,
|
2022-04-12 10:50:01 +00:00
|
|
|
} 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 { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
|
2021-09-21 07:55:56 +00:00
|
|
|
import { flashElementsById } from "utils/helpers";
|
|
|
|
|
import {
|
2023-01-28 02:17:06 +00:00
|
|
|
expandAccordion,
|
2021-12-07 09:45:18 +00:00
|
|
|
highlightReplayElement,
|
2023-01-28 02:17:06 +00:00
|
|
|
processUndoRedoToasts,
|
|
|
|
|
scrollWidgetIntoView,
|
2021-12-07 09:45:18 +00:00
|
|
|
switchTab,
|
2021-09-21 07:55:56 +00:00
|
|
|
} from "utils/replayHelpers";
|
2024-04-19 09:36:50 +00:00
|
|
|
import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil";
|
2022-05-04 09:45:57 +00:00
|
|
|
import {
|
|
|
|
|
getCurrentApplicationId,
|
|
|
|
|
snipingModeSelector,
|
|
|
|
|
} from "selectors/editorSelectors";
|
2021-12-07 09:45:18 +00:00
|
|
|
import { findFieldInfo, REPLAY_FOCUS_DELAY } from "entities/Replay/replayUtils";
|
|
|
|
|
import { setActionProperty, updateAction } from "actions/pluginActionActions";
|
|
|
|
|
import { getEntityInCurrentPath } from "./RecentEntitiesSagas";
|
|
|
|
|
import { updateJSCollectionBody } from "actions/jsPaneActions";
|
|
|
|
|
import {
|
|
|
|
|
updateReplayEntitySaga,
|
|
|
|
|
workerComputeUndoRedo,
|
|
|
|
|
} from "./EvaluationsSaga";
|
|
|
|
|
import { createBrowserHistory } from "history";
|
|
|
|
|
import {
|
2023-07-12 06:42:16 +00:00
|
|
|
getDatasource,
|
2021-12-07 09:45:18 +00:00
|
|
|
getEditorConfig,
|
|
|
|
|
getPluginForm,
|
2023-07-12 06:42:16 +00:00
|
|
|
getPlugins,
|
2021-12-07 09:45:18 +00:00
|
|
|
getSettingConfig,
|
2023-09-12 11:51:39 +00:00
|
|
|
} from "@appsmith/selectors/entitiesSelector";
|
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 { Action } from "entities/Action";
|
2024-01-16 14:49:08 +00:00
|
|
|
import {
|
|
|
|
|
isAIAction,
|
|
|
|
|
isAPIAction,
|
|
|
|
|
isQueryAction,
|
|
|
|
|
isSaaSAction,
|
|
|
|
|
} from "entities/Action";
|
2022-09-09 15:59:47 +00:00
|
|
|
import { API_EDITOR_TABS } from "constants/ApiEditorConstants/CommonApiConstants";
|
2021-12-07 09:45:18 +00:00
|
|
|
import { EDITOR_TABS } from "constants/QueryEditorConstants";
|
|
|
|
|
import _, { isEmpty } from "lodash";
|
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 { ReplayEditorUpdate } from "entities/Replay/ReplayEntity/ReplayEditor";
|
chore: Import debugger fixes (#31080)
## Description
To add debugger error for import path for module instance on EE, this PR
enables code to be extended on EE
#### PR fixes following issue(s)
Fixes # (issue number)
> if no issue exists, please create an issue and ask the maintainers
about this first
>
>
#### 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
> Please delete options that are not relevant.
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- Chore (housekeeping or task changes that don't impact user perception)
- This change requires a documentation update
>
>
>
## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [ ] Manual
- [ ] JUnit
- [ ] 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
- [ ] 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
- [ ] 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:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Refactor**
- Updated import paths and references for `ENTITY_TYPE` to
`EntityTypeValue` across various components and utilities for improved
code consistency.
- Reorganized import statements related to `AppsmithConsole` utilities
and constants to enhance code maintainability.
- Adjusted usage of enums and types, specifically for entity and
platform error handling, to align with updated import paths.
- **New Features**
- Introduced utility functions for handling entity types and platform
errors in AppsmithConsole, including new constants and error retrieval
functions.
- Added a new enum value `MISSING_MODULE` to better categorize log types
in debugging scenarios.
- **Bug Fixes**
- Implemented changes to error logging and handling mechanisms,
including the addition of new case handling for
`LOG_TYPE.MISSING_MODULE` in debugger logs, to improve the debugging
experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-02-14 06:30:18 +00:00
|
|
|
import { ENTITY_TYPE } from "@appsmith/entities/AppsmithConsole/utils";
|
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 { Datasource } from "entities/Datasource";
|
2021-12-07 09:45:18 +00:00
|
|
|
import { initialize } from "redux-form";
|
|
|
|
|
import {
|
|
|
|
|
API_EDITOR_FORM_NAME,
|
|
|
|
|
DATASOURCE_DB_FORM,
|
|
|
|
|
DATASOURCE_REST_API_FORM,
|
|
|
|
|
QUERY_EDITOR_FORM_NAME,
|
2022-09-02 17:15:08 +00:00
|
|
|
} from "@appsmith/constants/forms";
|
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 { Canvas } from "entities/Replay/ReplayEntity/ReplayCanvas";
|
2022-05-04 09:45:57 +00:00
|
|
|
import {
|
|
|
|
|
setAppThemingModeStackAction,
|
|
|
|
|
updateSelectedAppThemeAction,
|
|
|
|
|
} from "actions/appThemingActions";
|
|
|
|
|
import { AppThemingMode } from "selectors/appThemingSelectors";
|
2022-11-23 09:48:23 +00:00
|
|
|
import { generateAutoHeightLayoutTreeAction } from "actions/autoHeightActions";
|
2023-01-28 02:17:06 +00:00
|
|
|
import { SelectionRequestType } from "sagas/WidgetSelectUtils";
|
2023-11-10 08:04:09 +00:00
|
|
|
import { startFormEvaluations } from "actions/evaluationActions";
|
2023-07-12 06:42:16 +00:00
|
|
|
import { getUIComponent } from "pages/Editor/QueryEditor/helpers";
|
|
|
|
|
import type { Plugin } from "api/PluginApi";
|
|
|
|
|
import { UIComponentTypes } from "api/PluginApi";
|
2023-09-11 07:09:41 +00:00
|
|
|
import { getCurrentEnvironmentId } from "@appsmith/selectors/environmentSelectors";
|
2024-01-24 16:25:08 +00:00
|
|
|
import { updateAndSaveAnvilLayout } from "layoutSystems/anvil/utils/anvilChecksUtils";
|
2021-09-21 07:55:56 +00:00
|
|
|
|
2023-10-11 07:35:24 +00:00
|
|
|
export interface UndoRedoPayload {
|
2021-09-21 07:55:56 +00:00
|
|
|
operation: ReplayReduxActionTypes;
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2021-09-21 07:55:56 +00:00
|
|
|
|
|
|
|
|
export default function* undoRedoListenerSaga() {
|
2021-12-07 09:45:18 +00:00
|
|
|
yield all([
|
|
|
|
|
takeEvery(ReduxActionTypes.UNDO_REDO_OPERATION, undoRedoSaga),
|
|
|
|
|
takeLatest(ReduxActionTypes.UPDATE_REPLAY_ENTITY, updateReplayEntitySaga),
|
|
|
|
|
]);
|
2021-09-21 07:55:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This Saga is called if the type of update is a property change
|
|
|
|
|
* @param replay
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
export function* openPropertyPaneSaga(replay: any) {
|
|
|
|
|
try {
|
|
|
|
|
const replayWidgetId = Object.keys(replay.widgets)[0];
|
|
|
|
|
|
|
|
|
|
if (!replayWidgetId || !replay.widgets[replayWidgetId].propertyUpdates)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
scrollWidgetIntoView(replayWidgetId);
|
|
|
|
|
|
|
|
|
|
const isPropertyPaneVisible: boolean = yield select(
|
|
|
|
|
getIsPropertyPaneVisible,
|
|
|
|
|
);
|
|
|
|
|
const selectedWidgetId: string = yield select(getCurrentWidgetId);
|
|
|
|
|
|
|
|
|
|
//if property pane is not visible, select the widget and force open property pane
|
|
|
|
|
if (selectedWidgetId !== replayWidgetId || !isPropertyPaneVisible) {
|
2023-01-28 02:17:06 +00:00
|
|
|
yield put(
|
|
|
|
|
selectWidgetInitAction(SelectionRequestType.One, [replayWidgetId]),
|
|
|
|
|
);
|
2021-09-21 07:55:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flashElementsById(
|
|
|
|
|
btoa(
|
|
|
|
|
replay.widgets[replayWidgetId].propertyUpdates.slice(0, 2).join("."),
|
|
|
|
|
),
|
|
|
|
|
0,
|
|
|
|
|
1000,
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This saga is called when type of chenge is not a property Change
|
|
|
|
|
* @param replay
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
export function* postUndoRedoSaga(replay: any) {
|
|
|
|
|
try {
|
|
|
|
|
const isPropertyPaneVisible: boolean = yield select(
|
|
|
|
|
getIsPropertyPaneVisible,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isPropertyPaneVisible) yield put(closePropertyPane());
|
|
|
|
|
|
|
|
|
|
// display toasts if it is a destructive operation
|
|
|
|
|
if (replay.toasts && replay.toasts.length > 0) {
|
|
|
|
|
processUndoRedoToasts(replay.toasts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!replay.widgets || Object.keys(replay.widgets).length <= 0) return;
|
|
|
|
|
|
|
|
|
|
const widgetIds = Object.keys(replay.widgets);
|
|
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
yield put(selectWidgetInitAction(SelectionRequestType.Multiple, widgetIds));
|
2021-09-21 07:55:56 +00:00
|
|
|
scrollWidgetIntoView(widgetIds[0]);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-07 09:45:18 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* saga that listen for UNDO_REDO_OPERATION
|
|
|
|
|
* it won't do anything in case of sniping/comment mode
|
|
|
|
|
*
|
|
|
|
|
* @param action
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
export function* undoRedoSaga(action: ReduxAction<UndoRedoPayload>) {
|
|
|
|
|
const isSnipingMode: boolean = yield select(snipingModeSelector);
|
|
|
|
|
|
|
|
|
|
// if the app is in snipping or comments mode, don't do anything
|
2022-08-03 07:02:49 +00:00
|
|
|
if (isSnipingMode) return;
|
2021-12-07 09:45:18 +00:00
|
|
|
try {
|
|
|
|
|
const history = createBrowserHistory();
|
|
|
|
|
const pathname = history.location.pathname;
|
|
|
|
|
const { id, type } = getEntityInCurrentPath(pathname);
|
|
|
|
|
const entityId = type === "page" ? "canvas" : id;
|
2022-06-21 13:57:34 +00:00
|
|
|
// @ts-expect-error: workerResponse is of type unknown
|
2021-12-07 09:45:18 +00:00
|
|
|
const workerResponse = yield call(
|
|
|
|
|
workerComputeUndoRedo,
|
|
|
|
|
action.payload.operation,
|
|
|
|
|
entityId,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// if there is no change, then don't do anythingÎ
|
|
|
|
|
if (!workerResponse) return;
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
event,
|
|
|
|
|
logs,
|
|
|
|
|
paths,
|
|
|
|
|
replay,
|
|
|
|
|
replayEntity,
|
|
|
|
|
replayEntityType,
|
|
|
|
|
timeTaken,
|
|
|
|
|
} = workerResponse;
|
|
|
|
|
|
|
|
|
|
logs && logs.forEach((evalLog: any) => log.debug(evalLog));
|
2022-05-04 09:45:57 +00:00
|
|
|
|
|
|
|
|
if (replay.theme) {
|
|
|
|
|
yield call(replayThemeSaga, replayEntity, replay);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-12-07 09:45:18 +00:00
|
|
|
switch (replayEntityType) {
|
|
|
|
|
case ENTITY_TYPE.WIDGET: {
|
|
|
|
|
const isPropertyUpdate = replay.widgets && replay.propertyUpdates;
|
|
|
|
|
AnalyticsUtil.logEvent(event, { paths, timeTaken });
|
2022-11-23 09:48:23 +00:00
|
|
|
|
2024-01-24 16:25:08 +00:00
|
|
|
yield call(updateAndSaveAnvilLayout, replayEntity.widgets, {
|
|
|
|
|
isRetry: false,
|
|
|
|
|
shouldReplay: false,
|
|
|
|
|
});
|
2022-11-24 18:40:06 +00:00
|
|
|
|
2022-11-23 09:48:23 +00:00
|
|
|
if (isPropertyUpdate) {
|
|
|
|
|
yield call(openPropertyPaneSaga, replay);
|
|
|
|
|
}
|
|
|
|
|
if (!isPropertyUpdate) {
|
|
|
|
|
yield call(postUndoRedoSaga, replay);
|
|
|
|
|
}
|
2022-11-24 18:40:06 +00:00
|
|
|
yield put(generateAutoHeightLayoutTreeAction(true, false));
|
2021-12-07 09:45:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ENTITY_TYPE.ACTION:
|
|
|
|
|
yield call(replayActionSaga, replayEntity, replay);
|
|
|
|
|
break;
|
|
|
|
|
case ENTITY_TYPE.DATASOURCE: {
|
|
|
|
|
yield call(replayDatasourceSaga, replayEntity, replay);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ENTITY_TYPE.JSACTION:
|
|
|
|
|
yield put(
|
|
|
|
|
updateJSCollectionBody(replayEntity.body, replayEntity.id, true),
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 09:45:57 +00:00
|
|
|
/**
|
|
|
|
|
* replay theme actions
|
|
|
|
|
*
|
|
|
|
|
* @param replayEntity
|
|
|
|
|
* @param replay
|
|
|
|
|
*/
|
|
|
|
|
function* replayThemeSaga(replayEntity: Canvas, replay: any) {
|
|
|
|
|
const applicationId: string = yield select(getCurrentApplicationId);
|
|
|
|
|
|
|
|
|
|
// if theme is changed, open the theme selector
|
|
|
|
|
if (replay.themeChanged) {
|
|
|
|
|
yield put(
|
|
|
|
|
setAppThemingModeStackAction([AppThemingMode.APP_THEME_SELECTION]),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
yield put(setAppThemingModeStackAction([]));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
yield put(selectWidgetInitAction(SelectionRequestType.Empty));
|
2022-05-04 09:45:57 +00:00
|
|
|
|
|
|
|
|
// todo(pawan): check with arun/rahul on how we can get rid of this check
|
|
|
|
|
// better way to do is set shouldreplay = false when evaluating tree
|
|
|
|
|
if (replayEntity.theme.id) {
|
|
|
|
|
yield put(
|
|
|
|
|
updateSelectedAppThemeAction({
|
|
|
|
|
theme: replayEntity.theme,
|
|
|
|
|
shouldReplay: false,
|
|
|
|
|
applicationId,
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 09:45:18 +00:00
|
|
|
function* replayActionSaga(
|
|
|
|
|
replayEntity: Action,
|
|
|
|
|
replay: { updates: ReplayEditorUpdate[] },
|
|
|
|
|
) {
|
|
|
|
|
const { updates = [] } = replay;
|
|
|
|
|
/**
|
|
|
|
|
* Pick one diff to determine tab switching.
|
|
|
|
|
* Diffs across multiple tabs are unlikely
|
|
|
|
|
*/
|
|
|
|
|
const { modifiedProperty } = updates[updates.length - 1] || {};
|
|
|
|
|
const { currentTab } = yield call(
|
|
|
|
|
getEditorFieldConfig,
|
|
|
|
|
replayEntity,
|
|
|
|
|
modifiedProperty,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if tab needs to be switched and switch is necessary
|
|
|
|
|
* Delay change if tab needs to be switched
|
|
|
|
|
*/
|
|
|
|
|
const didSwitch: boolean = yield call(switchTab, currentTab);
|
|
|
|
|
if (didSwitch) yield delay(REPLAY_FOCUS_DELAY);
|
|
|
|
|
|
|
|
|
|
//Reinitialize form
|
2022-04-07 16:18:49 +00:00
|
|
|
const currentFormName =
|
2024-01-16 14:49:08 +00:00
|
|
|
isQueryAction(replayEntity) ||
|
|
|
|
|
isSaaSAction(replayEntity) ||
|
|
|
|
|
isAIAction(replayEntity)
|
2022-04-07 16:18:49 +00:00
|
|
|
? QUERY_EDITOR_FORM_NAME
|
|
|
|
|
: API_EDITOR_FORM_NAME;
|
2021-12-07 09:45:18 +00:00
|
|
|
yield put(initialize(currentFormName, replayEntity));
|
|
|
|
|
|
|
|
|
|
//Begin modified field highlighting
|
|
|
|
|
highlightReplayElement(
|
|
|
|
|
updates.map((u: ReplayEditorUpdate) => u.modifiedProperty),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update all the diffs in the action object.
|
|
|
|
|
* We need this for debugger logs, dynamicBindingPathList and to call relevant APIs */
|
2023-07-12 06:42:16 +00:00
|
|
|
|
2023-09-11 07:09:41 +00:00
|
|
|
const currentEnvironment: string = yield select(getCurrentEnvironmentId);
|
2023-07-12 06:42:16 +00:00
|
|
|
const plugins: Plugin[] = yield select(getPlugins);
|
|
|
|
|
const uiComponent = getUIComponent(replayEntity.pluginId, plugins);
|
|
|
|
|
const datasource: Datasource | undefined = yield select(
|
|
|
|
|
getDatasource,
|
|
|
|
|
replayEntity.datasource?.id || "",
|
|
|
|
|
);
|
|
|
|
|
|
2021-12-07 09:45:18 +00:00
|
|
|
yield all(
|
2023-07-12 06:42:16 +00:00
|
|
|
updates.map((u) => {
|
|
|
|
|
// handle evaluations after update.
|
|
|
|
|
const postEvalActions =
|
|
|
|
|
uiComponent === UIComponentTypes.UQIDbEditorForm
|
|
|
|
|
? [
|
|
|
|
|
startFormEvaluations(
|
|
|
|
|
replayEntity.id,
|
|
|
|
|
replayEntity.actionConfiguration,
|
|
|
|
|
replayEntity.datasource.id || "",
|
|
|
|
|
replayEntity.pluginId,
|
|
|
|
|
u.modifiedProperty,
|
|
|
|
|
true,
|
|
|
|
|
datasource?.datasourceStorages[currentEnvironment]
|
|
|
|
|
.datasourceConfiguration,
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
: [];
|
|
|
|
|
|
|
|
|
|
return put(
|
|
|
|
|
setActionProperty(
|
|
|
|
|
{
|
|
|
|
|
actionId: replayEntity.id,
|
|
|
|
|
propertyName: u.modifiedProperty,
|
|
|
|
|
value:
|
|
|
|
|
u.kind === "A"
|
|
|
|
|
? _.get(replayEntity, u.modifiedProperty)
|
|
|
|
|
: u.update,
|
|
|
|
|
skipSave: true,
|
|
|
|
|
},
|
|
|
|
|
postEvalActions,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
2021-12-07 09:45:18 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Save the updated action object
|
|
|
|
|
yield put(updateAction({ id: replayEntity.id }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function* replayDatasourceSaga(
|
|
|
|
|
replayEntity: Datasource,
|
|
|
|
|
replay: { updates: ReplayEditorUpdate[] },
|
|
|
|
|
) {
|
|
|
|
|
const { updates = [] } = replay;
|
|
|
|
|
const { modifiedProperty } = updates[updates.length - 1] || {};
|
|
|
|
|
const { fieldInfo: { parentSection = "" } = {} } = yield call(
|
|
|
|
|
getDatasourceFieldConfig,
|
|
|
|
|
replayEntity,
|
|
|
|
|
modifiedProperty,
|
|
|
|
|
);
|
|
|
|
|
/**
|
|
|
|
|
* Check if the modified field is under a collapsed section and expand if necessary
|
|
|
|
|
* Delay change if accordion needs to be expanded
|
|
|
|
|
*/
|
|
|
|
|
const didExpand: boolean = yield call(expandAccordion, parentSection);
|
|
|
|
|
if (didExpand) yield delay(REPLAY_FOCUS_DELAY);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reinitialize redux form
|
|
|
|
|
* Attribute "datasourceId" is used as a differentiator between rest-api datasources and the others */
|
|
|
|
|
if (replayEntity.hasOwnProperty("datasourceId")) {
|
|
|
|
|
yield put(initialize(DATASOURCE_REST_API_FORM, replayEntity));
|
|
|
|
|
} else {
|
|
|
|
|
yield put(initialize(DATASOURCE_DB_FORM, _.omit(replayEntity, ["name"])));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Highlight modified fields
|
|
|
|
|
highlightReplayElement(
|
|
|
|
|
updates.map((u: ReplayEditorUpdate) => u.modifiedProperty),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Figure out the field config of the last modified field in datasource forms
|
|
|
|
|
*/
|
|
|
|
|
function* getDatasourceFieldConfig(
|
|
|
|
|
replayEntity: Datasource,
|
|
|
|
|
modifiedProperty: string,
|
|
|
|
|
) {
|
|
|
|
|
const formConfig: [Record<any, any>] = yield select(
|
|
|
|
|
getPluginForm,
|
|
|
|
|
replayEntity.pluginId,
|
|
|
|
|
);
|
|
|
|
|
const fieldInfo = findFieldInfo(formConfig, modifiedProperty);
|
|
|
|
|
return { fieldInfo };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2022-05-04 09:45:57 +00:00
|
|
|
Figure out the tab in which the last modified field is present and the
|
2021-12-07 09:45:18 +00:00
|
|
|
field config of the last modified field.
|
|
|
|
|
*/
|
|
|
|
|
function* getEditorFieldConfig(replayEntity: Action, modifiedProperty: string) {
|
|
|
|
|
let currentTab = "";
|
|
|
|
|
let fieldInfo = {};
|
|
|
|
|
if (!modifiedProperty) return { currentTab, fieldInfo };
|
|
|
|
|
if (isAPIAction(replayEntity)) {
|
|
|
|
|
if (modifiedProperty.includes("headers"))
|
|
|
|
|
currentTab = API_EDITOR_TABS.HEADERS;
|
|
|
|
|
else if (modifiedProperty.includes("queryParameters"))
|
|
|
|
|
currentTab = API_EDITOR_TABS.PARAMS;
|
|
|
|
|
else if (modifiedProperty.includes("body"))
|
|
|
|
|
currentTab = API_EDITOR_TABS.BODY;
|
|
|
|
|
else if (
|
|
|
|
|
modifiedProperty.includes("pagination") ||
|
|
|
|
|
modifiedProperty.includes("next") ||
|
|
|
|
|
modifiedProperty.includes("previous")
|
|
|
|
|
)
|
|
|
|
|
currentTab = API_EDITOR_TABS.PAGINATION;
|
|
|
|
|
if (!currentTab) {
|
|
|
|
|
const settingsConfig: [Record<any, any>] = yield select(
|
|
|
|
|
getSettingConfig,
|
|
|
|
|
replayEntity.pluginId,
|
|
|
|
|
);
|
|
|
|
|
fieldInfo = findFieldInfo(settingsConfig, modifiedProperty);
|
|
|
|
|
if (!isEmpty(fieldInfo)) currentTab = API_EDITOR_TABS.SETTINGS;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const editorConfig: [Record<any, any>] = yield select(
|
|
|
|
|
getEditorConfig,
|
|
|
|
|
replayEntity.pluginId,
|
|
|
|
|
);
|
|
|
|
|
fieldInfo = findFieldInfo(editorConfig, modifiedProperty);
|
|
|
|
|
if (!isEmpty(fieldInfo)) {
|
|
|
|
|
currentTab = EDITOR_TABS.QUERY;
|
|
|
|
|
} else {
|
|
|
|
|
const settingsConfig: [Record<any, any>] = yield select(
|
|
|
|
|
getSettingConfig,
|
|
|
|
|
replayEntity.pluginId,
|
|
|
|
|
);
|
|
|
|
|
fieldInfo = findFieldInfo(settingsConfig, modifiedProperty);
|
|
|
|
|
if (!isEmpty(fieldInfo)) currentTab = EDITOR_TABS.SETTINGS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return { currentTab, fieldInfo };
|
|
|
|
|
}
|