2022-10-26 10:00:55 +00:00
|
|
|
import { call, put, select } from "redux-saga/effects";
|
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 {
|
|
|
|
|
ReduxAction,
|
|
|
|
|
ReduxActionWithPromise,
|
|
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2019-12-23 12:16:33 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionErrorTypes,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2020-02-03 10:37:03 +00:00
|
|
|
import {
|
|
|
|
|
validateResponse,
|
|
|
|
|
callAPI,
|
|
|
|
|
getResponseErrorMessage,
|
|
|
|
|
} from "sagas/ErrorSagas";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type {
|
2022-06-15 15:37:41 +00:00
|
|
|
FetchWorkspaceRolesResponse,
|
|
|
|
|
SaveWorkspaceRequest,
|
|
|
|
|
FetchWorkspaceRequest,
|
|
|
|
|
FetchWorkspaceResponse,
|
|
|
|
|
CreateWorkspaceRequest,
|
2020-06-17 10:19:56 +00:00
|
|
|
FetchAllUsersResponse,
|
|
|
|
|
FetchAllUsersRequest,
|
|
|
|
|
FetchAllRolesResponse,
|
2022-06-15 15:37:41 +00:00
|
|
|
DeleteWorkspaceUserRequest,
|
2020-06-17 10:19:56 +00:00
|
|
|
ChangeUserRoleRequest,
|
2020-08-12 11:41:56 +00:00
|
|
|
FetchAllRolesRequest,
|
2022-06-15 15:37:41 +00:00
|
|
|
SaveWorkspaceLogo,
|
2022-10-26 10:00:55 +00:00
|
|
|
} from "@appsmith/api/WorkspaceApi";
|
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 WorkspaceApi from "@appsmith/api/WorkspaceApi";
|
|
|
|
|
import type { ApiResponse } from "api/ApiResponses";
|
2023-01-23 03:50:47 +00:00
|
|
|
import { Toaster, Variant } from "design-system-old";
|
2022-06-15 15:37:41 +00:00
|
|
|
import { getCurrentWorkspace } from "@appsmith/selectors/workspaceSelectors";
|
2021-06-03 18:36:34 +00:00
|
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
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 { Workspace } from "@appsmith/constants/workspaceConstants";
|
2021-01-21 06:19:06 +00:00
|
|
|
import history from "utils/history";
|
2021-06-03 18:36:34 +00:00
|
|
|
import { APPLICATIONS_URL } from "constants/routes";
|
2023-03-29 17:07:06 +00:00
|
|
|
import { getAllApplications } from "@appsmith/actions/applicationActions";
|
2021-03-13 14:24:45 +00:00
|
|
|
import log from "loglevel";
|
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 { User } from "constants/userConstants";
|
2022-02-11 18:08:46 +00:00
|
|
|
import {
|
|
|
|
|
createMessage,
|
2022-06-15 15:37:41 +00:00
|
|
|
DELETE_WORKSPACE_SUCCESSFUL,
|
2022-02-11 18:08:46 +00:00
|
|
|
} from "@appsmith/constants/messages";
|
2019-12-23 12:16:33 +00:00
|
|
|
|
|
|
|
|
export function* fetchRolesSaga() {
|
|
|
|
|
try {
|
2022-06-15 15:37:41 +00:00
|
|
|
const response: FetchWorkspaceRolesResponse = yield call(
|
|
|
|
|
WorkspaceApi.fetchRoles,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2019-12-23 12:16:33 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.FETCH_WORKSPACE_ROLES_SUCCESS,
|
2019-12-23 12:16:33 +00:00
|
|
|
payload: response.data,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2019-12-23 12:16:33 +00:00
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.FETCH_WORKSPACE_ROLES_ERROR,
|
2019-12-23 12:16:33 +00:00
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* fetchWorkspaceSaga(
|
|
|
|
|
action: ReduxAction<FetchWorkspaceRequest>,
|
|
|
|
|
) {
|
2019-12-23 12:16:33 +00:00
|
|
|
try {
|
2022-06-15 15:37:41 +00:00
|
|
|
const request: FetchWorkspaceRequest = action.payload;
|
|
|
|
|
const response: FetchWorkspaceResponse = yield call(
|
|
|
|
|
WorkspaceApi.fetchWorkspace,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield request.skipValidation ||
|
2021-07-16 08:31:26 +00:00
|
|
|
validateResponse(response);
|
2019-12-23 12:16:33 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.FETCH_WORKSPACE_SUCCESS,
|
2021-07-16 08:31:26 +00:00
|
|
|
payload: response.data || {},
|
2019-12-23 12:16:33 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.FETCH_WORKSPACE_ERROR,
|
2019-12-23 12:16:33 +00:00
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 10:19:56 +00:00
|
|
|
export function* fetchAllUsersSaga(action: ReduxAction<FetchAllUsersRequest>) {
|
|
|
|
|
try {
|
|
|
|
|
const request: FetchAllUsersRequest = action.payload;
|
|
|
|
|
const response: FetchAllUsersResponse = yield call(
|
2022-06-15 15:37:41 +00:00
|
|
|
WorkspaceApi.fetchAllUsers,
|
2020-06-17 10:19:56 +00:00
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-06-17 10:19:56 +00:00
|
|
|
if (isValidResponse) {
|
2020-12-24 04:32:25 +00:00
|
|
|
const users = response.data.map((user) => ({
|
2020-06-25 03:05:41 +00:00
|
|
|
...user,
|
|
|
|
|
isDeleting: false,
|
|
|
|
|
isChangingRole: false,
|
|
|
|
|
}));
|
2020-06-17 10:19:56 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.FETCH_ALL_USERS_SUCCESS,
|
2020-06-25 03:05:41 +00:00
|
|
|
payload: users,
|
2020-06-17 10:19:56 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.FETCH_ALL_USERS_ERROR,
|
|
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* changeWorkspaceUserRoleSaga(
|
2020-06-17 10:19:56 +00:00
|
|
|
action: ReduxAction<ChangeUserRoleRequest>,
|
|
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
const request: ChangeUserRoleRequest = action.payload;
|
2022-06-15 15:37:41 +00:00
|
|
|
const response: ApiResponse = yield call(
|
|
|
|
|
WorkspaceApi.changeWorkspaceUserRole,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-06-17 10:19:56 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.CHANGE_WORKSPACE_USER_ROLE_SUCCESS,
|
2020-06-17 10:19:56 +00:00
|
|
|
payload: response.data,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.CHANGE_WORKSPACE_USER_ROLE_ERROR,
|
2020-08-28 18:51:16 +00:00
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
2020-06-17 10:19:56 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* deleteWorkspaceUserSaga(
|
|
|
|
|
action: ReduxAction<DeleteWorkspaceUserRequest>,
|
|
|
|
|
) {
|
2020-06-17 10:19:56 +00:00
|
|
|
try {
|
2022-06-15 15:37:41 +00:00
|
|
|
const request: DeleteWorkspaceUserRequest = action.payload;
|
|
|
|
|
const response: ApiResponse = yield call(
|
|
|
|
|
WorkspaceApi.deleteWorkspaceUser,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-06-17 10:19:56 +00:00
|
|
|
if (isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const currentUser: User | undefined = yield select(getCurrentUser);
|
2021-06-03 18:36:34 +00:00
|
|
|
if (currentUser?.username == action.payload.username) {
|
|
|
|
|
history.replace(APPLICATIONS_URL);
|
|
|
|
|
} else {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.DELETE_WORKSPACE_USER_SUCCESS,
|
2021-06-03 18:36:34 +00:00
|
|
|
payload: {
|
|
|
|
|
username: action.payload.username,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-11-24 07:01:37 +00:00
|
|
|
Toaster.show({
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2020-11-24 07:01:37 +00:00
|
|
|
text: `${response.data.username} has been removed successfully`,
|
|
|
|
|
variant: Variant.success,
|
2020-06-17 10:19:56 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.DELETE_WORKSPACE_USER_ERROR,
|
2020-06-17 10:19:56 +00:00
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-12 11:41:56 +00:00
|
|
|
export function* fetchAllRolesSaga(action: ReduxAction<FetchAllRolesRequest>) {
|
2020-06-17 10:19:56 +00:00
|
|
|
try {
|
2020-08-12 11:41:56 +00:00
|
|
|
const request: FetchAllRolesRequest = action.payload;
|
|
|
|
|
const response: FetchAllRolesResponse = yield call(
|
2022-06-15 15:37:41 +00:00
|
|
|
WorkspaceApi.fetchAllRoles,
|
2020-08-12 11:41:56 +00:00
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-06-17 10:19:56 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.FETCH_ALL_ROLES_SUCCESS,
|
|
|
|
|
payload: response.data,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.FETCH_ALL_ROLES_ERROR,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* saveWorkspaceSaga(action: ReduxAction<SaveWorkspaceRequest>) {
|
2019-12-23 12:16:33 +00:00
|
|
|
try {
|
2022-06-15 15:37:41 +00:00
|
|
|
const request: SaveWorkspaceRequest = action.payload;
|
|
|
|
|
const response: ApiResponse = yield call(
|
|
|
|
|
WorkspaceApi.saveWorkspace,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2019-12-23 12:16:33 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.SAVE_WORKSPACE_SUCCESS,
|
2020-11-25 12:24:14 +00:00
|
|
|
payload: request,
|
2019-12-23 12:16:33 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.SAVE_WORKSPACE_ERROR,
|
2019-12-23 12:16:33 +00:00
|
|
|
payload: {
|
2022-06-21 13:57:34 +00:00
|
|
|
error: (error as Error).message,
|
2019-12-23 12:16:33 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* deleteWorkspaceSaga(action: ReduxAction<string>) {
|
2021-12-20 05:58:01 +00:00
|
|
|
try {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.SAVING_WORKSPACE_INFO,
|
2021-12-20 05:58:01 +00:00
|
|
|
});
|
2022-06-15 15:37:41 +00:00
|
|
|
const workspaceId: string = action.payload;
|
|
|
|
|
const response: ApiResponse = yield call(
|
|
|
|
|
WorkspaceApi.deleteWorkspace,
|
|
|
|
|
workspaceId,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2021-12-20 05:58:01 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.DELETE_WORKSPACE_SUCCESS,
|
|
|
|
|
payload: workspaceId,
|
2021-12-20 05:58:01 +00:00
|
|
|
});
|
|
|
|
|
Toaster.show({
|
2022-06-15 15:37:41 +00:00
|
|
|
text: createMessage(DELETE_WORKSPACE_SUCCESSFUL),
|
2021-12-20 05:58:01 +00:00
|
|
|
variant: Variant.success,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.DELETE_WORKSPACE_ERROR,
|
2021-12-20 05:58:01 +00:00
|
|
|
payload: {
|
2022-06-21 13:57:34 +00:00
|
|
|
error: (error as Error).message,
|
2021-12-20 05:58:01 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* createWorkspaceSaga(
|
|
|
|
|
action: ReduxActionWithPromise<CreateWorkspaceRequest>,
|
2020-02-03 10:37:03 +00:00
|
|
|
) {
|
2021-05-13 08:35:39 +00:00
|
|
|
const { name, reject, resolve } = action.payload;
|
2020-02-03 10:37:03 +00:00
|
|
|
try {
|
2022-06-15 15:37:41 +00:00
|
|
|
const request: CreateWorkspaceRequest = { name };
|
|
|
|
|
const response: ApiResponse = yield callAPI(
|
|
|
|
|
WorkspaceApi.createWorkspace,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-02-03 10:37:03 +00:00
|
|
|
if (!isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const errorMessage: string | undefined = yield getResponseErrorMessage(
|
|
|
|
|
response,
|
|
|
|
|
);
|
2020-02-03 10:37:03 +00:00
|
|
|
yield call(reject, { _error: errorMessage });
|
|
|
|
|
} else {
|
|
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.CREATE_WORKSPACE_SUCCESS,
|
2020-02-03 10:37:03 +00:00
|
|
|
payload: response.data,
|
|
|
|
|
});
|
|
|
|
|
|
2021-01-21 06:19:06 +00:00
|
|
|
yield put(getAllApplications());
|
2020-02-03 10:37:03 +00:00
|
|
|
yield call(resolve);
|
|
|
|
|
}
|
2021-01-21 06:19:06 +00:00
|
|
|
|
2022-07-20 11:54:16 +00:00
|
|
|
// get created workspace in focus
|
2022-06-21 13:57:34 +00:00
|
|
|
// @ts-expect-error: response is of type unknown
|
2022-06-15 15:37:41 +00:00
|
|
|
const workspaceId = response.data.id;
|
|
|
|
|
history.push(`${window.location.pathname}#${workspaceId}`);
|
2020-02-03 10:37:03 +00:00
|
|
|
} catch (error) {
|
2022-06-21 13:57:34 +00:00
|
|
|
yield call(reject, { _error: (error as Error).message });
|
2020-02-03 10:37:03 +00:00
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.CREATE_WORKSPACE_ERROR,
|
2020-02-03 10:37:03 +00:00
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* uploadWorkspaceLogoSaga(
|
|
|
|
|
action: ReduxAction<SaveWorkspaceLogo>,
|
|
|
|
|
) {
|
2020-12-01 22:01:27 +00:00
|
|
|
try {
|
|
|
|
|
const request = action.payload;
|
2022-06-15 15:37:41 +00:00
|
|
|
const response: ApiResponse = yield call(
|
|
|
|
|
WorkspaceApi.saveWorkspaceLogo,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-12-01 22:01:27 +00:00
|
|
|
if (isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const allWorkspaces: Workspace[] = yield select(getCurrentWorkspace);
|
2022-06-15 15:37:41 +00:00
|
|
|
const currentWorkspace = allWorkspaces.filter(
|
|
|
|
|
(el: Workspace) => el.id === request.id,
|
|
|
|
|
);
|
|
|
|
|
if (currentWorkspace.length > 0) {
|
2020-12-01 22:01:27 +00:00
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.SAVE_WORKSPACE_SUCCESS,
|
2020-12-11 07:01:13 +00:00
|
|
|
payload: {
|
2022-06-15 15:37:41 +00:00
|
|
|
id: currentWorkspace[0].id,
|
2022-06-21 13:57:34 +00:00
|
|
|
// @ts-expect-error: response is of type unknown
|
2020-12-11 07:01:13 +00:00
|
|
|
logoUrl: response.data.logoUrl,
|
|
|
|
|
},
|
2020-12-01 22:01:27 +00:00
|
|
|
});
|
|
|
|
|
Toaster.show({
|
|
|
|
|
text: "Logo uploaded successfully",
|
|
|
|
|
variant: Variant.success,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error("Error occured while uploading the logo", error);
|
2020-12-01 22:01:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* deleteWorkspaceLogoSaga(action: ReduxAction<{ id: string }>) {
|
2020-12-01 22:01:27 +00:00
|
|
|
try {
|
|
|
|
|
const request = action.payload;
|
2022-06-15 15:37:41 +00:00
|
|
|
const response: ApiResponse = yield call(
|
|
|
|
|
WorkspaceApi.deleteWorkspaceLogo,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-12-01 22:01:27 +00:00
|
|
|
if (isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const allWorkspaces: Workspace[] = yield select(getCurrentWorkspace);
|
2022-06-15 15:37:41 +00:00
|
|
|
const currentWorkspace = allWorkspaces.filter(
|
|
|
|
|
(el: Workspace) => el.id === request.id,
|
|
|
|
|
);
|
|
|
|
|
if (currentWorkspace.length > 0) {
|
2020-12-01 22:01:27 +00:00
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.SAVE_WORKSPACE_SUCCESS,
|
2020-12-11 07:01:13 +00:00
|
|
|
payload: {
|
2022-06-15 15:37:41 +00:00
|
|
|
id: currentWorkspace[0].id,
|
2022-06-21 13:57:34 +00:00
|
|
|
// @ts-expect-error: response is of type unknown
|
2020-12-11 07:01:13 +00:00
|
|
|
logoUrl: response.data.logoUrl,
|
|
|
|
|
},
|
2020-12-01 22:01:27 +00:00
|
|
|
});
|
|
|
|
|
Toaster.show({
|
|
|
|
|
text: "Logo removed successfully",
|
|
|
|
|
variant: Variant.success,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error("Error occured while removing the logo", error);
|
2020-12-01 22:01:27 +00:00
|
|
|
}
|
|
|
|
|
}
|