Release v0.1.3
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
||||
import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
||||
import { asArray, asRecord, isAuditLockedVersion } from "./utils/campaignView";
|
||||
import { getBool, getNumber, getText } from "./utils/draftEditor";
|
||||
import { cloneJson, getBool, getNumber, getText } from "./utils/draftEditor";
|
||||
import { campaignMailSettingsPolicyState } from "./policyUi";
|
||||
|
||||
const securityOptions = mailServerSecurityOptions as readonly MailSecurity[];
|
||||
@@ -70,7 +70,8 @@ export default function MailSettingsPage({ settings, campaignId, view = "setting
|
||||
unsavedTitle: isPolicyView ? "Unsaved mail policy changes" : "Unsaved mail settings",
|
||||
unsavedMessage: isPolicyView
|
||||
? "Mail policy changes have unsaved draft changes. Save them before leaving, or discard them and continue."
|
||||
: "Mail settings have unsaved changes. Save them before leaving, or discard them and continue."
|
||||
: "Mail settings have unsaved changes. Save them before leaving, or discard them and continue.",
|
||||
transformDraftBeforeSave: normalizeMailSettingsBeforeSave
|
||||
});
|
||||
const server = asRecord(displayDraft.server);
|
||||
const smtp = asRecord(server.smtp);
|
||||
@@ -165,6 +166,37 @@ export default function MailSettingsPage({ settings, campaignId, view = "setting
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeMailSettingsBeforeSave(value: Record<string, unknown>): Record<string, unknown> {
|
||||
if (mailModuleInstalled === false) return value;
|
||||
const next = cloneJson(value);
|
||||
const nextServer = { ...asRecord(next.server) };
|
||||
const profileId = getText(nextServer, "mail_profile_id");
|
||||
if (profileId.length === 0) return next;
|
||||
|
||||
const nextCredentials = { ...asRecord(nextServer.credentials) };
|
||||
normalizeProfileCredentialProtocol(nextServer, nextCredentials, "smtp", effectiveMailPolicy?.smtp_credentials?.inherit === false ? false : true);
|
||||
normalizeProfileCredentialProtocol(nextServer, nextCredentials, "imap", effectiveMailPolicy?.imap_credentials?.inherit === false ? false : true);
|
||||
nextServer.credentials = nextCredentials;
|
||||
next.server = nextServer;
|
||||
return next;
|
||||
}
|
||||
|
||||
function normalizeProfileCredentialProtocol(
|
||||
serverValue: Record<string, unknown>,
|
||||
credentialsValue: Record<string, unknown>,
|
||||
protocol: "smtp" | "imap",
|
||||
inherit: boolean
|
||||
) {
|
||||
serverValue["inherit_" + protocol + "_credentials"] = inherit;
|
||||
if (inherit === false) return;
|
||||
|
||||
const transport = { ...asRecord(serverValue[protocol]) };
|
||||
delete transport.username;
|
||||
delete transport.password;
|
||||
serverValue[protocol] = transport;
|
||||
credentialsValue[protocol] = {};
|
||||
}
|
||||
|
||||
function selectMailProfile(profileId: string) {
|
||||
if (!mailModuleInstalled || locked) return;
|
||||
if (!profileId && !campaignProfilesAllowed) {
|
||||
|
||||
Reference in New Issue
Block a user