PromucFlow_constructor/app/client/src/ce/actions/workspaceActions.ts
Michael Carner a3fe54f217
fix: reset workspace before deleting a workspace (#23782)
## Description
Fixes [#12057](https://github.com/appsmithorg/appsmith/issues/12057)

In specific scenarios, the currentWorkspace is not up to date and uses a
previous workspace, which can cause certain API calls to fail. The end
result is the user sees a "No Resource Found" error with no clear
explanation.

This changes adds a new ReduxAction RESET_CURRENT_WORKSPACE with returns
it to it's initial value. The only place I've added that is at the
begining of deleteWorkspaceSaga()

#### PR fixes following issue(s)
Fixes # (12057)

#### Type of change
- Bug fix (non-breaking change which fixes an issue)

## Testing

#### How Has This Been Tested?
- [x] Manual


## 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] My changes generate no new warnings
- [x] New and existing unit tests pass locally with my changes


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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
2023-06-02 17:50:53 +05:30

96 lines
2.0 KiB
TypeScript

import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import type {
SaveWorkspaceLogo,
SaveWorkspaceRequest,
} from "@appsmith/api/WorkspaceApi";
export const fetchWorkspace = (
workspaceId: string,
skipValidation?: boolean,
) => {
return {
type: ReduxActionTypes.FETCH_CURRENT_WORKSPACE,
payload: {
workspaceId,
skipValidation,
},
};
};
export const resetCurrentWorkspace = () => {
return {
type: ReduxActionTypes.RESET_CURRENT_WORKSPACE,
};
};
export const deleteWorkspace = (workspaceId: string) => {
return {
type: ReduxActionTypes.DELETE_WORKSPACE_INIT,
payload: workspaceId,
};
};
export const changeWorkspaceUserRole = (
workspaceId: string,
newPermissionGroupId: string,
username: string,
) => {
return {
type: ReduxActionTypes.CHANGE_WORKSPACE_USER_ROLE_INIT,
payload: {
workspaceId,
newPermissionGroupId,
username,
},
};
};
export const deleteWorkspaceUser = (workspaceId: string, username: string) => {
return {
type: ReduxActionTypes.DELETE_WORKSPACE_USER_INIT,
payload: {
workspaceId,
username,
},
};
};
export const fetchUsersForWorkspace = (workspaceId: string) => {
return {
type: ReduxActionTypes.FETCH_ALL_USERS_INIT,
payload: {
workspaceId,
},
};
};
export const fetchRolesForWorkspace = (workspaceId: string) => {
return {
type: ReduxActionTypes.FETCH_ALL_ROLES_INIT,
payload: {
workspaceId,
},
};
};
export const saveWorkspace = (workspaceSettings: SaveWorkspaceRequest) => {
return {
type: ReduxActionTypes.SAVE_WORKSPACE_INIT,
payload: workspaceSettings,
};
};
export const uploadWorkspaceLogo = (workspaceLogo: SaveWorkspaceLogo) => {
return {
type: ReduxActionTypes.UPLOAD_WORKSPACE_LOGO,
payload: workspaceLogo,
};
};
export const deleteWorkspaceLogo = (id: string) => {
return {
type: ReduxActionTypes.REMOVE_WORKSPACE_LOGO,
payload: {
id: id,
},
};
};