Implement PR Comments
This commit is contained in:
1 parent
de3d38d891
commit
38a1d5e7a1
7 files changed
+96
-49
No files matched your search
@@ -26,6 +26,21 @@ const SettingsEmail = ({
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
|
||||
// Destructure settings with default values
|
||||
const {
|
||||
systemEmailHost = "",
|
||||
systemEmailPort = "",
|
||||
systemEmailSecure = false,
|
||||
systemEmailPool = false,
|
||||
systemEmailUser = "",
|
||||
systemEmailAddress = "",
|
||||
systemEmailPassword = "",
|
||||
systemEmailTLSServername = "",
|
||||
systemEmailConnectionHost = "localhost",
|
||||
systemEmailIgnoreTLS = false,
|
||||
systemEmailRequireTLS = false,
|
||||
systemEmailRejectUnauthorized = true,
|
||||
} = settingsData?.settings || {};
|
||||
// Local state
|
||||
const [password, setPassword] = useState("");
|
||||
const [hasBeenReset, setHasBeenReset] = useState(false);
|
||||
@@ -48,25 +63,31 @@ const SettingsEmail = ({
|
||||
const handleSendTestEmail = () => {
|
||||
// Collect current form values
|
||||
const emailConfig = {
|
||||
systemEmailHost: settingsData?.settings?.systemEmailHost,
|
||||
systemEmailPort: settingsData?.settings?.systemEmailPort,
|
||||
systemEmailSecure: settingsData?.settings?.systemEmailSecure,
|
||||
systemEmailPool: settingsData?.settings?.systemEmailPool,
|
||||
systemEmailUser: settingsData?.settings?.systemEmailUser,
|
||||
systemEmailAddress: settingsData?.settings?.systemEmailAddress,
|
||||
systemEmailPassword: password || settingsData?.settings?.systemEmailPassword,
|
||||
systemEmailConnectionHost: settingsData?.settings?.systemEmailConnectionHost,
|
||||
systemEmailTLSServername: settingsData?.settings?.systemEmailTLSServername,
|
||||
systemEmailIgnoreTLS: settingsData?.settings?.systemEmailIgnoreTLS,
|
||||
systemEmailRequireTLS: settingsData?.settings?.systemEmailRequireTLS,
|
||||
systemEmailRejectUnauthorized:
|
||||
settingsData?.settings?.systemEmailRejectUnauthorized,
|
||||
systemEmailHost,
|
||||
systemEmailPort,
|
||||
systemEmailSecure,
|
||||
systemEmailPool,
|
||||
systemEmailUser,
|
||||
systemEmailAddress,
|
||||
systemEmailPassword: password || systemEmailPassword,
|
||||
systemEmailTLSServername,
|
||||
systemEmailConnectionHost,
|
||||
systemEmailIgnoreTLS,
|
||||
systemEmailRequireTLS,
|
||||
systemEmailRejectUnauthorized,
|
||||
};
|
||||
|
||||
// Basic validation
|
||||
if (!emailConfig.systemEmailHost || !emailConfig.systemEmailPort) {
|
||||
if (
|
||||
!emailConfig.systemEmailHost ||
|
||||
!emailConfig.systemEmailPort ||
|
||||
!emailConfig.systemEmailAddress
|
||||
) {
|
||||
createToast({
|
||||
body: t("settingsEmailRequiredFields", "Email host and port are required"),
|
||||
body: t(
|
||||
"settingsEmailRequiredFields",
|
||||
"Email address, host and port are required"
|
||||
),
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
@@ -98,7 +119,7 @@ const SettingsEmail = ({
|
||||
<TextInput
|
||||
name="systemEmailHost"
|
||||
placeholder="smtp.gmail.com"
|
||||
value={settingsData?.settings?.systemEmailHost ?? ""}
|
||||
value={systemEmailHost}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
@@ -108,7 +129,7 @@ const SettingsEmail = ({
|
||||
name="systemEmailPort"
|
||||
placeholder="425"
|
||||
type="number"
|
||||
value={settingsData?.settings?.systemEmailPort ?? ""}
|
||||
value={systemEmailPort}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
@@ -123,13 +144,13 @@ const SettingsEmail = ({
|
||||
<Typography>{t("settingsEmailSecure")}</Typography>
|
||||
<Switch
|
||||
name="systemEmailSecure"
|
||||
checked={settingsData?.settings?.systemEmailSecure ?? false}
|
||||
checked={systemEmailSecure}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<Typography>{t("settingsEmailPool")}</Typography>
|
||||
<Switch
|
||||
name="systemEmailPool"
|
||||
checked={settingsData?.settings?.systemEmailPool ?? false}
|
||||
checked={systemEmailPool}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
@@ -138,7 +159,7 @@ const SettingsEmail = ({
|
||||
<TextInput
|
||||
name="systemEmailUser"
|
||||
placeholder="Leave empty if not required"
|
||||
value={settingsData?.settings?.systemEmailUser ?? ""}
|
||||
value={systemEmailUser}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
@@ -147,7 +168,7 @@ const SettingsEmail = ({
|
||||
<TextInput
|
||||
name="systemEmailAddress"
|
||||
placeholder="uptime@bluewavelabs.ca"
|
||||
value={settingsData?.settings?.systemEmailAddress ?? ""}
|
||||
value={systemEmailAddress}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
@@ -189,34 +210,33 @@ const SettingsEmail = ({
|
||||
<TextInput
|
||||
name="systemEmailTLSServername"
|
||||
placeholder="bluewavelabs.ca"
|
||||
value={settingsData?.settings?.systemEmailTLSServername ?? ""}
|
||||
value={systemEmailTLSServername}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
flexDirection: "column",
|
||||
gap: theme.spacing(4),
|
||||
}}
|
||||
>
|
||||
<Typography>{t("settingsEmailIgnoreTLS")}</Typography>
|
||||
<Switch
|
||||
name="systemEmailIgnoreTLS"
|
||||
checked={settingsData?.settings?.systemEmailIgnoreTLS ?? false}
|
||||
checked={systemEmailIgnoreTLS}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<Typography>{t("settingsEmailRequireTLS")}</Typography>
|
||||
<Switch
|
||||
name="systemEmailRequireTLS"
|
||||
checked={settingsData?.settings?.systemEmailRequireTLS ?? false}
|
||||
checked={systemEmailRequireTLS}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<Typography>{t("settingsEmailRejectUnauthorized")}</Typography>
|
||||
<Switch
|
||||
name="systemEmailRejectUnauthorized"
|
||||
checked={settingsData?.settings?.systemEmailRejectUnauthorized ?? false}
|
||||
checked={systemEmailRejectUnauthorized}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
@@ -225,7 +245,7 @@ const SettingsEmail = ({
|
||||
<TextInput
|
||||
name="systemEmailConnectionHost"
|
||||
placeholder="bluewavelabs.ca"
|
||||
value={settingsData?.settings?.systemEmailConnectionHost ?? ""}
|
||||
value={systemEmailConnectionHost}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
Reference in new issue
Block a user