feat: Provide option to send test email to test out email configurati… (#8992)
This commit is contained in:
parent
dbbb7b84b2
commit
41bf761a58
|
|
@ -94,6 +94,7 @@ class UserApi extends Api {
|
|||
static adminSettingsURL = "v1/admin/env";
|
||||
static restartServerURL = "v1/admin/restart";
|
||||
static downloadConfigURL = "v1/admin/env/download";
|
||||
static sendTestEmailURL = "/v1/admin/send-test-email";
|
||||
|
||||
static createUser(
|
||||
request: CreateUserRequest,
|
||||
|
|
@ -205,6 +206,10 @@ class UserApi extends Api {
|
|||
static restartServer(): AxiosPromise<ApiResponse> {
|
||||
return Api.post(UserApi.restartServerURL);
|
||||
}
|
||||
|
||||
static sendTestEmail(): AxiosPromise<ApiResponse> {
|
||||
return Api.post(UserApi.sendTestEmailURL);
|
||||
}
|
||||
}
|
||||
|
||||
export default UserApi;
|
||||
|
|
|
|||
|
|
@ -624,6 +624,7 @@ export const ReduxActionTypes = {
|
|||
UPDATE_JS_ACTION_BODY: "UPDATE_JS_ACTION_BODY",
|
||||
UPDATE_JS_ACTION_BODY_INIT: "UPDATE_JS_ACTION_BODY_INIT",
|
||||
UPDATE_JS_ACTION_BODY_SUCCESS: "UPDATE_JS_ACTION_BODY_SUCCESS",
|
||||
SEND_TEST_EMAIL: "SEND_TEST_EMAIL",
|
||||
};
|
||||
|
||||
export type ReduxActionType = typeof ReduxActionTypes[keyof typeof ReduxActionTypes];
|
||||
|
|
|
|||
|
|
@ -806,6 +806,10 @@ export const RESTART_ERROR_BODY = () =>
|
|||
export const RESTART_ERROR_HEADER = () => "Restart failed";
|
||||
export const INFO_VERSION_MISMATCH_FOUND_RELOAD_REQUEST = () =>
|
||||
"Hey! There is a new version of Appsmith available. Please consider refreshing your window.";
|
||||
export const TEST_EMAIL_SUCCESS = (email: string) => () =>
|
||||
`Test email sent, please check the inbox of ${email}`;
|
||||
export const TEST_EMAIL_SUCCESS_TROUBLESHOOT = () => "Troubleshoot";
|
||||
export const TEST_EMAIL_FAILURE = () => "Sending Test Email Failed";
|
||||
|
||||
export const WELCOME_FORM_NON_SUPER_USER_ROLE_DROPDOWN = () =>
|
||||
"Tell us more about what you do at work?";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export type User = {
|
|||
isSuperUser: boolean;
|
||||
role?: string;
|
||||
useCase?: string;
|
||||
isConfigurable: boolean;
|
||||
};
|
||||
|
||||
export interface UserApplication {
|
||||
|
|
@ -37,6 +38,7 @@ export const DefaultCurrentUserDetails: User = {
|
|||
username: ANONYMOUS_USERNAME,
|
||||
gender: "MALE",
|
||||
isSuperUser: false,
|
||||
isConfigurable: false,
|
||||
};
|
||||
|
||||
// TODO keeping it here instead of the USER_API since it leads to cyclic deps errors during tests
|
||||
|
|
|
|||
|
|
@ -193,6 +193,24 @@ SettingsFactory.register("APPSMITH_MAIL_PASSWORD", {
|
|||
},
|
||||
});
|
||||
|
||||
SettingsFactory.register("APPSMITH_MAIL_TEST_EMAIL", {
|
||||
action: (dispatch) => {
|
||||
dispatch &&
|
||||
dispatch({
|
||||
type: ReduxActionTypes.SEND_TEST_EMAIL,
|
||||
payload: true,
|
||||
});
|
||||
},
|
||||
category: "email",
|
||||
controlType: SettingTypes.BUTTON,
|
||||
isVisible: (values: Record<string, any>) => {
|
||||
return (
|
||||
values && values["APPSMITH_MAIL_HOST"] && values["APPSMITH_MAIL_FROM"]
|
||||
);
|
||||
},
|
||||
text: "Send Test Email",
|
||||
});
|
||||
|
||||
//General
|
||||
SettingsFactory.register("APPSMITH_INSTANCE_NAME", {
|
||||
category: "general",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default function WithSuperUserHOC(
|
|||
return function Wrapped(props: RouteComponentProps) {
|
||||
const user = useSelector(getCurrentUser);
|
||||
|
||||
if (!user?.isSuperUser) {
|
||||
if (!user?.isSuperUser || !user?.isConfigurable) {
|
||||
return <Redirect to={APPLICATIONS_URL} />;
|
||||
}
|
||||
return <Component {...props} />;
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export default function ProfileDropdown(props: TagProps) {
|
|||
}}
|
||||
text="Edit Profile"
|
||||
/>
|
||||
{user?.isSuperUser && isAdminSettingsEnabled && (
|
||||
{user?.isSuperUser && user?.isConfigurable && isAdminSettingsEnabled && (
|
||||
<StyledMenuItem
|
||||
className={`t--settings ${BlueprintClasses.POPOVER_DISMISS}`}
|
||||
icon="setting"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import React from "react";
|
||||
import UserApi from "api/UserApi";
|
||||
import { Variant } from "components/ads/common";
|
||||
import { Toaster } from "components/ads/Toast";
|
||||
|
|
@ -8,12 +9,20 @@ import {
|
|||
} from "constants/ReduxActionConstants";
|
||||
import { APPLICATIONS_URL } from "constants/routes";
|
||||
import { User } from "constants/userConstants";
|
||||
import { takeLatest, all, call, put, delay } from "redux-saga/effects";
|
||||
import { takeLatest, all, call, put, delay, select } from "redux-saga/effects";
|
||||
import history from "utils/history";
|
||||
import { validateResponse } from "./ErrorSagas";
|
||||
import { getAppsmithConfigs } from "configs";
|
||||
|
||||
import { ApiResponse } from "api/ApiResponses";
|
||||
import {
|
||||
createMessage,
|
||||
TEST_EMAIL_FAILURE,
|
||||
TEST_EMAIL_SUCCESS,
|
||||
TEST_EMAIL_SUCCESS_TROUBLESHOOT,
|
||||
} from "constants/messages";
|
||||
import { getCurrentUser } from "selectors/usersSelectors";
|
||||
import { EMAIL_SETUP_DOC } from "constants/ThirdPartyConstants";
|
||||
|
||||
function* FetchAdminSettingsSaga() {
|
||||
const response = yield call(UserApi.fetchAdminSettings);
|
||||
|
|
@ -91,6 +100,40 @@ function* RestartServerPoll() {
|
|||
});
|
||||
}
|
||||
|
||||
function* SendTestEmail() {
|
||||
try {
|
||||
const response = yield call(UserApi.sendTestEmail);
|
||||
const currentUser = yield select(getCurrentUser);
|
||||
let actionElement;
|
||||
if (response.data) {
|
||||
actionElement = (
|
||||
<>
|
||||
<br />
|
||||
<span onClick={() => window.open(EMAIL_SETUP_DOC, "blank")}>
|
||||
{createMessage(TEST_EMAIL_SUCCESS_TROUBLESHOOT)}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Toaster.show({
|
||||
actionElement,
|
||||
text: createMessage(
|
||||
response.data
|
||||
? TEST_EMAIL_SUCCESS(currentUser?.email)
|
||||
: TEST_EMAIL_FAILURE,
|
||||
),
|
||||
hideProgressBar: true,
|
||||
variant: response.data ? Variant.info : Variant.danger,
|
||||
});
|
||||
} catch (e) {
|
||||
Toaster.show({
|
||||
text: createMessage(TEST_EMAIL_FAILURE),
|
||||
hideProgressBar: true,
|
||||
variant: Variant.danger,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function* InitSuperUserSaga(action: ReduxAction<User>) {
|
||||
const user = action.payload;
|
||||
if (user.isSuperUser) {
|
||||
|
|
@ -102,6 +145,7 @@ function* InitSuperUserSaga(action: ReduxAction<User>) {
|
|||
),
|
||||
takeLatest(ReduxActionTypes.SAVE_ADMIN_SETTINGS, SaveAdminSettingsSaga),
|
||||
takeLatest(ReduxActionTypes.RESTART_SERVER_POLL, RestartServerPoll),
|
||||
takeLatest(ReduxActionTypes.SEND_TEST_EMAIL, SendTestEmail),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user