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-04-26 05:41:32 +00:00
EvaluationReduxAction ,
2019-10-21 15:12:45 +00:00
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 {
2019-10-21 15:12:45 +00:00
ReduxActionErrorTypes ,
ReduxActionTypes ,
2022-04-12 10:50:01 +00:00
} from "@appsmith/constants/ReduxActionConstants" ;
2019-10-25 05:35:20 +00:00
import {
all ,
call ,
2023-06-13 11:00:37 +00:00
fork ,
2019-10-25 05:35:20 +00:00
put ,
2021-08-09 06:22:37 +00:00
race ,
2020-02-18 10:41:52 +00:00
select ,
2021-07-07 03:46:16 +00:00
take ,
2019-10-25 05:35:20 +00:00
takeEvery ,
takeLatest ,
} from "redux-saga/effects" ;
2023-06-13 11:00:37 +00:00
import type { Datasource , DatasourceStructure } from "entities/Datasource" ;
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 { ActionCreateUpdateResponse } from "api/ActionAPI" ;
import ActionAPI from "api/ActionAPI" ;
import type { ApiResponse } from "api/ApiResponses" ;
2023-11-30 12:33:33 +00:00
import type { FetchPageRequest , FetchPageResponse } from "api/PageApi" ;
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 PageApi from "api/PageApi" ;
2023-11-16 11:33:59 +00:00
import { updateCanvasWithDSL } from "@appsmith/sagas/PageSagas" ;
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 {
FetchActionsPayload ,
SetActionPropertyPayload ,
} from "actions/pluginActionActions" ;
2019-10-25 05:35:20 +00:00
import {
2020-01-24 09:54:40 +00:00
copyActionError ,
copyActionSuccess ,
2024-01-17 10:04:50 +00:00
createActionInit ,
2019-10-25 05:35:20 +00:00
createActionSuccess ,
deleteActionSuccess ,
2020-07-03 08:58:58 +00:00
fetchActionsForPage ,
2020-03-12 20:27:39 +00:00
fetchActionsForPageSuccess ,
2020-01-24 09:54:40 +00:00
moveActionError ,
moveActionSuccess ,
2020-07-06 13:35:31 +00:00
updateAction ,
2023-11-22 08:34:48 +00:00
updateActionData ,
2020-07-03 08:58:58 +00:00
updateActionProperty ,
2019-10-25 05:35:20 +00:00
updateActionSuccess ,
2021-08-27 09:25:28 +00:00
} from "actions/pluginActionActions" ;
2021-11-26 09:04:16 +00:00
import { getDynamicBindingsChangesSaga } from "utils/DynamicBindingUtils" ;
2019-11-13 07:34:59 +00:00
import { validateResponse } from "./ErrorSagas" ;
2019-12-23 12:12:58 +00:00
import { transformRestAction } from "transformers/RestActionTransformer" ;
2023-06-30 10:21:08 +00:00
import { getCurrentPageId } from "selectors/editorSelectors" ;
2020-03-06 04:59:24 +00:00
import AnalyticsUtil from "utils/AnalyticsUtil" ;
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-09-22 16:59:47 +00:00
Action ,
ActionViewMode ,
2023-08-08 15:23:01 +00:00
ApiAction ,
2023-06-01 17:26:05 +00:00
ApiActionConfig ,
2023-10-27 06:36:57 +00:00
CreateActionDefaultsParams ,
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
SlashCommandPayload ,
} from "entities/Action" ;
2023-06-01 17:26:05 +00:00
import { isGraphqlPlugin } from "entities/Action" ;
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 {
2021-12-07 09:45:18 +00:00
isAPIAction ,
2022-10-17 15:16:38 +00:00
PluginPackageName ,
2021-09-22 16:59:47 +00:00
PluginType ,
SlashCommand ,
} from "entities/Action" ;
2023-10-27 06:36:57 +00:00
import type { ActionData } from "@appsmith/reducers/entityReducers/actionsReducer" ;
2024-01-18 08:32:42 +00:00
import type { EditorSegmentList } from "@appsmith/selectors/appIDESelectors" ;
2024-01-24 08:52:40 +00:00
import type { EntityItem } from "@appsmith/entities/IDE/constants" ;
2024-01-16 13:22:07 +00:00
import { selectQuerySegmentEditorList } from "@appsmith/selectors/appIDESelectors" ;
2020-07-03 08:58:58 +00:00
import {
getAction ,
getCurrentPageNameByActionId ,
2023-06-01 17:26:05 +00:00
getDatasource ,
2023-06-13 11:00:37 +00:00
getDatasourceStructureById ,
2022-10-17 15:16:38 +00:00
getDatasources ,
2021-03-01 14:57:15 +00:00
getEditorConfig ,
2020-07-03 08:58:58 +00:00
getPageNameByPageId ,
2021-04-22 03:30:09 +00:00
getPlugin ,
2021-02-23 08:27:37 +00:00
getSettingConfig ,
2023-12-27 08:47:35 +00:00
getPageActions ,
2024-01-17 10:04:50 +00:00
getNewEntityName ,
2023-09-12 11:51:39 +00:00
} from "@appsmith/selectors/entitiesSelector" ;
2020-07-06 13:35:31 +00:00
import history from "utils/history" ;
2022-03-25 10:43:26 +00:00
import { INTEGRATION_TABS } from "constants/routes" ;
2020-09-28 05:12:23 +00:00
import PerformanceTracker , {
PerformanceTransactionName ,
} from "utils/PerformanceTracker" ;
2021-03-13 14:24:45 +00:00
import {
ACTION_COPY_SUCCESS ,
ACTION_MOVE_SUCCESS ,
createMessage ,
ERROR_ACTION_COPY_FAIL ,
ERROR_ACTION_MOVE_FAIL ,
ERROR_ACTION_RENAME_FAIL ,
2022-02-11 18:08:46 +00:00
} from "@appsmith/constants/messages" ;
2023-08-08 15:23:01 +00:00
import { get , isEmpty , merge } from "lodash" ;
2022-04-30 02:57:15 +00:00
import {
fixActionPayloadForMongoQuery ,
getConfigInitialValues ,
} from "components/formControls/utils" ;
2021-04-23 13:50:55 +00:00
import AppsmithConsole from "utils/AppsmithConsole" ;
import { ENTITY_TYPE } from "entities/AppsmithConsole" ;
import LOG_TYPE from "entities/AppsmithConsole/logtype" ;
2022-09-09 15:59:47 +00:00
import {
createNewApiAction ,
createNewQueryAction ,
} from "actions/apiPaneActions" ;
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" ;
2021-11-05 05:49:19 +00:00
import * as log from "loglevel" ;
2022-06-21 13:57:34 +00:00
import { shouldBeDefined } from "utils/helpers" ;
2022-03-25 10:43:26 +00:00
import {
apiEditorIdURL ,
builderURL ,
integrationEditorURL ,
2023-12-27 08:47:35 +00:00
queryAddURL ,
2022-03-25 10:43:26 +00:00
queryEditorIdURL ,
saasEditorApiIdURL ,
2023-10-12 05:31:22 +00:00
} from "@appsmith/RouteBuilder" ;
feat: Store `originalActionId` as part of Action DTO for copied action (#25011)
## Description
To measure the impact of query modules in Appsmith. We need to track the
time a user takes to edit a copied query. Today, we do not have a
mechanism to understand if a query in question is a copied query. To fix
this, the data model of the Query action needs to change to include the
`originalQueryId` if a query is, in fact, a copied query.
- [ ] When a query is first copied, there will be no `originalActionId`
in the action object. In this scenario, the client will populate the
`originalActionId` field and call the POST API to create the copied
query.
- [ ] If the query is already a copied query, the client will duplicate
the value of the `originalActionId` when calling the POST API to create
the copied query.
|POST|`/api/v1/actions`|
----------|------|
### [Related discussion on
Notion](https://www.notion.so/appsmith/Backend-dependency-for-modules-instrumentation-889462d461844745be0a2599c8555ca5)
#### PR fixes following issue(s)
Fixes #24734
#### 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
- [x] Manual
- [x] 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
- [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
- [ ] 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
> Pull Request Template
>
> Use this template to quickly create a well written pull request.
Delete all quotes before creating the pull request.
>
## Description
> Add a TL;DR when description is extra long (helps content team)
>
> Please include a summary of the changes and which issue has been
fixed. Please also include relevant motivation
> and context. List any dependencies that are required for this change
>
> Links to Notion, Figma or any other documents that might be relevant
to the PR
>
>
#### 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
- [ ] 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
---------
Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-07-04 07:42:09 +00:00
import {
RequestPayloadAnalyticsPath ,
checkAndLogErrorsIfCyclicDependency ,
enhanceRequestPayloadWithEventData ,
2024-01-24 06:44:16 +00:00
getFromServerWhenNoPrefetchedResult ,
feat: Store `originalActionId` as part of Action DTO for copied action (#25011)
## Description
To measure the impact of query modules in Appsmith. We need to track the
time a user takes to edit a copied query. Today, we do not have a
mechanism to understand if a query in question is a copied query. To fix
this, the data model of the Query action needs to change to include the
`originalQueryId` if a query is, in fact, a copied query.
- [ ] When a query is first copied, there will be no `originalActionId`
in the action object. In this scenario, the client will populate the
`originalActionId` field and call the POST API to create the copied
query.
- [ ] If the query is already a copied query, the client will duplicate
the value of the `originalActionId` when calling the POST API to create
the copied query.
|POST|`/api/v1/actions`|
----------|------|
### [Related discussion on
Notion](https://www.notion.so/appsmith/Backend-dependency-for-modules-instrumentation-889462d461844745be0a2599c8555ca5)
#### PR fixes following issue(s)
Fixes #24734
#### 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
- [x] Manual
- [x] 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
- [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
- [ ] 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
> Pull Request Template
>
> Use this template to quickly create a well written pull request.
Delete all quotes before creating the pull request.
>
## Description
> Add a TL;DR when description is extra long (helps content team)
>
> Please include a summary of the changes and which issue has been
fixed. Please also include relevant motivation
> and context. List any dependencies that are required for this change
>
> Links to Notion, Figma or any other documents that might be relevant
to the PR
>
>
#### 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
- [ ] 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
---------
Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-07-04 07:42:09 +00:00
} from "./helper" ;
2022-10-17 15:16:38 +00:00
import { setSnipingMode as setSnipingModeAction } from "actions/propertyPaneActions" ;
2023-05-19 18:37:06 +00:00
import { toast } from "design-system" ;
2023-05-26 10:13:18 +00:00
import { getFormValues } from "redux-form" ;
import {
API_EDITOR_FORM_NAME ,
QUERY_EDITOR_FORM_NAME ,
} from "@appsmith/constants/forms" ;
2023-06-01 17:26:05 +00:00
import { DEFAULT_GRAPHQL_ACTION_CONFIG } from "constants/ApiEditorConstants/GraphQLEditorConstants" ;
import { DEFAULT_API_ACTION_CONFIG } from "constants/ApiEditorConstants/ApiEditorConstants" ;
2023-06-13 11:00:37 +00:00
import { fetchDatasourceStructure } from "actions/datasourceActions" ;
2023-07-13 12:06:38 +00:00
import { setAIPromptTriggered } from "utils/storage" ;
2023-07-24 12:02:50 +00:00
import { getDefaultTemplateActionConfig } from "utils/editorContextUtils" ;
2023-08-07 09:31:45 +00:00
import { sendAnalyticsEventSaga } from "./AnalyticsSaga" ;
2023-08-31 10:59:53 +00:00
import { EditorModes } from "components/editorComponents/CodeEditor/EditorConfig" ;
2023-10-20 11:36:39 +00:00
import { updateActionAPICall } from "@appsmith/sagas/ApiCallerSagas" ;
2023-11-30 12:33:33 +00:00
import { getIsServerDSLMigrationsEnabled } from "selectors/pageSelectors" ;
2023-12-27 08:47:35 +00:00
import { removeFocusHistoryRequest } from "../actions/focusHistoryActions" ;
import { selectFeatureFlagCheck } from "@appsmith/selectors/featureFlagsSelectors" ;
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag" ;
import { identifyEntityFromPath } from "../navigation/FocusEntity" ;
import { getActionConfig } from "../pages/Editor/Explorer/Actions/helpers" ;
2024-01-17 10:04:50 +00:00
import { resolveParentEntityMetadata } from "@appsmith/sagas/helpers" ;
2024-01-24 08:52:40 +00:00
import { getQueryEntityItemUrl } from "@appsmith/pages/Editor/IDE/EditorPane/Query/utils" ;
2024-01-17 10:04:50 +00:00
export const DEFAULT_PREFIX = {
QUERY : "Query" ,
API : "Api" ,
} as const ;
2023-06-01 17:26:05 +00:00
2023-10-27 06:36:57 +00:00
export function * createDefaultActionPayloadWithPluginDefaults (
props : CreateActionDefaultsParams ,
2023-06-01 17:26:05 +00:00
) {
2023-10-27 06:36:57 +00:00
const actionDefaults : Partial < Action > = yield call (
createDefaultActionPayload ,
props ,
) ;
if ( actionDefaults . pluginId ) {
const pluginDefaults : Partial < Record < string , unknown > > = yield call (
getPluginActionDefaultValues ,
actionDefaults . pluginId ,
) ;
return merge ( { } , pluginDefaults , actionDefaults ) ;
}
return actionDefaults ;
}
2023-06-01 17:26:05 +00:00
2023-10-27 06:36:57 +00:00
export function * createDefaultActionPayload ( {
datasourceId ,
from ,
newActionName ,
feat: query should be populated based on table selected on datasource… (#30306)
## Description
We have a datasource preview and generate crud functionality implemented
on datasource review page. This functionality has been rolled out to all
100% of the users. This PR introduces an enhancement for that
functionality.
Whenever we are previewing datasource and have selected a particular
table from schema, and now when we create a new query, this query will
be constructed based on the table name we had selected. For eg, if
schema is showing 5 tables i.e table1, table2, table3, table4, table5,
and if we are previewing table3, and I click on new query CTA, it will
take me to query editor and the query body will have something like:
`select * from public.table3 limit 10`.
#### PR fixes following issue(s)
Fixes #29600
> 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
- New feature (non-breaking change which adds functionality)
>
>
>
## 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
- [x] 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
- [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
- [ ] 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
- **New Features**
- Introduced the ability to select and remember a specific table during
data source preview.
- Enhanced query creation with the option to pre-select a default table.
- **Improvements**
- Updated components and sagas to handle the selection of a default
table when creating new queries.
- **Bug Fixes**
- Ensured consistent default table selection across the app when
interacting with data sources and queries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2024-01-22 12:13:07 +00:00
queryDefaultTableName ,
2023-10-27 06:36:57 +00:00
} : CreateActionDefaultsParams ) {
const datasource : Datasource = yield select ( getDatasource , datasourceId ) ;
2023-06-01 17:26:05 +00:00
const plugin : Plugin = yield select ( getPlugin , datasource ? . pluginId ) ;
const pluginType : PluginType = plugin ? . type ;
const isGraphql : boolean = isGraphqlPlugin ( plugin ) ;
// If the datasource is Graphql then get Graphql default config else Api config
const DEFAULT_CONFIG = isGraphql
? DEFAULT_GRAPHQL_ACTION_CONFIG
: DEFAULT_API_ACTION_CONFIG ;
const DEFAULT_HEADERS = isGraphql
? DEFAULT_GRAPHQL_ACTION_CONFIG . headers
: DEFAULT_API_ACTION_CONFIG . headers ;
/* Removed Datasource Headers because they already exists in inherited headers so should not be duplicated to Newer APIs creation as datasource is already attached to it. While for older APIs we can start showing message on the UI from the API from messages key in Actions object. */
const defaultApiActionConfig : ApiActionConfig = {
. . . DEFAULT_CONFIG ,
headers : DEFAULT_HEADERS ,
} ;
2023-07-24 12:02:50 +00:00
const dsStructure : DatasourceStructure | undefined = yield select (
getDatasourceStructureById ,
datasource ? . id ,
) ;
const defaultActionConfig : any = getDefaultTemplateActionConfig (
plugin ,
feat: query should be populated based on table selected on datasource… (#30306)
## Description
We have a datasource preview and generate crud functionality implemented
on datasource review page. This functionality has been rolled out to all
100% of the users. This PR introduces an enhancement for that
functionality.
Whenever we are previewing datasource and have selected a particular
table from schema, and now when we create a new query, this query will
be constructed based on the table name we had selected. For eg, if
schema is showing 5 tables i.e table1, table2, table3, table4, table5,
and if we are previewing table3, and I click on new query CTA, it will
take me to query editor and the query body will have something like:
`select * from public.table3 limit 10`.
#### PR fixes following issue(s)
Fixes #29600
> 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
- New feature (non-breaking change which adds functionality)
>
>
>
## 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
- [x] 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
- [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
- [ ] 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
- **New Features**
- Introduced the ability to select and remember a specific table during
data source preview.
- Enhanced query creation with the option to pre-select a default table.
- **Improvements**
- Updated components and sagas to handle the selection of a default
table when creating new queries.
- **Bug Fixes**
- Ensured consistent default table selection across the app when
interacting with data sources and queries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2024-01-22 12:13:07 +00:00
queryDefaultTableName ,
2023-07-24 12:02:50 +00:00
dsStructure ,
datasource ? . isMock ,
) ;
feat: query should be populated based on table selected on datasource… (#30306)
## Description
We have a datasource preview and generate crud functionality implemented
on datasource review page. This functionality has been rolled out to all
100% of the users. This PR introduces an enhancement for that
functionality.
Whenever we are previewing datasource and have selected a particular
table from schema, and now when we create a new query, this query will
be constructed based on the table name we had selected. For eg, if
schema is showing 5 tables i.e table1, table2, table3, table4, table5,
and if we are previewing table3, and I click on new query CTA, it will
take me to query editor and the query body will have something like:
`select * from public.table3 limit 10`.
#### PR fixes following issue(s)
Fixes #29600
> 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
- New feature (non-breaking change which adds functionality)
>
>
>
## 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
- [x] 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
- [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
- [ ] 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
- **New Features**
- Introduced the ability to select and remember a specific table during
data source preview.
- Enhanced query creation with the option to pre-select a default table.
- **Improvements**
- Updated components and sagas to handle the selection of a default
table when creating new queries.
- **Bug Fixes**
- Ensured consistent default table selection across the app when
interacting with data sources and queries.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2024-01-22 12:13:07 +00:00
// since table name has been consumed, we no longer need it, hence resetting it
yield put ( {
type : ReduxActionTypes . SET_DATASOURCE_PREVIEW_SELECTED_TABLE_NAME ,
payload : "" ,
} ) ;
2023-10-27 06:36:57 +00:00
const defaultAction : Partial < Action > = {
2023-06-01 17:26:05 +00:00
pluginId : datasource?.pluginId ,
datasource : {
id : datasourceId ,
} ,
eventData : {
actionType : pluginType === PluginType . DB ? "Query" : "API" ,
from : from ,
dataSource : datasource.name ,
datasourceId : datasourceId ,
pluginName : plugin?.name ,
isMock : ! ! datasource ? . isMock ,
} ,
actionConfiguration :
2023-07-24 12:02:50 +00:00
plugin ? . type === PluginType . API
? defaultApiActionConfig
: ! ! defaultActionConfig
? defaultActionConfig
: { } ,
2023-10-27 06:36:57 +00:00
name : newActionName ,
2023-06-01 17:26:05 +00:00
} ;
2023-10-27 06:36:57 +00:00
return defaultAction ;
2023-06-01 17:26:05 +00:00
}
2023-10-27 06:36:57 +00:00
export function * getPluginActionDefaultValues ( pluginId : string ) {
2023-06-01 17:26:05 +00:00
if ( ! pluginId ) {
return ;
}
const editorConfig : any [ ] = yield select ( getEditorConfig , pluginId ) ;
const settingConfig : any [ ] = yield select ( getSettingConfig , pluginId ) ;
let initialValues : Record < string , unknown > = yield call (
getConfigInitialValues ,
editorConfig ,
) ;
if ( settingConfig ) {
const settingInitialValues : Record < string , unknown > = yield call (
getConfigInitialValues ,
settingConfig ,
) ;
initialValues = merge ( initialValues , settingInitialValues ) ;
}
return initialValues ;
}
2019-10-21 15:12:45 +00:00
2024-01-17 10:04:50 +00:00
/ * *
* This saga prepares the action request i . e it helps generating a
* new name of an action . This is to reduce any dependency on name generation
* on the caller of this saga .
* /
export function * createActionRequestSaga (
actionPayload : ReduxAction <
Partial < Action > & { eventData : any ; pluginId : string }
> ,
) {
const payload = { . . . actionPayload . payload } ;
const pluginId =
actionPayload . payload . pluginId ||
actionPayload . payload . datasource ? . pluginId ;
if ( ! actionPayload . payload . name ) {
const { parentEntityId , parentEntityKey } = resolveParentEntityMetadata (
actionPayload . payload ,
) ;
if ( ! parentEntityId || ! parentEntityKey ) return ;
const plugin : Plugin | undefined = yield select ( getPlugin , pluginId || "" ) ;
const isQueryType =
plugin ? . type === PluginType . DB ||
plugin ? . packageName === PluginPackageName . APPSMITH_AI ;
const prefix = isQueryType ? DEFAULT_PREFIX.QUERY : DEFAULT_PREFIX.API ;
if (
plugin ? . type === PluginType . DB ||
plugin ? . packageName === PluginPackageName . APPSMITH_AI
) {
DEFAULT_PREFIX . QUERY ;
}
const name : string = yield select ( getNewEntityName , {
prefix ,
parentEntityId ,
parentEntityKey ,
} ) ;
payload . name = name ;
}
yield put ( createActionInit ( payload ) ) ;
}
2020-12-30 07:31:20 +00:00
export function * createActionSaga (
2021-02-11 11:47:21 +00:00
actionPayload : ReduxAction <
Partial < Action > & { eventData : any ; pluginId : string }
> ,
2020-12-30 07:31:20 +00:00
) {
2019-11-13 07:34:59 +00:00
try {
2023-10-27 06:36:57 +00:00
const payload = actionPayload . payload ;
2021-02-11 11:47:21 +00:00
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 response : ApiResponse < ActionCreateUpdateResponse > =
yield ActionAPI . createAction ( payload ) ;
2022-06-21 13:57:34 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
2019-11-13 07:34:59 +00:00
if ( isValidResponse ) {
2022-06-21 13:57:34 +00:00
const pageName : string = yield select (
2020-03-06 04:59:24 +00:00
getCurrentPageNameByActionId ,
response . data . id ,
) ;
2020-10-06 15:10:21 +00:00
AnalyticsUtil . logEvent ( "CREATE_ACTION" , {
2020-10-07 14:10:08 +00:00
id : response.data.id ,
2022-06-21 13:57:34 +00:00
// @ts-expect-error: name does not exists on type ActionCreateUpdateResponse
2020-10-07 14:10:08 +00:00
actionName : response.data.name ,
2020-03-06 04:59:24 +00:00
pageName : pageName ,
2020-10-06 15:10:21 +00:00
. . . actionPayload . payload . eventData ,
2020-03-06 04:59:24 +00:00
} ) ;
2020-10-30 06:24:15 +00:00
2021-04-23 13:50:55 +00:00
AppsmithConsole . info ( {
text : ` Action created ` ,
source : {
type : ENTITY_TYPE . ACTION ,
id : response.data.id ,
2022-06-21 13:57:34 +00:00
// @ts-expect-error: name does not exists on type ActionCreateUpdateResponse
2021-04-23 13:50:55 +00:00
name : response.data.name ,
} ,
} ) ;
2020-10-30 06:24:15 +00:00
2021-04-23 13:50:55 +00:00
const newAction = response . data ;
2022-06-21 13:57:34 +00:00
// @ts-expect-error: type mismatch ActionCreateUpdateResponse vs Action
2020-10-30 06:24:15 +00:00
yield put ( createActionSuccess ( newAction ) ) ;
2023-06-13 11:00:37 +00:00
// we fork to prevent the call from blocking
yield fork ( fetchActionDatasourceStructure , newAction ) ;
2019-11-13 07:34:59 +00:00
}
} catch ( error ) {
yield put ( {
type : ReduxActionErrorTypes . CREATE_ACTION_ERROR ,
2020-01-24 09:54:40 +00:00
payload : actionPayload.payload ,
2019-10-21 15:12:45 +00:00
} ) ;
}
}
2023-12-13 17:43:43 +00:00
export function * fetchActionDatasourceStructure (
action : ActionCreateUpdateResponse ,
) {
2023-06-13 11:00:37 +00:00
if ( action . datasource ? . id ) {
const doesDatasourceStructureAlreadyExist : DatasourceStructure =
yield select ( getDatasourceStructureById , action . datasource . id ) ;
if ( doesDatasourceStructureAlreadyExist ) {
return ;
}
yield put ( fetchDatasourceStructure ( action . datasource . id , true ) ) ;
} else {
return ;
}
}
2021-04-26 05:41:32 +00:00
export function * fetchActionsSaga (
action : EvaluationReduxAction < FetchActionsPayload > ,
) {
2024-01-24 06:44:16 +00:00
const { applicationId , unpublishedActions } = action . payload ;
2020-09-28 05:12:23 +00:00
PerformanceTracker . startAsyncTracking (
PerformanceTransactionName . FETCH_ACTIONS_API ,
{ mode : "EDITOR" , appId : applicationId } ,
) ;
2019-11-13 07:34:59 +00:00
try {
2024-01-24 06:44:16 +00:00
const response : ApiResponse < Action [ ] > = yield call (
getFromServerWhenNoPrefetchedResult ,
unpublishedActions ,
async ( ) = > ActionAPI . fetchActions ( { applicationId } ) ,
) ;
2022-06-21 13:57:34 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
2019-11-13 07:34:59 +00:00
if ( isValidResponse ) {
yield put ( {
type : ReduxActionTypes . FETCH_ACTIONS_SUCCESS ,
payload : response.data ,
2021-04-26 05:41:32 +00:00
postEvalActions : action.postEvalActions ,
2019-11-13 07:34:59 +00:00
} ) ;
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . FETCH_ACTIONS_API ,
) ;
2019-11-13 07:34:59 +00:00
}
} catch ( error ) {
2019-10-21 15:12:45 +00:00
yield put ( {
type : ReduxActionErrorTypes . FETCH_ACTIONS_ERROR ,
2019-11-13 07:34:59 +00:00
payload : { error } ,
2019-10-21 15:12:45 +00:00
} ) ;
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . FETCH_ACTIONS_API ,
{ failed : true } ,
) ;
2019-10-21 15:12:45 +00:00
}
}
2020-07-15 13:01:35 +00:00
export function * fetchActionsForViewModeSaga (
action : ReduxAction < FetchActionsPayload > ,
) {
2024-01-24 06:44:16 +00:00
const { applicationId , publishedActions } = action . payload ;
2020-09-28 05:12:23 +00:00
PerformanceTracker . startAsyncTracking (
PerformanceTransactionName . FETCH_ACTIONS_API ,
{ mode : "VIEWER" , appId : applicationId } ,
) ;
2020-07-15 13:01:35 +00:00
try {
2024-01-24 06:44:16 +00:00
const response : ApiResponse < ActionViewMode [ ] > = yield call (
getFromServerWhenNoPrefetchedResult ,
publishedActions ,
async ( ) = > ActionAPI . fetchActionsForViewMode ( applicationId ) ,
) ;
2022-03-25 10:43:26 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
2020-07-15 13:01:35 +00:00
if ( isValidResponse ) {
2022-03-25 10:43:26 +00:00
const correctFormatResponse = response . data . map ( ( action ) = > {
return {
. . . action ,
actionConfiguration : {
timeoutInMillisecond : action.timeoutInMillisecond ,
} ,
} ;
} ) ;
2020-07-15 13:01:35 +00:00
yield put ( {
type : ReduxActionTypes . FETCH_ACTIONS_VIEW_MODE_SUCCESS ,
2021-01-26 03:12:52 +00:00
payload : correctFormatResponse ,
2020-07-15 13:01:35 +00:00
} ) ;
2022-03-25 10:43:26 +00:00
} else {
yield put ( {
type : ReduxActionErrorTypes . FETCH_ACTIONS_VIEW_MODE_ERROR ,
payload : response.responseMeta.error ,
} ) ;
2020-07-15 13:01:35 +00:00
}
2022-03-25 10:43:26 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . FETCH_ACTIONS_API ,
) ;
2020-07-15 13:01:35 +00:00
} catch ( error ) {
yield put ( {
type : ReduxActionErrorTypes . FETCH_ACTIONS_VIEW_MODE_ERROR ,
payload : { error } ,
} ) ;
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . FETCH_ACTIONS_API ,
{ failed : true } ,
) ;
2020-07-15 13:01:35 +00:00
}
}
2020-02-21 12:16:49 +00:00
export function * fetchActionsForPageSaga (
2021-07-29 08:13:10 +00:00
action : EvaluationReduxAction < { pageId : string } > ,
2020-02-21 12:16:49 +00:00
) {
2020-09-28 05:12:23 +00:00
const { pageId } = action . payload ;
PerformanceTracker . startAsyncTracking (
PerformanceTransactionName . FETCH_PAGE_ACTIONS_API ,
{ pageId : pageId } ,
) ;
2020-02-21 12:16:49 +00:00
try {
2022-06-21 13:57:34 +00:00
const response : ApiResponse < Action [ ] > = yield call (
2020-02-21 12:16:49 +00:00
ActionAPI . fetchActionsByPageId ,
pageId ,
) ;
2022-06-21 13:57:34 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
2020-02-21 12:16:49 +00:00
if ( isValidResponse ) {
2022-06-06 03:56:14 +00:00
yield put ( fetchActionsForPageSuccess ( response . data ) ) ;
// wait for success of
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . FETCH_PAGE_ACTIONS_API ,
) ;
2020-02-21 12:16:49 +00:00
}
} catch ( error ) {
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . FETCH_PAGE_ACTIONS_API ,
{ failed : true } ,
) ;
2020-02-21 12:16:49 +00:00
yield put ( {
type : ReduxActionErrorTypes . FETCH_ACTIONS_FOR_PAGE_ERROR ,
payload : { error } ,
} ) ;
}
}
2023-08-08 15:23:01 +00:00
export function * updateActionSaga ( actionPayload : ReduxAction < { id : string } > ) {
2019-11-13 07:34:59 +00:00
try {
2020-09-28 05:12:23 +00:00
PerformanceTracker . startAsyncTracking (
PerformanceTransactionName . UPDATE_ACTION_API ,
{ actionid : actionPayload.payload.id } ,
) ;
2023-08-08 15:23:01 +00:00
let action : Action = yield select ( getAction , actionPayload . payload . id ) ;
2021-01-12 04:17:28 +00:00
if ( ! action ) throw new Error ( "Could not find action to update" ) ;
2020-06-23 11:10:26 +00:00
2021-12-07 09:45:18 +00:00
if ( isAPIAction ( action ) ) {
2023-08-08 15:23:01 +00:00
// get api action object from redux form
const reduxFormApiAction : ApiAction = yield select (
getFormValues ( API_EDITOR_FORM_NAME ) ,
) ;
// run transformation on redux form action's headers, bodyformData and queryParameters.
// the reason we do this is because the transformation should only be done on the raw action data from the redux form.
// However sometimes when we attempt to save an API as a datasource, we update the Apiaction with the datasource information and the redux form data will not be available i.e. reduxFormApiAction = undefined
// In this scenario we can just default to the action object - (skip the if block below).
if ( ! isEmpty ( reduxFormApiAction ) ) {
action = {
. . . action ,
actionConfiguration : {
. . . action . actionConfiguration ,
headers : reduxFormApiAction.actionConfiguration.headers ,
bodyFormData : reduxFormApiAction.actionConfiguration.bodyFormData ,
queryParameters :
reduxFormApiAction . actionConfiguration . queryParameters ,
} ,
} ;
}
2020-07-06 13:35:31 +00:00
action = transformRestAction ( action ) ;
2020-06-29 08:23:10 +00:00
}
2020-06-16 10:23:19 +00:00
2022-04-30 02:57:15 +00:00
/* NOTE: This is fix for a missing command config */
2022-06-21 13:57:34 +00:00
const plugin : Plugin | undefined = yield select ( getPlugin , action . pluginId ) ;
2022-10-17 15:16:38 +00:00
if ( action && plugin && plugin . packageName === PluginPackageName . MONGO ) {
2022-06-21 13:57:34 +00:00
// @ts-expect-error: Types are not available
2022-04-30 02:57:15 +00:00
action = fixActionPayloadForMongoQuery ( action ) ;
}
2023-10-20 11:36:39 +00:00
const response : ApiResponse < Action > = yield call (
updateActionAPICall ,
action ,
) ;
2022-09-24 10:01:52 +00:00
2022-06-21 13:57:34 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
2019-11-13 07:34:59 +00:00
if ( isValidResponse ) {
2021-12-07 09:45:18 +00:00
const pageName : string = yield select (
2020-03-06 04:59:24 +00:00
getCurrentPageNameByActionId ,
response . data . id ,
) ;
2023-08-07 09:31:45 +00:00
yield sendAnalyticsEventSaga ( actionPayload . type , {
action ,
pageName ,
} ) ;
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . UPDATE_ACTION_API ,
) ;
2020-10-30 06:24:15 +00:00
2021-01-12 04:17:28 +00:00
yield put ( updateActionSuccess ( { data : response.data } ) ) ;
2022-09-24 10:01:52 +00:00
checkAndLogErrorsIfCyclicDependency (
( response . data as Action ) . errorReports ,
) ;
2019-11-13 07:34:59 +00:00
}
} catch ( error ) {
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . UPDATE_ACTION_API ,
{ failed : true } ,
) ;
2019-11-13 07:34:59 +00:00
yield put ( {
type : ReduxActionErrorTypes . UPDATE_ACTION_ERROR ,
2023-05-19 18:37:06 +00:00
payload : { error , id : actionPayload.payload.id , show : false } ,
2019-10-21 15:12:45 +00:00
} ) ;
}
}
2023-12-27 08:47:35 +00:00
/ * *
* Adds custom redirect logic to redirect after an item is deleted
* 1 . Do not navigate if the deleted item is not selected
* 2 . If it is the only item , navigate to a list url
* 3 . If there are other items , navigate to an item close to the current one
* * * /
function * handleDeleteActionRedirect ( deletedAction : Action ) {
const pageId : string = yield select ( getCurrentPageId ) ;
const allActions : ActionData [ ] = yield select ( getPageActions ( pageId ) ) ;
const currentSelectedEntity = identifyEntityFromPath (
window . location . pathname ,
) ;
const isSelectedActionDeleted = currentSelectedEntity . id === deletedAction . id ;
// If deleted item is not currently selected, don't redirect
if ( ! isSelectedActionDeleted ) {
return ;
}
const otherActions = allActions . filter (
( a ) = > deletedAction . id !== a . config . id ,
) ;
// If no other action is remaining, navigate to the query add url
if ( otherActions . length === 0 ) {
history . push ( queryAddURL ( { pageId } ) ) ;
return ;
}
// Check if another action is present in the group and redirect to it, orelse
// navigate to tht top of the list
2024-01-16 13:22:07 +00:00
const currentSortedList : EditorSegmentList = yield select (
selectQuerySegmentEditorList ,
2023-12-27 08:47:35 +00:00
) ;
2024-01-16 13:22:07 +00:00
let remainingGroupActions : EntityItem [ ] = [ ] ;
for ( const { items } of currentSortedList ) {
if ( items . find ( ( a ) = > a . key === deletedAction . id ) ) {
remainingGroupActions = items . filter ( ( a ) = > a . key !== deletedAction . id ) ;
2023-12-27 08:47:35 +00:00
break ;
}
}
2024-01-16 13:22:07 +00:00
2023-12-27 08:47:35 +00:00
let url ;
if ( remainingGroupActions . length === 0 ) {
const toRedirect = otherActions [ 0 ] ;
const config = getActionConfig ( toRedirect . config . pluginType ) ;
url = config ? . getURL (
pageId ,
toRedirect . config . id ,
toRedirect . config . pluginType ,
) ;
} else {
const toRedirect = remainingGroupActions [ 0 ] ;
2024-01-24 08:52:40 +00:00
url = getQueryEntityItemUrl ( toRedirect , pageId ) ;
2023-12-27 08:47:35 +00:00
const config = getActionConfig ( toRedirect . type ) ;
2024-01-16 13:22:07 +00:00
url = config ? . getURL ( pageId , toRedirect . key , toRedirect . type ) ;
2023-12-27 08:47:35 +00:00
}
if ( url ) {
history . push ( url ) ;
}
}
2020-03-06 04:59:24 +00:00
export function * deleteActionSaga (
2021-07-07 03:46:16 +00:00
actionPayload : ReduxAction < {
id : string ;
name : string ;
onSuccess ? : ( ) = > void ;
} > ,
2020-03-06 04:59:24 +00:00
) {
2019-11-13 07:34:59 +00:00
try {
const id = actionPayload . payload . id ;
2020-03-06 04:59:24 +00:00
const name = actionPayload . payload . name ;
2021-07-15 07:14:42 +00:00
const action : Action | undefined = yield select ( getAction , id ) ;
if ( ! action ) return ;
2020-07-06 13:35:31 +00:00
2021-04-22 03:30:09 +00:00
const isApi = action . pluginType === PluginType . API ;
const isQuery = action . pluginType === PluginType . DB ;
const isSaas = action . pluginType === PluginType . SAAS ;
2022-07-11 04:06:29 +00:00
const pageId : string = yield select ( getCurrentPageId ) ;
2020-07-06 13:35:31 +00:00
2022-06-21 13:57:34 +00:00
const response : ApiResponse < Action > = yield ActionAPI . deleteAction ( id ) ;
const isValidResponse : boolean = yield validateResponse ( response ) ;
2021-09-01 03:40:44 +00:00
if ( ! isValidResponse ) {
return ;
}
if ( isApi ) {
2022-06-21 13:57:34 +00:00
const pageName : string = yield select ( getCurrentPageNameByActionId , id ) ;
2021-09-01 03:40:44 +00:00
AnalyticsUtil . logEvent ( "DELETE_API" , {
apiName : name ,
pageName ,
apiID : id ,
2019-11-13 07:34:59 +00:00
} ) ;
2021-09-01 03:40:44 +00:00
}
if ( isSaas ) {
2022-06-21 13:57:34 +00:00
const pageName : string = yield select ( getCurrentPageNameByActionId , id ) ;
2021-09-01 03:40:44 +00:00
AnalyticsUtil . logEvent ( "DELETE_SAAS" , {
apiName : name ,
pageName ,
apiID : id ,
} ) ;
}
if ( isQuery ) {
AnalyticsUtil . logEvent ( "DELETE_QUERY" , {
queryName : name ,
} ) ;
}
2023-12-27 08:47:35 +00:00
const currentUrl = window . location . pathname ;
const isPagePaneSegmentsEnabled : boolean = yield select (
selectFeatureFlagCheck ,
FEATURE_FLAG . release_show_new_sidebar_pages_pane_enabled ,
) ;
2021-04-22 03:30:09 +00:00
2023-12-27 08:47:35 +00:00
if ( isPagePaneSegmentsEnabled ) {
yield call ( handleDeleteActionRedirect , action ) ;
2021-09-01 03:40:44 +00:00
} else {
2023-12-27 08:47:35 +00:00
if ( ! ! actionPayload . payload . onSuccess ) {
actionPayload . payload . onSuccess ( ) ;
} else {
history . push (
integrationEditorURL ( {
pageId ,
selectedTab : INTEGRATION_TABS.NEW ,
} ) ,
) ;
}
2021-09-01 03:40:44 +00:00
}
2021-03-30 05:29:03 +00:00
2021-09-01 03:40:44 +00:00
AppsmithConsole . info ( {
logType : LOG_TYPE.ENTITY_DELETED ,
text : "Action was deleted" ,
source : {
type : ENTITY_TYPE . ACTION ,
name : response.data.name ,
id : response.data.id ,
} ,
analytics : {
pluginId : action.pluginId ,
} ,
} ) ;
2021-07-15 07:14:42 +00:00
2021-09-01 03:40:44 +00:00
yield put ( deleteActionSuccess ( { id } ) ) ;
2023-12-27 08:47:35 +00:00
yield put ( removeFocusHistoryRequest ( currentUrl ) ) ;
2019-11-13 07:34:59 +00:00
} catch ( error ) {
yield put ( {
type : ReduxActionErrorTypes . DELETE_ACTION_ERROR ,
2019-12-11 15:14:38 +00:00
payload : { error , id : actionPayload.payload.id } ,
2019-10-21 15:12:45 +00:00
} ) ;
}
}
2020-01-24 09:54:40 +00:00
function * moveActionSaga (
action : ReduxAction < {
id : string ;
destinationPageId : string ;
originalPageId : string ;
name : string ;
} > ,
) {
2022-06-21 13:57:34 +00:00
const actionObject = shouldBeDefined < Action > (
yield select ( getAction , action . payload . id ) ,
` Action not found for id - ${ action . payload . id } ` ,
) ;
2020-01-24 09:54:40 +00:00
try {
2022-06-21 13:57:34 +00:00
const response : ApiResponse = yield ActionAPI . moveAction ( {
2020-01-27 13:53:33 +00:00
action : {
2021-11-26 09:04:16 +00:00
. . . actionObject ,
2020-07-06 13:35:31 +00:00
pageId : action.payload.originalPageId ,
2020-01-27 13:53:33 +00:00
name : action.payload.name ,
} ,
2020-01-24 09:54:40 +00:00
destinationPageId : action.payload.destinationPageId ,
} ) ;
2022-06-21 13:57:34 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
const pageName : string = yield select (
getPageNameByPageId ,
// @ts-expect-error: response is of type unknown
response . data . pageId ,
) ;
2020-01-24 09:54:40 +00:00
if ( isValidResponse ) {
2023-05-19 18:37:06 +00:00
toast . show (
2022-06-21 13:57:34 +00:00
// @ts-expect-error: response is of type unknown
2023-05-19 18:37:06 +00:00
createMessage ( ACTION_MOVE_SUCCESS , response . data . name , pageName ) ,
{
kind : "success" ,
} ,
) ;
2020-01-24 09:54:40 +00:00
}
2021-03-13 14:24:45 +00:00
2020-03-06 04:59:24 +00:00
AnalyticsUtil . logEvent ( "MOVE_API" , {
2022-06-21 13:57:34 +00:00
// @ts-expect-error: response is of type unknown
2020-03-06 04:59:24 +00:00
apiName : response.data.name ,
pageName : pageName ,
2022-06-21 13:57:34 +00:00
// @ts-expect-error: response is of type unknown
2020-03-06 04:59:24 +00:00
apiID : response.data.id ,
} ) ;
2023-12-27 08:47:35 +00:00
const currentUrl = window . location . pathname ;
2022-06-21 13:57:34 +00:00
// @ts-expect-error: response is of type unknown
2020-01-27 13:53:33 +00:00
yield put ( moveActionSuccess ( response . data ) ) ;
2023-12-27 08:47:35 +00:00
yield put ( removeFocusHistoryRequest ( currentUrl ) ) ;
2020-01-24 09:54:40 +00:00
} catch ( e ) {
2023-05-19 18:37:06 +00:00
toast . show ( createMessage ( ERROR_ACTION_MOVE_FAIL , actionObject . name ) , {
kind : "error" ,
2020-01-24 09:54:40 +00:00
} ) ;
yield put (
moveActionError ( {
id : action.payload.id ,
originalPageId : action.payload.originalPageId ,
} ) ,
) ;
}
}
function * copyActionSaga (
action : ReduxAction < { id : string ; destinationPageId : string ; name : string } > ,
) {
feat: Store `originalActionId` as part of Action DTO for copied action (#25011)
## Description
To measure the impact of query modules in Appsmith. We need to track the
time a user takes to edit a copied query. Today, we do not have a
mechanism to understand if a query in question is a copied query. To fix
this, the data model of the Query action needs to change to include the
`originalQueryId` if a query is, in fact, a copied query.
- [ ] When a query is first copied, there will be no `originalActionId`
in the action object. In this scenario, the client will populate the
`originalActionId` field and call the POST API to create the copied
query.
- [ ] If the query is already a copied query, the client will duplicate
the value of the `originalActionId` when calling the POST API to create
the copied query.
|POST|`/api/v1/actions`|
----------|------|
### [Related discussion on
Notion](https://www.notion.so/appsmith/Backend-dependency-for-modules-instrumentation-889462d461844745be0a2599c8555ca5)
#### PR fixes following issue(s)
Fixes #24734
#### 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
- [x] Manual
- [x] 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
- [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
- [ ] 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
> Pull Request Template
>
> Use this template to quickly create a well written pull request.
Delete all quotes before creating the pull request.
>
## Description
> Add a TL;DR when description is extra long (helps content team)
>
> Please include a summary of the changes and which issue has been
fixed. Please also include relevant motivation
> and context. List any dependencies that are required for this change
>
> Links to Notion, Figma or any other documents that might be relevant
to the PR
>
>
#### 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
- [ ] 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
---------
Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-07-04 07:42:09 +00:00
let actionObject : Action = yield select ( getAction , action . payload . id ) ;
2020-01-24 09:54:40 +00:00
try {
2021-01-12 04:17:28 +00:00
if ( ! actionObject ) throw new Error ( "Could not find action to copy" ) ;
feat: Store `originalActionId` as part of Action DTO for copied action (#25011)
## Description
To measure the impact of query modules in Appsmith. We need to track the
time a user takes to edit a copied query. Today, we do not have a
mechanism to understand if a query in question is a copied query. To fix
this, the data model of the Query action needs to change to include the
`originalQueryId` if a query is, in fact, a copied query.
- [ ] When a query is first copied, there will be no `originalActionId`
in the action object. In this scenario, the client will populate the
`originalActionId` field and call the POST API to create the copied
query.
- [ ] If the query is already a copied query, the client will duplicate
the value of the `originalActionId` when calling the POST API to create
the copied query.
|POST|`/api/v1/actions`|
----------|------|
### [Related discussion on
Notion](https://www.notion.so/appsmith/Backend-dependency-for-modules-instrumentation-889462d461844745be0a2599c8555ca5)
#### PR fixes following issue(s)
Fixes #24734
#### 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
- [x] Manual
- [x] 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
- [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
- [ ] 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
> Pull Request Template
>
> Use this template to quickly create a well written pull request.
Delete all quotes before creating the pull request.
>
## Description
> Add a TL;DR when description is extra long (helps content team)
>
> Please include a summary of the changes and which issue has been
fixed. Please also include relevant motivation
> and context. List any dependencies that are required for this change
>
> Links to Notion, Figma or any other documents that might be relevant
to the PR
>
>
#### 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
- [ ] 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
---------
Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-07-04 07:42:09 +00:00
// At this point the actionObject.id will be the id of the action to be copied
// We enhance the payload with eventData to track the action being copied
actionObject = enhanceRequestPayloadWithEventData (
actionObject ,
action . type ,
) as Action ;
2021-01-12 04:17:28 +00:00
const copyAction = Object . assign ( { } , actionObject , {
2020-01-24 09:54:40 +00:00
name : action.payload.name ,
pageId : action.payload.destinationPageId ,
2021-01-12 04:17:28 +00:00
} ) as Partial < Action > ;
2023-08-07 09:31:45 +00:00
2021-01-12 04:17:28 +00:00
delete copyAction . id ;
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 response : ApiResponse < ActionCreateUpdateResponse > =
yield ActionAPI . createAction ( copyAction ) ;
2022-06-21 13:57:34 +00:00
const datasources : Datasource [ ] = yield select ( getDatasources ) ;
2020-01-24 09:54:40 +00:00
2022-06-21 13:57:34 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
const pageName : string = yield select (
getPageNameByPageId ,
// @ts-expect-error: pageId not present on ActionCreateUpdateResponse
response . data . pageId ,
) ;
2020-01-24 09:54:40 +00:00
if ( isValidResponse ) {
2023-05-19 18:37:06 +00:00
toast . show (
createMessage ( ACTION_COPY_SUCCESS , actionObject . name , pageName ) ,
{
kind : "success" ,
} ,
) ;
2020-03-06 04:59:24 +00:00
feat: Store `originalActionId` as part of Action DTO for copied action (#25011)
## Description
To measure the impact of query modules in Appsmith. We need to track the
time a user takes to edit a copied query. Today, we do not have a
mechanism to understand if a query in question is a copied query. To fix
this, the data model of the Query action needs to change to include the
`originalQueryId` if a query is, in fact, a copied query.
- [ ] When a query is first copied, there will be no `originalActionId`
in the action object. In this scenario, the client will populate the
`originalActionId` field and call the POST API to create the copied
query.
- [ ] If the query is already a copied query, the client will duplicate
the value of the `originalActionId` when calling the POST API to create
the copied query.
|POST|`/api/v1/actions`|
----------|------|
### [Related discussion on
Notion](https://www.notion.so/appsmith/Backend-dependency-for-modules-instrumentation-889462d461844745be0a2599c8555ca5)
#### PR fixes following issue(s)
Fixes #24734
#### 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
- [x] Manual
- [x] 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
- [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
- [ ] 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
> Pull Request Template
>
> Use this template to quickly create a well written pull request.
Delete all quotes before creating the pull request.
>
## Description
> Add a TL;DR when description is extra long (helps content team)
>
> Please include a summary of the changes and which issue has been
fixed. Please also include relevant motivation
> and context. List any dependencies that are required for this change
>
> Links to Notion, Figma or any other documents that might be relevant
to the PR
>
>
#### 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
- [ ] 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
---------
Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-07-04 07:42:09 +00:00
// At this point the `actionObject.id` will not exist
// So we need to get the originalActionId from the payload
// if the eventData in the actionObject doesn't exist
const originalActionId = get (
actionObject ,
` ${ RequestPayloadAnalyticsPath } .originalActionId ` ,
action . payload . id ,
) ;
AnalyticsUtil . logEvent ( "DUPLICATE_ACTION" , {
// @ts-expect-error: name not present on ActionCreateUpdateResponse
actionName : response.data.name ,
pageName : pageName ,
2023-08-30 13:07:09 +00:00
actionId : response.data.id ,
feat: Store `originalActionId` as part of Action DTO for copied action (#25011)
## Description
To measure the impact of query modules in Appsmith. We need to track the
time a user takes to edit a copied query. Today, we do not have a
mechanism to understand if a query in question is a copied query. To fix
this, the data model of the Query action needs to change to include the
`originalQueryId` if a query is, in fact, a copied query.
- [ ] When a query is first copied, there will be no `originalActionId`
in the action object. In this scenario, the client will populate the
`originalActionId` field and call the POST API to create the copied
query.
- [ ] If the query is already a copied query, the client will duplicate
the value of the `originalActionId` when calling the POST API to create
the copied query.
|POST|`/api/v1/actions`|
----------|------|
### [Related discussion on
Notion](https://www.notion.so/appsmith/Backend-dependency-for-modules-instrumentation-889462d461844745be0a2599c8555ca5)
#### PR fixes following issue(s)
Fixes #24734
#### 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
- [x] Manual
- [x] 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
- [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
- [ ] 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
> Pull Request Template
>
> Use this template to quickly create a well written pull request.
Delete all quotes before creating the pull request.
>
## Description
> Add a TL;DR when description is extra long (helps content team)
>
> Please include a summary of the changes and which issue has been
fixed. Please also include relevant motivation
> and context. List any dependencies that are required for this change
>
> Links to Notion, Figma or any other documents that might be relevant
to the PR
>
>
#### 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
- [ ] 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
---------
Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-07-04 07:42:09 +00:00
originalActionId ,
actionType : actionObject.pluginType ,
} ) ;
}
2020-12-10 08:22:40 +00:00
// checking if there is existing datasource to be added to the action payload
const existingDatasource = datasources . find (
( d : Datasource ) = > d . id === response . data . datasource . id ,
) ;
let payload = response . data ;
if ( existingDatasource ) {
payload = { . . . payload , datasource : existingDatasource } ;
}
2022-06-21 13:57:34 +00:00
// @ts-expect-error: type mismatch Action vs ActionCreateUpdateResponse
2020-12-10 08:22:40 +00:00
yield put ( copyActionSuccess ( payload ) ) ;
2020-01-24 09:54:40 +00:00
} catch ( e ) {
2021-03-13 14:24:45 +00:00
const actionName = actionObject ? actionObject . name : "" ;
2023-05-19 18:37:06 +00:00
toast . show ( createMessage ( ERROR_ACTION_COPY_FAIL , actionName ) , {
kind : "error" ,
2020-01-24 09:54:40 +00:00
} ) ;
yield put ( copyActionError ( action . payload ) ) ;
}
}
2020-06-16 10:23:19 +00:00
export function * refactorActionName (
id : string ,
pageId : string ,
oldName : string ,
newName : string ,
) {
// fetch page of the action
2020-09-28 05:12:23 +00:00
PerformanceTracker . startAsyncTracking (
PerformanceTransactionName . REFACTOR_ACTION_NAME ,
{ actionId : id } ,
) ;
2023-11-30 12:33:33 +00:00
const isServerDSLMigrationsEnabled = select ( getIsServerDSLMigrationsEnabled ) ;
const params : FetchPageRequest = { id : pageId } ;
if ( isServerDSLMigrationsEnabled ) {
params . migrateDSL = true ;
}
const pageResponse : FetchPageResponse = yield call ( PageApi . fetchPage , params ) ;
2020-06-16 10:23:19 +00:00
// check if page request is successful
2022-06-21 13:57:34 +00:00
const isPageRequestSuccessful : boolean = yield validateResponse ( pageResponse ) ;
2020-06-16 10:23:19 +00:00
if ( isPageRequestSuccessful ) {
// get the layoutId from the page response
const layoutId = pageResponse . data . layouts [ 0 ] . id ;
// call to refactor action
2022-06-21 13:57:34 +00:00
const refactorResponse : ApiResponse = yield ActionAPI . updateActionName ( {
2020-06-16 10:23:19 +00:00
layoutId ,
2021-04-19 07:05:10 +00:00
actionId : id ,
2020-06-16 10:23:19 +00:00
pageId : pageId ,
oldName : oldName ,
newName : newName ,
} ) ;
2023-10-11 07:14:38 +00:00
const isRefactorSuccessful : boolean =
yield validateResponse ( refactorResponse ) ;
2020-06-16 10:23:19 +00:00
2022-06-21 13:57:34 +00:00
const currentPageId : string = yield select ( getCurrentPageId ) ;
2020-09-28 05:12:23 +00:00
PerformanceTracker . stopAsyncTracking (
PerformanceTransactionName . REFACTOR_ACTION_NAME ,
{ isSuccess : isRefactorSuccessful } ,
) ;
2020-06-16 10:23:19 +00:00
if ( isRefactorSuccessful ) {
2020-06-18 07:46:53 +00:00
yield put ( {
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
type : ReduxActionTypes . SAVE_ACTION_NAME_SUCCESS ,
2020-06-18 07:46:53 +00:00
payload : {
actionId : id ,
} ,
} ) ;
2020-06-16 10:23:19 +00:00
if ( currentPageId === pageId ) {
2022-06-21 13:57:34 +00:00
// @ts-expect-error: refactorResponse is of type unknown
2020-06-16 10:23:19 +00:00
yield updateCanvasWithDSL ( refactorResponse . data , pageId , layoutId ) ;
2023-11-28 09:10:02 +00:00
yield put (
updateActionData ( [
{
entityName : newName ,
dataPath : "data" ,
data : undefined ,
dataPathRef : ` ${ oldName } .data ` ,
} ,
] ) ,
) ;
2020-06-16 10:23:19 +00:00
} else {
yield put ( fetchActionsForPage ( pageId ) ) ;
}
}
}
}
2021-07-26 16:44:10 +00:00
function * bindDataOnCanvasSaga (
action : ReduxAction < {
queryId : string ;
applicationId : string ;
pageId : string ;
} > ,
) {
2021-10-18 14:03:44 +00:00
const { pageId , queryId } = action . payload ;
2022-10-17 15:16:38 +00:00
yield put ( setSnipingModeAction ( { isActive : true , bindTo : queryId } ) ) ;
2021-07-26 16:44:10 +00:00
history . push (
2022-03-25 10:43:26 +00:00
builderURL ( {
2021-10-18 14:03:44 +00:00
pageId ,
2021-07-26 16:44:10 +00:00
} ) ,
) ;
}
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
function * saveActionName ( action : ReduxAction < { id : string ; name : string } > ) {
2020-07-21 14:01:51 +00:00
// Takes from state, checks if the name isValid, saves
2020-06-18 14:16:49 +00:00
const apiId = action . payload . id ;
2022-06-21 13:57:34 +00:00
const api = shouldBeDefined < ActionData > (
yield select ( ( state ) = >
state . entities . actions . find (
( action : ActionData ) = > action . config . id === apiId ,
) ,
2020-06-18 14:16:49 +00:00
) ,
2022-06-21 13:57:34 +00:00
` Api not found for apiId - ${ apiId } ` ,
2020-06-18 14:16:49 +00:00
) ;
2022-06-21 13:57:34 +00:00
2020-06-17 13:16:14 +00:00
try {
2020-06-18 07:46:53 +00:00
yield refactorActionName (
api . config . id ,
2023-10-27 06:36:57 +00:00
api . config . pageId || "" ,
2020-06-18 07:46:53 +00:00
api . config . name ,
action . payload . name ,
2020-06-17 13:16:14 +00:00
) ;
2020-06-18 07:46:53 +00:00
} catch ( e ) {
yield put ( {
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
type : ReduxActionErrorTypes . SAVE_ACTION_NAME_ERROR ,
2020-06-18 07:46:53 +00:00
payload : {
actionId : action.payload.id ,
2020-06-18 14:16:49 +00:00
oldName : api.config.name ,
2020-06-18 07:46:53 +00:00
} ,
} ) ;
2023-05-19 18:37:06 +00:00
toast . show ( createMessage ( ERROR_ACTION_RENAME_FAIL , action . payload . name ) , {
kind : "error" ,
2020-06-17 13:16:14 +00:00
} ) ;
2021-11-05 05:49:19 +00:00
log . error ( e ) ;
2020-06-16 10:23:19 +00:00
}
}
2021-11-25 13:18:40 +00:00
export function * setActionPropertySaga (
2022-09-01 05:11:57 +00:00
action : EvaluationReduxAction < SetActionPropertyPayload > ,
2021-11-25 13:18:40 +00:00
) {
2021-12-07 09:45:18 +00:00
const { actionId , propertyName , skipSave , value } = action . payload ;
2020-07-03 08:58:58 +00:00
if ( ! actionId ) return ;
2020-07-06 04:19:49 +00:00
if ( propertyName === "name" ) return ;
2020-08-27 15:39:16 +00:00
2021-12-07 09:45:18 +00:00
const actionObj : Action = yield select ( getAction , actionId ) ;
2021-06-04 07:09:36 +00:00
const fieldToBeUpdated = propertyName . replace (
"actionConfiguration" ,
"config" ,
) ;
2023-05-19 18:37:06 +00:00
if ( ! actionObj ) {
return ;
}
2023-05-26 10:13:18 +00:00
// we use the formData to crosscheck, just in case value is not updated yet.
const formData : Action = yield select (
getFormValues (
actionObj ? . pluginType === PluginType . API
? API_EDITOR_FORM_NAME
: QUERY_EDITOR_FORM_NAME ,
) ,
) ;
2021-04-23 13:50:55 +00:00
AppsmithConsole . info ( {
2021-06-04 07:09:36 +00:00
logType : LOG_TYPE.ACTION_UPDATE ,
2021-04-23 13:50:55 +00:00
text : "Configuration updated" ,
source : {
type : ENTITY_TYPE . ACTION ,
2023-05-19 18:37:06 +00:00
name : actionObj?.name ,
2021-04-23 13:50:55 +00:00
id : actionId ,
2021-06-04 07:09:36 +00:00
propertyPath : fieldToBeUpdated ,
2021-04-23 13:50:55 +00:00
} ,
state : {
2021-06-04 07:09:36 +00:00
[ fieldToBeUpdated ] : value ,
2021-04-23 13:50:55 +00:00
} ,
} ) ;
2020-07-03 08:58:58 +00:00
const effects : Record < string , any > = { } ;
// Value change effect
effects [ propertyName ] = value ;
// Bindings change effect
effects . dynamicBindingPathList = getDynamicBindingsChangesSaga (
actionObj ,
value ,
propertyName ,
2023-05-26 10:13:18 +00:00
formData ,
2020-07-03 08:58:58 +00:00
) ;
yield all (
2020-12-24 04:32:25 +00:00
Object . keys ( effects ) . map ( ( field ) = >
2022-09-01 05:11:57 +00:00
put (
updateActionProperty (
{ id : actionId , field , value : effects [ field ] } ,
field === "dynamicBindingPathList" ? [ ] : action . postEvalActions ,
) ,
) ,
2020-07-03 08:58:58 +00:00
) ,
) ;
2020-08-27 15:39:16 +00:00
if ( propertyName === "executeOnLoad" ) {
yield put ( {
type : ReduxActionTypes . TOGGLE_ACTION_EXECUTE_ON_LOAD_INIT ,
payload : {
actionId ,
shouldExecute : value ,
} ,
} ) ;
return ;
}
2021-12-07 09:45:18 +00:00
//skipSave property is added to skip API calls when the updateAction needs to be called from the caller
if ( ! skipSave ) yield put ( updateAction ( { id : actionId } ) ) ;
2020-07-03 08:58:58 +00:00
}
2020-08-27 15:39:16 +00:00
function * toggleActionExecuteOnLoadSaga (
action : ReduxAction < { actionId : string ; shouldExecute : boolean } > ,
) {
try {
2022-06-21 13:57:34 +00:00
const response : ApiResponse = yield call (
2020-08-27 15:39:16 +00:00
ActionAPI . toggleActionExecuteOnLoad ,
action . payload . actionId ,
action . payload . shouldExecute ,
) ;
2022-06-21 13:57:34 +00:00
const isValidResponse : boolean = yield validateResponse ( response ) ;
2020-08-27 15:39:16 +00:00
if ( isValidResponse ) {
yield put ( {
type : ReduxActionTypes . TOGGLE_ACTION_EXECUTE_ON_LOAD_SUCCESS ,
} ) ;
}
} catch ( error ) {
yield put ( {
type : ReduxActionErrorTypes . TOGGLE_ACTION_EXECUTE_ON_LOAD_ERROR ,
payload : error ,
} ) ;
}
}
2020-07-07 08:07:37 +00:00
function * handleMoveOrCopySaga ( actionPayload : ReduxAction < { id : string } > ) {
const { id } = actionPayload . payload ;
2020-08-21 06:03:04 +00:00
const action : Action = yield select ( getAction , id ) ;
2021-04-22 03:30:09 +00:00
const isApi = action . pluginType === PluginType . API ;
const isQuery = action . pluginType === PluginType . DB ;
2021-09-23 11:35:49 +00:00
const isSaas = action . pluginType === PluginType . SAAS ;
2020-07-07 08:07:37 +00:00
if ( isApi ) {
2022-03-25 10:43:26 +00:00
history . push (
apiEditorIdURL ( {
pageId : action.pageId ,
apiId : action.id ,
} ) ,
) ;
2020-07-07 08:07:37 +00:00
}
if ( isQuery ) {
2020-08-21 06:03:04 +00:00
history . push (
2022-03-25 10:43:26 +00:00
queryEditorIdURL ( {
pageId : action.pageId ,
queryId : action.id ,
} ) ,
2020-08-21 06:03:04 +00:00
) ;
2020-07-07 08:07:37 +00:00
}
2021-04-22 03:30:09 +00:00
if ( isSaas ) {
2022-06-21 13:57:34 +00:00
const plugin = shouldBeDefined < Plugin > (
yield select ( getPlugin , action . pluginId ) ,
` Plugin not found for pluginId - ${ action . pluginId } ` ,
) ;
2021-04-22 03:30:09 +00:00
history . push (
2022-03-25 10:43:26 +00:00
saasEditorApiIdURL ( {
pageId : action.pageId ,
pluginPackageName : plugin.packageName ,
apiId : action.id ,
} ) ,
2021-04-22 03:30:09 +00:00
) ;
}
2020-07-07 08:07:37 +00:00
}
2021-09-22 16:59:47 +00:00
function * executeCommandSaga ( actionPayload : ReduxAction < SlashCommandPayload > ) {
2021-09-08 06:50:21 +00:00
const pageId : string = yield select ( getCurrentPageId ) ;
2021-09-22 16:59:47 +00:00
const callback = get ( actionPayload , "payload.callback" ) ;
2021-07-07 03:46:16 +00:00
switch ( actionPayload . payload . actionType ) {
2021-09-22 16:59:47 +00:00
case SlashCommand . NEW_INTEGRATION :
2021-07-07 03:46:16 +00:00
history . push (
2022-03-25 10:43:26 +00:00
integrationEditorURL ( {
2022-07-11 04:06:29 +00:00
pageId ,
2022-03-25 10:43:26 +00:00
selectedTab : INTEGRATION_TABS.NEW ,
} ) ,
2021-07-07 03:46:16 +00:00
) ;
break ;
2021-09-22 16:59:47 +00:00
case SlashCommand . NEW_QUERY :
2021-07-07 03:46:16 +00:00
const datasource = get ( actionPayload , "payload.args.datasource" ) ;
2022-09-09 15:59:47 +00:00
yield put ( createNewQueryAction ( pageId , "QUICK_COMMANDS" , datasource . id ) ) ;
2022-06-21 13:57:34 +00:00
// @ts-expect-error: QUERY is of type unknown
2021-07-07 03:46:16 +00:00
const QUERY = yield take ( ReduxActionTypes . CREATE_ACTION_SUCCESS ) ;
2021-09-22 16:59:47 +00:00
if ( callback ) callback ( ` {{ ${ QUERY . payload . name } .data}} ` ) ;
2021-07-07 03:46:16 +00:00
break ;
2021-09-22 16:59:47 +00:00
case SlashCommand . NEW_API :
2021-07-07 03:46:16 +00:00
yield put ( createNewApiAction ( pageId , "QUICK_COMMANDS" ) ) ;
2022-06-21 13:57:34 +00:00
// @ts-expect-error: QUERY is of type unknown
2021-07-07 03:46:16 +00:00
const API = yield take ( ReduxActionTypes . CREATE_ACTION_SUCCESS ) ;
2021-09-22 16:59:47 +00:00
if ( callback ) callback ( ` {{ ${ API . payload . name } .data}} ` ) ;
2021-07-07 03:46:16 +00:00
break ;
2023-05-08 03:39:03 +00:00
case SlashCommand . ASK_AI : {
const context = get ( actionPayload , "payload.args" , { } ) ;
2023-08-31 10:59:53 +00:00
const isJavascriptMode = context . mode === EditorModes . TEXT_WITH_BINDING ;
2023-07-13 12:06:38 +00:00
const noOfTimesAIPromptTriggered : number = yield select (
( state ) = > state . ai . noOfTimesAITriggered ,
) ;
2023-08-31 10:59:53 +00:00
const noOfTimesAIPromptTriggeredForQuery : number = yield select (
( state ) = > state . ai . noOfTimesAITriggeredForQuery ,
) ;
const triggerCount = isJavascriptMode
? noOfTimesAIPromptTriggered
: noOfTimesAIPromptTriggeredForQuery ;
if ( triggerCount < 5 ) {
const currentValue : number = yield setAIPromptTriggered ( context . mode ) ;
2023-07-13 12:06:38 +00:00
yield put ( {
type : ReduxActionTypes . UPDATE_AI_TRIGGERED ,
payload : {
value : currentValue ,
2023-08-31 10:59:53 +00:00
mode : context.mode ,
2023-07-13 12:06:38 +00:00
} ,
} ) ;
}
2023-05-08 03:39:03 +00:00
yield put ( {
2023-10-13 12:17:51 +00:00
type : ReduxActionTypes . UPDATE_AI_CONTEXT ,
2023-05-08 03:39:03 +00:00
payload : {
context ,
} ,
} ) ;
2023-04-20 15:12:35 +00:00
break ;
2023-05-08 03:39:03 +00:00
}
2021-07-07 03:46:16 +00:00
}
}
2021-12-24 13:59:02 +00:00
function * updateEntitySavingStatus() {
yield race ( [
take ( ReduxActionTypes . UPDATE_ACTION_SUCCESS ) ,
take ( ReduxActionTypes . SAVE_PAGE_SUCCESS ) ,
2022-03-04 05:36:13 +00:00
take ( ReduxActionTypes . UPDATE_JS_ACTION_BODY_SUCCESS ) ,
2021-12-24 13:59:02 +00:00
] ) ;
yield put ( {
type : ReduxActionTypes . ENTITY_UPDATE_SUCCESS ,
} ) ;
}
2019-10-21 15:12:45 +00:00
export function * watchActionSagas() {
yield all ( [
2020-07-03 08:58:58 +00:00
takeEvery ( ReduxActionTypes . SET_ACTION_PROPERTY , setActionPropertySaga ) ,
2019-10-21 15:12:45 +00:00
takeEvery ( ReduxActionTypes . FETCH_ACTIONS_INIT , fetchActionsSaga ) ,
2020-07-15 13:01:35 +00:00
takeEvery (
ReduxActionTypes . FETCH_ACTIONS_VIEW_MODE_INIT ,
fetchActionsForViewModeSaga ,
) ,
2024-01-17 10:04:50 +00:00
takeEvery ( ReduxActionTypes . CREATE_ACTION_REQUEST , createActionRequestSaga ) ,
2020-04-22 09:15:24 +00:00
takeEvery ( ReduxActionTypes . CREATE_ACTION_INIT , createActionSaga ) ,
2020-07-28 10:41:51 +00:00
takeLatest ( ReduxActionTypes . UPDATE_ACTION_INIT , updateActionSaga ) ,
2019-10-25 05:35:20 +00:00
takeLatest ( ReduxActionTypes . DELETE_ACTION_INIT , deleteActionSaga ) ,
2021-07-26 16:44:10 +00:00
takeLatest ( ReduxActionTypes . BIND_DATA_ON_CANVAS , bindDataOnCanvasSaga ) ,
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
takeLatest ( ReduxActionTypes . SAVE_ACTION_NAME_INIT , saveActionName ) ,
2020-01-24 09:54:40 +00:00
takeLatest ( ReduxActionTypes . MOVE_ACTION_INIT , moveActionSaga ) ,
takeLatest ( ReduxActionTypes . COPY_ACTION_INIT , copyActionSaga ) ,
2020-02-21 12:16:49 +00:00
takeLatest (
ReduxActionTypes . FETCH_ACTIONS_FOR_PAGE_INIT ,
fetchActionsForPageSaga ,
) ,
2020-07-07 08:07:37 +00:00
takeEvery ( ReduxActionTypes . MOVE_ACTION_SUCCESS , handleMoveOrCopySaga ) ,
takeEvery ( ReduxActionTypes . COPY_ACTION_SUCCESS , handleMoveOrCopySaga ) ,
takeEvery ( ReduxActionErrorTypes . MOVE_ACTION_ERROR , handleMoveOrCopySaga ) ,
takeEvery ( ReduxActionErrorTypes . COPY_ACTION_ERROR , handleMoveOrCopySaga ) ,
2020-08-27 15:39:16 +00:00
takeLatest (
ReduxActionTypes . TOGGLE_ACTION_EXECUTE_ON_LOAD_INIT ,
toggleActionExecuteOnLoadSaga ,
) ,
2021-09-22 16:59:47 +00:00
takeLatest ( ReduxActionTypes . EXECUTE_COMMAND , executeCommandSaga ) ,
2021-12-24 13:59:02 +00:00
takeLatest (
ReduxActionTypes . ENTITY_UPDATE_STARTED ,
updateEntitySavingStatus ,
) ,
2019-10-21 15:12:45 +00:00
] ) ;
}