From e6136b0d7ef5d2a50726e77d9132e4e049eb7338 Mon Sep 17 00:00:00 2001 From: jenny-s51 Date: Tue, 22 Jun 2021 10:17:45 -0400 Subject: [PATCH] disable test connection button if form fields not entered --- src/realm-settings/EmailTab.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/realm-settings/EmailTab.tsx b/src/realm-settings/EmailTab.tsx index 120d04ea3f..6658078768 100644 --- a/src/realm-settings/EmailTab.tsx +++ b/src/realm-settings/EmailTab.tsx @@ -6,6 +6,7 @@ import { AlertVariant, Button, Checkbox, + formatBreakpointMods, FormGroup, PageSection, Switch, @@ -51,12 +52,15 @@ export const RealmSettingsEmailTab = ({ control, handleSubmit, errors, + watch, setValue, reset: resetForm, getValues, } = useForm(); const userForm = useForm({ mode: "onChange" }); + const watchFromValue = watch("smtpServer.from", ""); + const watchHostValue = watch("smtpServer.host", ""); useEffect(() => { reset(); @@ -402,6 +406,9 @@ export const RealmSettingsEmailTab = ({ variant="secondary" onClick={() => saveAndTestEmail()} data-testid="test-connection-button" + isDisabled={ + !(emailRegexPattern.test(watchFromValue) && watchHostValue) + } > {t("realm-settings:testConnection")}