This commit is contained in:
rustmailer
2026-05-14 22:11:10 +08:00
parent 907e59027d
commit 3fa4fe453c
24 changed files with 83 additions and 9 deletions
@@ -114,6 +114,7 @@ export type Account = {
folder_limit?: number;
download_interval_min: number;
download_batch_size: number;
auto_download_new_mailboxes: boolean;
};
const getAccountSchema = (isEdit: boolean, t: (key: string) => string) =>
@@ -138,6 +139,7 @@ const getAccountSchema = (isEdit: boolean, t: (key: string) => string) =>
.int()
.min(10, { message: t('validation.singleRequestBatchSizeTooSmall') })
.max(200, { message: t('validation.singleRequestBatchSizeTooLarge') }),
auto_download_new_mailboxes: z.boolean(),
});
type Step = {
@@ -151,7 +153,7 @@ export type Steps = [...Step[]];
const getSteps = (t: (key: string) => string): Steps => [
{ id: "step-1", name: t('accounts.steps.emailAddress'), fields: ["email", "account_name"] },
{ id: "step-2", name: t('accounts.steps.imap'), fields: ["imap", "use_dangerous", "login_name"] },
{ id: "step-3", name: t('accounts.steps.syncPreferences'), fields: ["enabled", "date_since", "date_before", "folder_limit", "download_interval_min", "download_batch_size"] },
{ id: "step-3", name: t('accounts.steps.syncPreferences'), fields: ["enabled", "date_since", "date_before", "folder_limit", "download_interval_min", "download_batch_size", "auto_download_new_mailboxes"] },
{ id: "step-4", name: t('accounts.steps.summary'), fields: [] },
];
@@ -184,6 +186,7 @@ const defaultValues: Account = {
folder_limit: undefined,
download_interval_min: 60,
download_batch_size: 30,
auto_download_new_mailboxes: true,
};
const emptyImap: ImapConfig = {
@@ -212,6 +215,7 @@ const mapCurrentRowToFormValues = (currentRow: AccountModel): Account => {
folder_limit: currentRow.folder_limit ?? undefined,
download_interval_min: currentRow.download_interval_min ?? 60,
download_batch_size: currentRow.download_batch_size ?? 30,
auto_download_new_mailboxes: currentRow.auto_download_new_mailboxes ?? true,
};
};
@@ -293,6 +297,7 @@ export function AccountActionDialog({ currentRow, open, onOpenChange }: Props) {
folder_limit: data.folder_limit,
download_interval_min: data.download_interval_min,
download_batch_size: data.download_batch_size,
auto_download_new_mailboxes: data.auto_download_new_mailboxes,
};
if (isEdit) {
const isAllMode = !data.date_since && !data.date_before;
@@ -232,6 +232,24 @@ export default function Step3() {
<hr className="my-4" />
<FormField
control={control}
name="auto_download_new_mailboxes"
render={({ field }) => (
<FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4 shadow-sm">
<FormControl>
<Checkbox checked={field.value} onCheckedChange={field.onChange} />
</FormControl>
<div className="space-y-1 leading-none">
<FormLabel>{t('accounts.autoDownloadNewMailboxes')}</FormLabel>
<FormDescription>{t('accounts.autoDownloadNewMailboxesDescription')}</FormDescription>
</div>
</FormItem>
)}
/>
<hr className="my-4" />
<FormField
control={control}
name="folder_limit"
@@ -168,6 +168,11 @@ export default function Step4() {
<AccordionTrigger className="font-medium capitalize text-gray-600">{t('accounts.downloadBatchSize')}:</AccordionTrigger>
<AccordionContent>{summaryData.download_batch_size}</AccordionContent>
</AccordionItem>
<AccordionItem key="auto_download_new_mailboxes" value="auto_download_new_mailboxes">
<AccordionTrigger className="font-medium capitalize text-gray-600">{t('accounts.autoDownloadNewMailboxes')}:</AccordionTrigger>
<AccordionContent>{summaryData.auto_download_new_mailboxes ? t('common.yes') : t('common.no')}</AccordionContent>
</AccordionItem>
</Accordion>
</div>
);