2021-05-20 12:03:08 +00:00
|
|
|
import { call, takeLatest, put, all, select, take } from "redux-saga/effects";
|
2019-12-16 08:49:10 +00:00
|
|
|
import {
|
|
|
|
|
ReduxAction,
|
2020-01-06 09:07:30 +00:00
|
|
|
ReduxActionWithPromise,
|
2019-12-16 08:49:10 +00:00
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionErrorTypes,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2020-06-09 12:10:55 +00:00
|
|
|
import { reset } from "redux-form";
|
2019-12-16 08:49:10 +00:00
|
|
|
import UserApi, {
|
|
|
|
|
CreateUserRequest,
|
|
|
|
|
CreateUserResponse,
|
|
|
|
|
ForgotPasswordRequest,
|
2020-01-06 09:07:30 +00:00
|
|
|
VerifyTokenRequest,
|
|
|
|
|
TokenPasswordUpdateRequest,
|
2021-03-04 09:37:02 +00:00
|
|
|
UpdateUserRequest,
|
2022-06-15 15:37:41 +00:00
|
|
|
LeaveWorkspaceRequest,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/api/UserApi";
|
2022-04-07 17:57:32 +00:00
|
|
|
import { AUTH_LOGIN_URL, SETUP } from "constants/routes";
|
2020-06-02 08:11:30 +00:00
|
|
|
import history from "utils/history";
|
2019-12-16 08:49:10 +00:00
|
|
|
import { ApiResponse } from "api/ApiResponses";
|
|
|
|
|
import {
|
|
|
|
|
validateResponse,
|
|
|
|
|
getResponseErrorMessage,
|
|
|
|
|
callAPI,
|
|
|
|
|
} from "./ErrorSagas";
|
2020-01-03 08:49:47 +00:00
|
|
|
import {
|
|
|
|
|
logoutUserSuccess,
|
|
|
|
|
logoutUserError,
|
2020-01-06 09:07:30 +00:00
|
|
|
verifyInviteSuccess,
|
|
|
|
|
verifyInviteError,
|
|
|
|
|
invitedUserSignupError,
|
|
|
|
|
invitedUserSignupSuccess,
|
2021-08-05 06:10:19 +00:00
|
|
|
fetchFeatureFlagsSuccess,
|
|
|
|
|
fetchFeatureFlagsError,
|
2020-01-03 08:49:47 +00:00
|
|
|
} from "actions/userActions";
|
2020-03-03 07:02:53 +00:00
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
2022-06-15 15:37:41 +00:00
|
|
|
import { INVITE_USERS_TO_WORKSPACE_FORM } from "constants/forms";
|
2020-09-28 06:29:41 +00:00
|
|
|
import PerformanceTracker, {
|
|
|
|
|
PerformanceTransactionName,
|
|
|
|
|
} from "utils/PerformanceTracker";
|
2022-01-07 06:08:17 +00:00
|
|
|
import { ERROR_CODES } from "@appsmith/constants/ApiConstants";
|
2021-10-01 16:25:55 +00:00
|
|
|
import {
|
|
|
|
|
ANONYMOUS_USERNAME,
|
|
|
|
|
CommentsOnboardingState,
|
2022-06-21 13:57:34 +00:00
|
|
|
User,
|
2021-10-01 16:25:55 +00:00
|
|
|
} from "constants/userConstants";
|
2020-12-17 07:03:59 +00:00
|
|
|
import { flushErrorsAndRedirect } from "actions/errorActions";
|
2021-02-16 06:17:23 +00:00
|
|
|
import localStorage from "utils/localStorage";
|
2021-06-02 09:56:22 +00:00
|
|
|
import { Toaster } from "components/ads/Toast";
|
|
|
|
|
import { Variant } from "components/ads/common";
|
2021-03-13 14:24:45 +00:00
|
|
|
import log from "loglevel";
|
2019-12-23 12:16:33 +00:00
|
|
|
|
2021-05-20 12:03:08 +00:00
|
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
2021-10-01 16:44:19 +00:00
|
|
|
import {
|
|
|
|
|
initAppLevelSocketConnection,
|
|
|
|
|
initPageLevelSocketConnection,
|
|
|
|
|
} from "actions/websocketActions";
|
2021-09-13 07:22:51 +00:00
|
|
|
import {
|
|
|
|
|
getEnableFirstTimeUserOnboarding,
|
|
|
|
|
getFirstTimeUserOnboardingApplicationId,
|
|
|
|
|
getFirstTimeUserOnboardingIntroModalVisibility,
|
|
|
|
|
} from "utils/storage";
|
2021-12-02 20:26:16 +00:00
|
|
|
import { initializeAnalyticsAndTrackers } from "utils/AppsmithUtils";
|
2021-05-20 12:03:08 +00:00
|
|
|
|
2019-12-16 08:49:10 +00:00
|
|
|
export function* createUserSaga(
|
2020-01-06 09:07:30 +00:00
|
|
|
action: ReduxActionWithPromise<CreateUserRequest>,
|
2019-12-16 08:49:10 +00:00
|
|
|
) {
|
2021-05-13 08:35:39 +00:00
|
|
|
const { email, password, reject, resolve } = action.payload;
|
2019-12-16 08:49:10 +00:00
|
|
|
try {
|
|
|
|
|
const request: CreateUserRequest = { email, password };
|
|
|
|
|
const response: CreateUserResponse = yield callAPI(
|
|
|
|
|
UserApi.createUser,
|
|
|
|
|
request,
|
|
|
|
|
);
|
|
|
|
|
//TODO(abhinav): DRY this
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2019-12-16 08:49:10 +00:00
|
|
|
if (!isValidResponse) {
|
|
|
|
|
const errorMessage = getResponseErrorMessage(response);
|
|
|
|
|
yield call(reject, { _error: errorMessage });
|
|
|
|
|
} else {
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2021-05-13 08:35:39 +00:00
|
|
|
const { email, id, name } = response.data;
|
2019-12-16 08:49:10 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.CREATE_USER_SUCCESS,
|
|
|
|
|
payload: {
|
|
|
|
|
email,
|
|
|
|
|
name,
|
|
|
|
|
id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
yield call(resolve);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2022-06-21 13:57:34 +00:00
|
|
|
yield call(reject, { _error: (error as Error).message });
|
2019-12-16 08:49:10 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.CREATE_USER_ERROR,
|
|
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 10:14:03 +00:00
|
|
|
export function* getCurrentUserSaga() {
|
|
|
|
|
try {
|
2020-09-28 06:29:41 +00:00
|
|
|
PerformanceTracker.startAsyncTracking(
|
|
|
|
|
PerformanceTransactionName.USER_ME_API,
|
|
|
|
|
);
|
2020-07-08 10:14:03 +00:00
|
|
|
const response: ApiResponse = yield call(UserApi.getCurrentUser);
|
|
|
|
|
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-07-08 10:14:03 +00:00
|
|
|
if (isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2021-12-02 20:26:16 +00:00
|
|
|
const { enableTelemetry } = response.data;
|
|
|
|
|
if (enableTelemetry) {
|
|
|
|
|
initializeAnalyticsAndTrackers();
|
|
|
|
|
}
|
2021-10-01 16:44:19 +00:00
|
|
|
yield put(initAppLevelSocketConnection());
|
|
|
|
|
yield put(initPageLevelSocketConnection());
|
2020-10-19 11:06:44 +00:00
|
|
|
if (
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2020-10-19 11:06:44 +00:00
|
|
|
!response.data.isAnonymous &&
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2020-10-19 11:06:44 +00:00
|
|
|
response.data.username !== ANONYMOUS_USERNAME
|
|
|
|
|
) {
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2021-12-02 20:26:16 +00:00
|
|
|
enableTelemetry && AnalyticsUtil.identifyUser(response.data);
|
2020-10-19 11:06:44 +00:00
|
|
|
}
|
2021-09-12 16:36:43 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.FETCH_USER_DETAILS_SUCCESS,
|
|
|
|
|
payload: response.data,
|
|
|
|
|
});
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2021-09-12 16:36:43 +00:00
|
|
|
if (response.data.emptyInstance) {
|
|
|
|
|
history.replace(SETUP);
|
2020-08-03 14:18:48 +00:00
|
|
|
}
|
2020-09-28 06:29:41 +00:00
|
|
|
PerformanceTracker.stopAsyncTracking(
|
|
|
|
|
PerformanceTransactionName.USER_ME_API,
|
|
|
|
|
);
|
2020-07-08 10:14:03 +00:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2020-09-28 06:29:41 +00:00
|
|
|
PerformanceTracker.stopAsyncTracking(
|
|
|
|
|
PerformanceTransactionName.USER_ME_API,
|
|
|
|
|
{ failed: true },
|
|
|
|
|
);
|
2020-07-08 10:14:03 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.FETCH_USER_DETAILS_ERROR,
|
|
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
2021-01-11 05:28:10 +00:00
|
|
|
|
|
|
|
|
yield put({
|
2022-04-07 17:57:32 +00:00
|
|
|
type: ReduxActionTypes.SAFE_CRASH_APPSMITH_REQUEST,
|
2021-01-11 05:28:10 +00:00
|
|
|
payload: {
|
|
|
|
|
code: ERROR_CODES.SERVER_ERROR,
|
|
|
|
|
},
|
|
|
|
|
});
|
2020-07-08 10:14:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-16 08:49:10 +00:00
|
|
|
export function* forgotPasswordSaga(
|
2020-01-06 09:07:30 +00:00
|
|
|
action: ReduxActionWithPromise<ForgotPasswordRequest>,
|
2019-12-16 08:49:10 +00:00
|
|
|
) {
|
2021-05-13 08:35:39 +00:00
|
|
|
const { email, reject, resolve } = action.payload;
|
2019-12-16 08:49:10 +00:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const request: ForgotPasswordRequest = { email };
|
|
|
|
|
const response: ApiResponse = yield callAPI(
|
|
|
|
|
UserApi.forgotPassword,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2019-12-16 08:49:10 +00:00
|
|
|
if (!isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const errorMessage: string | undefined = yield getResponseErrorMessage(
|
|
|
|
|
response,
|
|
|
|
|
);
|
2019-12-16 08:49:10 +00:00
|
|
|
yield call(reject, { _error: errorMessage });
|
|
|
|
|
} else {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.FORGOT_PASSWORD_SUCCESS,
|
|
|
|
|
});
|
|
|
|
|
yield call(resolve);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2022-06-21 13:57:34 +00:00
|
|
|
yield call(reject, { _error: (error as Error).message });
|
2019-12-16 08:49:10 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.FORGOT_PASSWORD_ERROR,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* resetPasswordSaga(
|
2020-01-06 09:07:30 +00:00
|
|
|
action: ReduxActionWithPromise<TokenPasswordUpdateRequest>,
|
2019-12-16 08:49:10 +00:00
|
|
|
) {
|
2021-05-13 08:35:39 +00:00
|
|
|
const { email, password, reject, resolve, token } = action.payload;
|
2019-12-16 08:49:10 +00:00
|
|
|
try {
|
2020-01-06 09:07:30 +00:00
|
|
|
const request: TokenPasswordUpdateRequest = {
|
|
|
|
|
email,
|
|
|
|
|
password,
|
2019-12-16 08:49:10 +00:00
|
|
|
token,
|
|
|
|
|
};
|
|
|
|
|
const response: ApiResponse = yield callAPI(UserApi.resetPassword, request);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2019-12-16 08:49:10 +00:00
|
|
|
if (!isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const errorMessage: string | undefined = yield getResponseErrorMessage(
|
|
|
|
|
response,
|
|
|
|
|
);
|
2019-12-16 08:49:10 +00:00
|
|
|
yield call(reject, { _error: errorMessage });
|
|
|
|
|
} else {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.RESET_USER_PASSWORD_SUCCESS,
|
|
|
|
|
});
|
|
|
|
|
yield call(resolve);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2022-06-21 13:57:34 +00:00
|
|
|
yield call(reject, { _error: (error as Error).message });
|
2019-12-16 08:49:10 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.RESET_USER_PASSWORD_ERROR,
|
|
|
|
|
payload: {
|
2022-06-21 13:57:34 +00:00
|
|
|
error: (error as Error).message,
|
2019-12-16 08:49:10 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-06 09:07:30 +00:00
|
|
|
|
|
|
|
|
export function* invitedUserSignupSaga(
|
|
|
|
|
action: ReduxActionWithPromise<TokenPasswordUpdateRequest>,
|
|
|
|
|
) {
|
2021-05-13 08:35:39 +00:00
|
|
|
const { email, password, reject, resolve, token } = action.payload;
|
2020-01-06 09:07:30 +00:00
|
|
|
try {
|
|
|
|
|
const request: TokenPasswordUpdateRequest = { email, password, token };
|
|
|
|
|
const response: ApiResponse = yield callAPI(
|
|
|
|
|
UserApi.confirmInvitedUserSignup,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-01-06 09:07:30 +00:00
|
|
|
if (!isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const errorMessage: string | undefined = yield getResponseErrorMessage(
|
|
|
|
|
response,
|
|
|
|
|
);
|
2020-01-06 09:07:30 +00:00
|
|
|
yield call(reject, { _error: errorMessage });
|
|
|
|
|
} else {
|
|
|
|
|
yield put(invitedUserSignupSuccess());
|
|
|
|
|
yield call(resolve);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2022-06-21 13:57:34 +00:00
|
|
|
yield call(reject, { _error: (error as Error).message });
|
2020-01-06 09:07:30 +00:00
|
|
|
yield put(invitedUserSignupError(error));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-23 12:16:33 +00:00
|
|
|
type InviteUserPayload = {
|
|
|
|
|
email: string;
|
2022-06-15 15:37:41 +00:00
|
|
|
workspaceId: string;
|
2021-01-12 01:22:31 +00:00
|
|
|
roleName: string;
|
2019-12-23 12:16:33 +00:00
|
|
|
};
|
|
|
|
|
|
2021-01-12 01:22:31 +00:00
|
|
|
export function* inviteUser(payload: InviteUserPayload, reject: any) {
|
2019-12-23 12:16:33 +00:00
|
|
|
const response: ApiResponse = yield callAPI(UserApi.inviteUser, payload);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2019-12-23 12:16:33 +00:00
|
|
|
if (!isValidResponse) {
|
|
|
|
|
let errorMessage = `${payload.email}: `;
|
|
|
|
|
errorMessage += getResponseErrorMessage(response);
|
|
|
|
|
yield call(reject, { _error: errorMessage });
|
|
|
|
|
}
|
|
|
|
|
yield;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* inviteUsers(
|
2020-01-06 09:07:30 +00:00
|
|
|
action: ReduxActionWithPromise<{
|
2022-06-15 15:37:41 +00:00
|
|
|
data: { usernames: string[]; workspaceId: string; roleName: string };
|
2019-12-23 12:16:33 +00:00
|
|
|
}>,
|
|
|
|
|
) {
|
2021-05-13 08:35:39 +00:00
|
|
|
const { data, reject, resolve } = action.payload;
|
2019-12-23 12:16:33 +00:00
|
|
|
try {
|
2020-08-11 03:54:36 +00:00
|
|
|
const response: ApiResponse = yield callAPI(UserApi.inviteUser, {
|
|
|
|
|
usernames: data.usernames,
|
2022-06-15 15:37:41 +00:00
|
|
|
workspaceId: data.workspaceId,
|
2020-08-11 03:54:36 +00:00
|
|
|
roleName: data.roleName,
|
2020-06-03 13:54:42 +00:00
|
|
|
});
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-08-11 03:54:36 +00:00
|
|
|
if (!isValidResponse) {
|
|
|
|
|
let errorMessage = `${data.usernames}: `;
|
|
|
|
|
errorMessage += getResponseErrorMessage(response);
|
|
|
|
|
yield call(reject, { _error: errorMessage });
|
|
|
|
|
}
|
2019-12-23 12:16:33 +00:00
|
|
|
yield put({
|
2020-08-12 11:41:56 +00:00
|
|
|
type: ReduxActionTypes.FETCH_ALL_USERS_INIT,
|
|
|
|
|
payload: {
|
2022-06-15 15:37:41 +00:00
|
|
|
workspaceId: data.workspaceId,
|
2020-08-12 11:41:56 +00:00
|
|
|
},
|
2020-06-17 04:17:25 +00:00
|
|
|
});
|
2021-11-02 04:33:51 +00:00
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionTypes.INVITED_USERS_TO_WORKSPACE,
|
2021-11-02 04:33:51 +00:00
|
|
|
payload: {
|
2022-06-15 15:37:41 +00:00
|
|
|
workspaceId: data.workspaceId,
|
2021-11-02 04:33:51 +00:00
|
|
|
users: data.usernames.map((name: string) => ({
|
|
|
|
|
username: name,
|
|
|
|
|
roleName: data.roleName,
|
|
|
|
|
})),
|
|
|
|
|
},
|
|
|
|
|
});
|
2019-12-23 12:16:33 +00:00
|
|
|
yield call(resolve);
|
2022-06-15 15:37:41 +00:00
|
|
|
yield put(reset(INVITE_USERS_TO_WORKSPACE_FORM));
|
2019-12-23 12:16:33 +00:00
|
|
|
} catch (error) {
|
2022-06-21 13:57:34 +00:00
|
|
|
yield call(reject, { _error: (error as Error).message });
|
2019-12-23 12:16:33 +00:00
|
|
|
yield put({
|
2022-06-15 15:37:41 +00:00
|
|
|
type: ReduxActionErrorTypes.INVITE_USERS_TO_WORKSPACE_ERROR,
|
2019-12-23 12:16:33 +00:00
|
|
|
payload: {
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-16 08:49:10 +00:00
|
|
|
|
2021-03-04 09:37:02 +00:00
|
|
|
export function* updateUserDetailsSaga(action: ReduxAction<UpdateUserRequest>) {
|
|
|
|
|
try {
|
2021-10-21 05:36:17 +00:00
|
|
|
const { email, name, role, useCase } = action.payload;
|
2021-03-04 09:37:02 +00:00
|
|
|
const response: ApiResponse = yield callAPI(UserApi.updateUser, {
|
2021-05-20 12:03:08 +00:00
|
|
|
email,
|
2021-03-04 09:37:02 +00:00
|
|
|
name,
|
2021-10-21 05:36:17 +00:00
|
|
|
role,
|
|
|
|
|
useCase,
|
2021-03-04 09:37:02 +00:00
|
|
|
});
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2021-03-04 09:37:02 +00:00
|
|
|
|
|
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.UPDATE_USER_DETAILS_SUCCESS,
|
|
|
|
|
payload: response.data,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.UPDATE_USER_DETAILS_ERROR,
|
2022-06-21 13:57:34 +00:00
|
|
|
payload: (error as Error).message,
|
2021-03-04 09:37:02 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-16 08:49:10 +00:00
|
|
|
export function* verifyResetPasswordTokenSaga(
|
2020-01-06 09:07:30 +00:00
|
|
|
action: ReduxAction<VerifyTokenRequest>,
|
2019-12-16 08:49:10 +00:00
|
|
|
) {
|
|
|
|
|
try {
|
2020-01-06 09:07:30 +00:00
|
|
|
const request: VerifyTokenRequest = action.payload;
|
|
|
|
|
const response: ApiResponse = yield call(
|
2019-12-16 08:49:10 +00:00
|
|
|
UserApi.verifyResetPasswordToken,
|
|
|
|
|
request,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2021-08-17 12:35:00 +00:00
|
|
|
if (isValidResponse && response.data) {
|
2019-12-16 08:49:10 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.RESET_PASSWORD_VERIFY_TOKEN_SUCCESS,
|
|
|
|
|
});
|
2021-08-17 12:35:00 +00:00
|
|
|
} else {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.RESET_PASSWORD_VERIFY_TOKEN_ERROR,
|
|
|
|
|
});
|
2019-12-16 08:49:10 +00:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2019-12-16 08:49:10 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.RESET_PASSWORD_VERIFY_TOKEN_ERROR,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-06 09:07:30 +00:00
|
|
|
export function* verifyUserInviteSaga(action: ReduxAction<VerifyTokenRequest>) {
|
|
|
|
|
try {
|
|
|
|
|
const request: VerifyTokenRequest = action.payload;
|
|
|
|
|
const response: ApiResponse = yield call(UserApi.verifyUserInvite, request);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-01-06 09:07:30 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put(verifyInviteSuccess());
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2020-01-06 09:07:30 +00:00
|
|
|
yield put(verifyInviteError(error));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Initialise comments (#3328)
* Initial scaffolding for comments CRUD APIs
* add actions
* add assets
* state management for existing comments and creating new
* add ui components
* add overlay comments wrapper to baseWidget
* add toggle comment mode button at editor header
* trigger tests
* Disallow commenting as someone else
* Add applicationId for comments
* lint
* Add overlay blacklist to prevent component interaction while adding comments
* Comment thread style updates
* Placeholder comment context menu
* Controlled comment thread visibility for making new comments visible by default
* Update comment type description
* Reset input on save
* Resolve comment thread button ui
* fix close on esc key, dont create new comment on outside click
* Submit on enter
* add emoji picker
* Attempt at adding a websocket server in Java
* CRUD APIs for comment threads
* Add API for getting all threads in application
* Move types to a separate file
* Initial commit for real time server (RTS)
* Add script to start RTS
* Fix position property
* Use create comment thread API
* Use add comment to thread API
* Add custom cursor
* Dispatch logout init on 401 errors
* Allow CORS for real time connection
* Add more logs to RTS
* Fix construction of MongoClient
* WIP: Real time comments
* Enable comments
* Minor updates
* Read backend API base URL from environment
* Escape to reset comments mode
* Set popover position as auto and boundary as scroll parent
* Disable warning
* Added permissions for comment threads
* Add resolved API for comment threads
* Migration to set commenting permission on existing apps
* Fix updates bringing the RTS down
* Show view latest button, scroll to bottom on creating a new comment
* Cleanup comment reducer
* Move to typescript for RTS
* Add missing server.ts and tsconfig files
* Resolve / unresolve comment
* Scaffold app comments
* Minor fixes: comment on top of all widgets, add toggle button at viewer header
* Reconnect socket on creating a new app, set connected status in store
* Retry socket connection flow
* Integration tests for comments with api mocks using msw
* Fix circular depependency
* rm file
* Minor cleanup and comments
* Minor refactors: move isScrolledToBottom to common hooks, decouple prevent interactions overlay from comments wrapper
* Use policies when pushing updates in RTS
* ENV var to set if comments are enabled
* Fix: check if editor/viewer is initialised before waiting for init action
* Add tests for comments reducer
* Revert "ENV var to set if comments are enabled"
This reverts commit 988efeaa69d378d943a387e1e73510334958adc5.
* Enable comments for users with appsmith email
* lint
* fix
* Try running a socket.io server inside backend
* Update comment reducer tests
* Init mentions within comments
* Fix comment thread updates with email rooms
* Minor fixes
* Refactors / review suggestions
* lint
* increase cache limit for builds
* Comment out tests for feature that's under development
* Add Dockerfile for RTS
* Fix policies missing for first comment in threads
* Use draftJS for comments input with mentions support
* fix fixtures
* Use thread's policies when querying for threads
* Update socket.io to v4
* Add support for richer body with mentions
* Update comment body type to RawDraftContentState
* fix stale method
* Fix mentions search
* Minor cleanups
* Comment context menu and thread UI updates
* revert: Scaffold app comments
* Yarn dependencies
* Delete comment using id api added
* Init app comments
* Add test for creating thread
* Api for delete comment with id
* Test comment creation response and policies
* Copy comment links
* Fix reset editor state
* Delete valid comment testcase added
* Delete comment TC : code refactor
* Don't allow creating comments with an empty body
* Pin comments WIP[]
* Ignore dependency-reduced-pom.xml files from VCS
* Cleanup of some dev-only files, for review
* Delete comment
* Update socket.io to v4 in RTS
* Pin and resolve comment thread object added in commentThread
* Pin and resolve comment thread object added in commentThread
* Update comment thread API
* Added creationTime and updationTime in comment thread response
* Added creationTime and updationTime in comment thread response
* Added human readable id to comment threads, fallback to username for null name in user document
* Refactor
* lint
* fix test, rm duplicate selector
* comment out saga used for dev
* CommentThread viewed status, username fallback for getName=null, username field added in pin & resolve status
* lint
* trigger tests
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Abhijeet <abhi.nagarnaik@gmail.com>
2021-04-29 10:33:51 +00:00
|
|
|
export function* logoutSaga(action: ReduxAction<{ redirectURL: string }>) {
|
2020-01-03 08:49:47 +00:00
|
|
|
try {
|
Initialise comments (#3328)
* Initial scaffolding for comments CRUD APIs
* add actions
* add assets
* state management for existing comments and creating new
* add ui components
* add overlay comments wrapper to baseWidget
* add toggle comment mode button at editor header
* trigger tests
* Disallow commenting as someone else
* Add applicationId for comments
* lint
* Add overlay blacklist to prevent component interaction while adding comments
* Comment thread style updates
* Placeholder comment context menu
* Controlled comment thread visibility for making new comments visible by default
* Update comment type description
* Reset input on save
* Resolve comment thread button ui
* fix close on esc key, dont create new comment on outside click
* Submit on enter
* add emoji picker
* Attempt at adding a websocket server in Java
* CRUD APIs for comment threads
* Add API for getting all threads in application
* Move types to a separate file
* Initial commit for real time server (RTS)
* Add script to start RTS
* Fix position property
* Use create comment thread API
* Use add comment to thread API
* Add custom cursor
* Dispatch logout init on 401 errors
* Allow CORS for real time connection
* Add more logs to RTS
* Fix construction of MongoClient
* WIP: Real time comments
* Enable comments
* Minor updates
* Read backend API base URL from environment
* Escape to reset comments mode
* Set popover position as auto and boundary as scroll parent
* Disable warning
* Added permissions for comment threads
* Add resolved API for comment threads
* Migration to set commenting permission on existing apps
* Fix updates bringing the RTS down
* Show view latest button, scroll to bottom on creating a new comment
* Cleanup comment reducer
* Move to typescript for RTS
* Add missing server.ts and tsconfig files
* Resolve / unresolve comment
* Scaffold app comments
* Minor fixes: comment on top of all widgets, add toggle button at viewer header
* Reconnect socket on creating a new app, set connected status in store
* Retry socket connection flow
* Integration tests for comments with api mocks using msw
* Fix circular depependency
* rm file
* Minor cleanup and comments
* Minor refactors: move isScrolledToBottom to common hooks, decouple prevent interactions overlay from comments wrapper
* Use policies when pushing updates in RTS
* ENV var to set if comments are enabled
* Fix: check if editor/viewer is initialised before waiting for init action
* Add tests for comments reducer
* Revert "ENV var to set if comments are enabled"
This reverts commit 988efeaa69d378d943a387e1e73510334958adc5.
* Enable comments for users with appsmith email
* lint
* fix
* Try running a socket.io server inside backend
* Update comment reducer tests
* Init mentions within comments
* Fix comment thread updates with email rooms
* Minor fixes
* Refactors / review suggestions
* lint
* increase cache limit for builds
* Comment out tests for feature that's under development
* Add Dockerfile for RTS
* Fix policies missing for first comment in threads
* Use draftJS for comments input with mentions support
* fix fixtures
* Use thread's policies when querying for threads
* Update socket.io to v4
* Add support for richer body with mentions
* Update comment body type to RawDraftContentState
* fix stale method
* Fix mentions search
* Minor cleanups
* Comment context menu and thread UI updates
* revert: Scaffold app comments
* Yarn dependencies
* Delete comment using id api added
* Init app comments
* Add test for creating thread
* Api for delete comment with id
* Test comment creation response and policies
* Copy comment links
* Fix reset editor state
* Delete valid comment testcase added
* Delete comment TC : code refactor
* Don't allow creating comments with an empty body
* Pin comments WIP[]
* Ignore dependency-reduced-pom.xml files from VCS
* Cleanup of some dev-only files, for review
* Delete comment
* Update socket.io to v4 in RTS
* Pin and resolve comment thread object added in commentThread
* Pin and resolve comment thread object added in commentThread
* Update comment thread API
* Added creationTime and updationTime in comment thread response
* Added creationTime and updationTime in comment thread response
* Added human readable id to comment threads, fallback to username for null name in user document
* Refactor
* lint
* fix test, rm duplicate selector
* comment out saga used for dev
* CommentThread viewed status, username fallback for getName=null, username field added in pin & resolve status
* lint
* trigger tests
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Abhijeet <abhi.nagarnaik@gmail.com>
2021-04-29 10:33:51 +00:00
|
|
|
const redirectURL = action.payload?.redirectURL;
|
2020-01-03 08:49:47 +00:00
|
|
|
const response: ApiResponse = yield call(UserApi.logoutUser);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2020-01-03 08:49:47 +00:00
|
|
|
if (isValidResponse) {
|
2020-04-08 08:43:56 +00:00
|
|
|
AnalyticsUtil.reset();
|
2022-06-21 13:57:34 +00:00
|
|
|
const currentUser: User | undefined = yield select(getCurrentUser);
|
2021-09-12 16:36:43 +00:00
|
|
|
yield put(logoutUserSuccess(!!currentUser?.emptyInstance));
|
2021-03-24 05:09:47 +00:00
|
|
|
localStorage.clear();
|
Initialise comments (#3328)
* Initial scaffolding for comments CRUD APIs
* add actions
* add assets
* state management for existing comments and creating new
* add ui components
* add overlay comments wrapper to baseWidget
* add toggle comment mode button at editor header
* trigger tests
* Disallow commenting as someone else
* Add applicationId for comments
* lint
* Add overlay blacklist to prevent component interaction while adding comments
* Comment thread style updates
* Placeholder comment context menu
* Controlled comment thread visibility for making new comments visible by default
* Update comment type description
* Reset input on save
* Resolve comment thread button ui
* fix close on esc key, dont create new comment on outside click
* Submit on enter
* add emoji picker
* Attempt at adding a websocket server in Java
* CRUD APIs for comment threads
* Add API for getting all threads in application
* Move types to a separate file
* Initial commit for real time server (RTS)
* Add script to start RTS
* Fix position property
* Use create comment thread API
* Use add comment to thread API
* Add custom cursor
* Dispatch logout init on 401 errors
* Allow CORS for real time connection
* Add more logs to RTS
* Fix construction of MongoClient
* WIP: Real time comments
* Enable comments
* Minor updates
* Read backend API base URL from environment
* Escape to reset comments mode
* Set popover position as auto and boundary as scroll parent
* Disable warning
* Added permissions for comment threads
* Add resolved API for comment threads
* Migration to set commenting permission on existing apps
* Fix updates bringing the RTS down
* Show view latest button, scroll to bottom on creating a new comment
* Cleanup comment reducer
* Move to typescript for RTS
* Add missing server.ts and tsconfig files
* Resolve / unresolve comment
* Scaffold app comments
* Minor fixes: comment on top of all widgets, add toggle button at viewer header
* Reconnect socket on creating a new app, set connected status in store
* Retry socket connection flow
* Integration tests for comments with api mocks using msw
* Fix circular depependency
* rm file
* Minor cleanup and comments
* Minor refactors: move isScrolledToBottom to common hooks, decouple prevent interactions overlay from comments wrapper
* Use policies when pushing updates in RTS
* ENV var to set if comments are enabled
* Fix: check if editor/viewer is initialised before waiting for init action
* Add tests for comments reducer
* Revert "ENV var to set if comments are enabled"
This reverts commit 988efeaa69d378d943a387e1e73510334958adc5.
* Enable comments for users with appsmith email
* lint
* fix
* Try running a socket.io server inside backend
* Update comment reducer tests
* Init mentions within comments
* Fix comment thread updates with email rooms
* Minor fixes
* Refactors / review suggestions
* lint
* increase cache limit for builds
* Comment out tests for feature that's under development
* Add Dockerfile for RTS
* Fix policies missing for first comment in threads
* Use draftJS for comments input with mentions support
* fix fixtures
* Use thread's policies when querying for threads
* Update socket.io to v4
* Add support for richer body with mentions
* Update comment body type to RawDraftContentState
* fix stale method
* Fix mentions search
* Minor cleanups
* Comment context menu and thread UI updates
* revert: Scaffold app comments
* Yarn dependencies
* Delete comment using id api added
* Init app comments
* Add test for creating thread
* Api for delete comment with id
* Test comment creation response and policies
* Copy comment links
* Fix reset editor state
* Delete valid comment testcase added
* Delete comment TC : code refactor
* Don't allow creating comments with an empty body
* Pin comments WIP[]
* Ignore dependency-reduced-pom.xml files from VCS
* Cleanup of some dev-only files, for review
* Delete comment
* Update socket.io to v4 in RTS
* Pin and resolve comment thread object added in commentThread
* Pin and resolve comment thread object added in commentThread
* Update comment thread API
* Added creationTime and updationTime in comment thread response
* Added creationTime and updationTime in comment thread response
* Added human readable id to comment threads, fallback to username for null name in user document
* Refactor
* lint
* fix test, rm duplicate selector
* comment out saga used for dev
* CommentThread viewed status, username fallback for getName=null, username field added in pin & resolve status
* lint
* trigger tests
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Abhijeet <abhi.nagarnaik@gmail.com>
2021-04-29 10:33:51 +00:00
|
|
|
yield put(flushErrorsAndRedirect(redirectURL || AUTH_LOGIN_URL));
|
2020-01-03 08:49:47 +00:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2020-01-03 08:49:47 +00:00
|
|
|
yield put(logoutUserError(error));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 12:03:08 +00:00
|
|
|
export function* waitForFetchUserSuccess() {
|
2022-06-21 13:57:34 +00:00
|
|
|
const currentUser: string | undefined = yield select(getCurrentUser);
|
2021-05-20 12:03:08 +00:00
|
|
|
if (!currentUser) {
|
|
|
|
|
yield take(ReduxActionTypes.FETCH_USER_DETAILS_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-02 05:56:41 +00:00
|
|
|
function* removePhoto(action: ReduxAction<{ callback: (id: string) => void }>) {
|
2021-05-20 12:03:08 +00:00
|
|
|
try {
|
2021-12-02 05:56:41 +00:00
|
|
|
const response: ApiResponse = yield call(UserApi.deletePhoto);
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2021-12-02 05:56:41 +00:00
|
|
|
const photoId = response.data?.profilePhotoAssetId; //get updated photo id of iploaded image
|
|
|
|
|
if (action.payload.callback) action.payload.callback(photoId);
|
2021-05-20 12:03:08 +00:00
|
|
|
} catch (error) {
|
|
|
|
|
log.error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function* updatePhoto(
|
2021-12-02 05:56:41 +00:00
|
|
|
action: ReduxAction<{ file: File; callback: (id: string) => void }>,
|
2021-05-20 12:03:08 +00:00
|
|
|
) {
|
|
|
|
|
try {
|
2021-12-02 05:56:41 +00:00
|
|
|
const response: ApiResponse = yield call(UserApi.uploadPhoto, {
|
|
|
|
|
file: action.payload.file,
|
|
|
|
|
});
|
2022-06-21 13:57:34 +00:00
|
|
|
//@ts-expect-error: response is of type unknown
|
2021-12-02 05:56:41 +00:00
|
|
|
const photoId = response.data?.profilePhotoAssetId; //get updated photo id of iploaded image
|
|
|
|
|
if (action.payload.callback) action.payload.callback(photoId);
|
2021-05-20 12:03:08 +00:00
|
|
|
} catch (error) {
|
|
|
|
|
log.error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-05 06:10:19 +00:00
|
|
|
function* fetchFeatureFlags() {
|
|
|
|
|
try {
|
|
|
|
|
const response: ApiResponse = yield call(UserApi.fetchFeatureFlags);
|
|
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
|
|
|
|
if (isValidResponse) {
|
2022-06-21 13:57:34 +00:00
|
|
|
// @ts-expect-error: response.data is of type unknown
|
2022-04-07 17:57:32 +00:00
|
|
|
yield put(fetchFeatureFlagsSuccess(response.data));
|
2021-08-05 06:10:19 +00:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
log.error(error);
|
|
|
|
|
yield put(fetchFeatureFlagsError(error));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 07:22:51 +00:00
|
|
|
function* updateFirstTimeUserOnboardingSage() {
|
2022-06-21 13:57:34 +00:00
|
|
|
const enable: string | null = yield getEnableFirstTimeUserOnboarding();
|
2021-09-13 07:22:51 +00:00
|
|
|
|
|
|
|
|
if (enable) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const applicationId: string = yield getFirstTimeUserOnboardingApplicationId() ||
|
|
|
|
|
"";
|
|
|
|
|
const introModalVisibility:
|
|
|
|
|
| string
|
|
|
|
|
| null = yield getFirstTimeUserOnboardingIntroModalVisibility();
|
2021-09-13 07:22:51 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.SET_ENABLE_FIRST_TIME_USER_ONBOARDING,
|
|
|
|
|
payload: true,
|
|
|
|
|
});
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.SET_FIRST_TIME_USER_ONBOARDING_APPLICATION_ID,
|
|
|
|
|
payload: applicationId,
|
|
|
|
|
});
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.SET_SHOW_FIRST_TIME_USER_ONBOARDING_MODAL,
|
|
|
|
|
payload: introModalVisibility,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-01 16:25:55 +00:00
|
|
|
export function* updateUsersCommentsOnboardingState(
|
|
|
|
|
action: ReduxAction<CommentsOnboardingState>,
|
|
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
yield call(UserApi.updateUsersCommentOnboardingState, {
|
|
|
|
|
commentOnboardingState: action.payload,
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
log.error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-16 08:49:10 +00:00
|
|
|
export default function* userSagas() {
|
|
|
|
|
yield all([
|
|
|
|
|
takeLatest(ReduxActionTypes.CREATE_USER_INIT, createUserSaga),
|
2020-07-08 10:14:03 +00:00
|
|
|
takeLatest(ReduxActionTypes.FETCH_USER_INIT, getCurrentUserSaga),
|
2019-12-16 08:49:10 +00:00
|
|
|
takeLatest(ReduxActionTypes.FORGOT_PASSWORD_INIT, forgotPasswordSaga),
|
|
|
|
|
takeLatest(ReduxActionTypes.RESET_USER_PASSWORD_INIT, resetPasswordSaga),
|
|
|
|
|
takeLatest(
|
|
|
|
|
ReduxActionTypes.RESET_PASSWORD_VERIFY_TOKEN_INIT,
|
|
|
|
|
verifyResetPasswordTokenSaga,
|
|
|
|
|
),
|
2022-06-15 15:37:41 +00:00
|
|
|
takeLatest(ReduxActionTypes.INVITE_USERS_TO_WORKSPACE_INIT, inviteUsers),
|
2020-01-03 08:49:47 +00:00
|
|
|
takeLatest(ReduxActionTypes.LOGOUT_USER_INIT, logoutSaga),
|
2020-01-06 09:07:30 +00:00
|
|
|
takeLatest(ReduxActionTypes.VERIFY_INVITE_INIT, verifyUserInviteSaga),
|
|
|
|
|
takeLatest(
|
|
|
|
|
ReduxActionTypes.INVITED_USER_SIGNUP_INIT,
|
|
|
|
|
invitedUserSignupSaga,
|
|
|
|
|
),
|
2021-03-04 09:37:02 +00:00
|
|
|
takeLatest(
|
|
|
|
|
ReduxActionTypes.UPDATE_USER_DETAILS_INIT,
|
|
|
|
|
updateUserDetailsSaga,
|
|
|
|
|
),
|
2021-05-20 12:03:08 +00:00
|
|
|
takeLatest(ReduxActionTypes.REMOVE_PROFILE_PHOTO, removePhoto),
|
|
|
|
|
takeLatest(ReduxActionTypes.UPLOAD_PROFILE_PHOTO, updatePhoto),
|
2022-06-15 15:37:41 +00:00
|
|
|
takeLatest(ReduxActionTypes.LEAVE_WORKSPACE_INIT, leaveWorkspaceSaga),
|
2021-08-05 06:10:19 +00:00
|
|
|
takeLatest(ReduxActionTypes.FETCH_FEATURE_FLAGS_INIT, fetchFeatureFlags),
|
2021-09-13 07:22:51 +00:00
|
|
|
takeLatest(
|
|
|
|
|
ReduxActionTypes.FETCH_USER_DETAILS_SUCCESS,
|
|
|
|
|
updateFirstTimeUserOnboardingSage,
|
|
|
|
|
),
|
2021-10-01 16:25:55 +00:00
|
|
|
takeLatest(
|
|
|
|
|
ReduxActionTypes.UPDATE_USERS_COMMENTS_ONBOARDING_STATE,
|
|
|
|
|
updateUsersCommentsOnboardingState,
|
|
|
|
|
),
|
2019-12-16 08:49:10 +00:00
|
|
|
]);
|
|
|
|
|
}
|
2021-06-02 09:56:22 +00:00
|
|
|
|
2022-06-15 15:37:41 +00:00
|
|
|
export function* leaveWorkspaceSaga(
|
|
|
|
|
action: ReduxAction<LeaveWorkspaceRequest>,
|
|
|
|
|
) {
|
2021-06-02 09:56:22 +00:00
|
|
|
try {
|
2022-06-15 15:37:41 +00:00
|
|
|
const request: LeaveWorkspaceRequest = action.payload;
|
|
|
|
|
const response: ApiResponse = yield call(UserApi.leaveWorkspace, request);
|
2022-06-21 13:57:34 +00:00
|
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
2021-06-02 09:56:22 +00:00
|
|
|
if (isValidResponse) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.GET_ALL_APPLICATION_INIT,
|
|
|
|
|
});
|
|
|
|
|
Toaster.show({
|
2022-07-20 11:54:16 +00:00
|
|
|
text: `You have successfully left the workspace`,
|
2021-06-02 09:56:22 +00:00
|
|
|
variant: Variant.success,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// do nothing as it's already handled globally
|
|
|
|
|
}
|
|
|
|
|
}
|