Repository Public
1// SP Mail Next — éditeur d'une règle après livraison : constructeur de conditions et d'actions (tout ce que le serveur valide), portée, essai à blanc sur un message.2import { useEffect, useId, useRef, useState } from "react"3import { fmtListDate, t } from "../../i18n"4import { isAbort, toNextError } from "../../next/api"5import {6 ACTION_TYPES, CATEGORIES, EXTRACT_TYPES, FIELDS, FIELD_OPS, TONES, UNTIL_PRESETS, actionLabel, actionNeedsAi, actionSummary, categoryLabel, conditionSummary, fieldLabel, formToRule, issueText, newAction, newCondition,7 opLabel, recentMessages, setConditionField, testRule, toneLabel, type ActionForm, type ActionType, type CondForm, type ExtractType, type Field, type FormIssue, type LabelRef, type Op, type RuleForm, type RuleInput, type RuleTestResult,8 type SizeUnit, type SnippetRef, type SummaryContext, type Tone, type UntilKind,9} from "../../next/rules"10import type { MessageSummary } from "../../next/types"11import { S } from "../../state/app"12import { useStore } from "../../state/store"13import { Dialog, Field as FormField, Icon, IconButton, Spinner } from "../kit"1415export interface EditorContext extends SummaryContext {16 labels: LabelRef[]17 snippets: SnippetRef[]18 /** la couche d'intelligence est active pour ce compte */19 ai: boolean20}2122function AiNote({ on, text }: { on: boolean; text: string }) {23 return (24 <p className={`nx-set-ainote${on ? "" : " off"}`}>25 <Icon name="sparkle" small />26 <span>27 <strong>{t("nx.settings.rules.needsAi")}</strong> {on ? text : `${text} ${t("nx.settings.rules.aiOff")}`}28 </span>29 </p>30 )31}3233// ---------------------------------------------------------------- une condition34function ConditionRow({ c, n, ai, invalid, onChange, onRemove }: { c: CondForm; n: number; ai: boolean; invalid: boolean; onChange: (c: CondForm) => void; onRemove: () => void }) {35 const ops = FIELD_OPS[c.field]36 const bool = c.field === "has_attachment" || c.field === "is_newsletter"37 return (38 <div className={`nx-set-line${invalid ? " invalid" : ""}`} role="group" aria-label={t("nx.settings.rules.conditionN", { n })} data-testid="rule-condition">39 <div className="nx-set-line-main">40 <select className="select" aria-label={t("nx.settings.rules.fieldLabel")} value={c.field} onChange={(e) => onChange(setConditionField(c, e.target.value as Field))}>41 {FIELDS.map((f) => (42 <option key={f} value={f}>43 {fieldLabel(f)}44 </option>45 ))}46 </select>47 {ops.length > 1 ? (48 <select className="select" aria-label={t("nx.settings.rules.opLabel")} value={c.op} onChange={(e) => onChange({ ...c, op: e.target.value as Op })}>49 {ops.map((o) => (50 <option key={o} value={o}>51 {opLabel(o)}52 </option>53 ))}54 </select>55 ) : (56 <span className="nx-set-op">{opLabel(ops[0])}</span>57 )}58 {bool ? (59 <select className="select" aria-label={t("nx.settings.rules.valueLabel")} value={c.flag ? "1" : "0"} onChange={(e) => onChange({ ...c, flag: e.target.value === "1" })}>60 <option value="1">{t("nx.settings.rules.yes")}</option>61 <option value="0">{t("nx.settings.rules.no")}</option>62 </select>63 ) : c.field === "size" ? (64 <span className="nx-set-pair">65 <input className="input" inputMode="decimal" aria-label={t("nx.settings.rules.sizeLabel")} value={c.amount} onChange={(e) => onChange({ ...c, amount: e.target.value })} maxLength={12} aria-invalid={invalid || undefined} />66 <select className="select" aria-label={t("nx.settings.rules.unitLabel")} value={c.unit} onChange={(e) => onChange({ ...c, unit: e.target.value as SizeUnit })}>67 <option value="kb">{t("nx.settings.rules.unitKb")}</option>68 <option value="mb">{t("nx.settings.rules.unitMb")}</option>69 </select>70 </span>71 ) : c.field === "ai_category" ? (72 <select className="select" aria-label={t("nx.settings.rules.valueLabel")} value={c.text} onChange={(e) => onChange({ ...c, text: e.target.value })}>73 {CATEGORIES.map((x) => (74 <option key={x} value={x}>75 {categoryLabel(x)}76 </option>77 ))}78 </select>79 ) : (80 <input className="input" aria-label={t("nx.settings.rules.valueLabel")} value={c.text} onChange={(e) => onChange({ ...c, text: e.target.value })} maxLength={300} spellCheck={false} autoCapitalize="off" placeholder={c.op === "matches_domain" ? t("nx.settings.rules.domainHint") : undefined} aria-invalid={invalid || undefined} />81 )}82 <IconButton icon="close" label={t("nx.settings.rules.removeCondition", { n })} onClick={onRemove} />83 </div>84 {c.field === "ai_category" ? <AiNote on={ai} text={t("nx.settings.rules.aiCondition")} /> : null}85 </div>86 )87}8889// ---------------------------------------------------------------- une action90function ActionRow({ a, n, ctx, invalid, onChange, onRemove, last }: { a: ActionForm; n: number; ctx: EditorContext; invalid: boolean; onChange: (a: ActionForm) => void; onRemove: () => void; last: boolean }) {91 const set = (p: Partial<ActionForm>) => onChange({ ...a, ...p })92 const setField = (i: number, p: Partial<ActionForm["fields"][number]>) => set({ fields: a.fields.map((f, k) => (k === i ? { ...f, ...p } : f)) })93 return (94 <div className={`nx-set-line${invalid ? " invalid" : ""}`} role="group" aria-label={t("nx.settings.rules.actionN", { n })} data-testid="rule-action">95 <div className="nx-set-line-main">96 <select className="select" aria-label={t("nx.settings.rules.actionType")} value={a.type} onChange={(e) => set({ type: e.target.value as ActionType })}>97 {ACTION_TYPES.map((x) => (98 <option key={x} value={x}>99 {actionLabel(x)}100 </option>101 ))}102 </select>103 {a.type === "label" ? (104 <select className="select" aria-label={t("nx.settings.rules.labelPick")} value={a.labelId} onChange={(e) => set({ labelId: e.target.value })} aria-invalid={invalid || undefined}>105 <option value="">{ctx.labels.length ? t("nx.settings.rules.labelChoose") : t("nx.settings.rules.labelNone")}</option>106 {ctx.labels.map((l) => (107 <option key={l.id} value={l.id}>108 {l.name}109 </option>110 ))}111 </select>112 ) : a.type === "snooze" ? (113 <span className="nx-set-pair">114 <select className="select" aria-label={t("nx.settings.rules.untilLabel")} value={a.untilKind} onChange={(e) => set({ untilKind: e.target.value as UntilKind })}>115 {UNTIL_PRESETS.map((u) => (116 <option key={u} value={u}>117 {t(`nx.settings.rules.until.${u}`)}118 </option>119 ))}120 <option value="hours">{t("nx.settings.rules.until.hours")}</option>121 <option value="days">{t("nx.settings.rules.until.days")}</option>122 </select>123 {a.untilKind === "hours" || a.untilKind === "days" ? <input className="input nx-set-num" inputMode="numeric" aria-label={t("nx.settings.rules.untilN")} value={a.untilN} onChange={(e) => set({ untilN: e.target.value })} maxLength={3} aria-invalid={invalid || undefined} /> : null}124 </span>125 ) : a.type === "remind" ? (126 <span className="nx-set-pair">127 <input className="input nx-set-num" inputMode="decimal" aria-label={t("nx.settings.rules.remindN")} value={a.remindN} onChange={(e) => set({ remindN: e.target.value })} maxLength={6} aria-invalid={invalid || undefined} />128 <select className="select" aria-label={t("nx.settings.rules.remindUnit")} value={a.remindUnit} onChange={(e) => set({ remindUnit: e.target.value as "hours" | "days" })}>129 <option value="hours">{t("nx.settings.rules.unitHours")}</option>130 <option value="days">{t("nx.settings.rules.unitDays")}</option>131 </select>132 </span>133 ) : a.type === "event" || a.type === "notify_app" ? (134 <input className="input mono" aria-label={a.type === "event" ? t("nx.settings.rules.eventName") : t("nx.settings.rules.appName")} value={a.name} onChange={(e) => set({ name: e.target.value })} maxLength={64} spellCheck={false} autoCapitalize="off" placeholder={a.type === "event" ? "facture.recue" : "crm"} aria-invalid={invalid || undefined} />135 ) : a.type === "draft_reply" ? (136 <span className="nx-set-pair">137 <select className="select" aria-label={t("nx.settings.rules.replySource")} value={a.source} onChange={(e) => set({ source: e.target.value as "snippet" | "ai" })}>138 <option value="snippet">{t("nx.settings.rules.replySnippet")}</option>139 <option value="ai">{t("nx.settings.rules.replyAi")}</option>140 </select>141 {a.source === "snippet" ? (142 <select className="select" aria-label={t("nx.settings.rules.snippetPick")} value={a.snippetId} onChange={(e) => set({ snippetId: e.target.value })} aria-invalid={invalid || undefined}>143 <option value="">{ctx.snippets.length ? t("nx.settings.rules.snippetChoose") : t("nx.settings.rules.snippetNone")}</option>144 {ctx.snippets.map((s) => (145 <option key={s.id} value={s.id}>146 {s.name}147 </option>148 ))}149 </select>150 ) : (151 <select className="select" aria-label={t("nx.settings.rules.tonePick")} value={a.tone} onChange={(e) => set({ tone: e.target.value as Tone })}>152 {TONES.map((x) => (153 <option key={x} value={x}>154 {toneLabel(x)}155 </option>156 ))}157 </select>158 )}159 </span>160 ) : (161 <span className="nx-set-fill" />162 )}163 <IconButton icon="close" label={t("nx.settings.rules.removeAction", { n })} disabled={last} onClick={onRemove} />164 </div>165 {a.type === "event" || a.type === "notify_app" ? <p className="nx-note nx-set-sub">{a.type === "event" ? t("nx.settings.rules.eventHint") : t("nx.settings.rules.appHint")}</p> : null}166 {a.type === "draft_reply" ? <p className="nx-note nx-set-sub">{t("nx.settings.rules.draftHint")}</p> : null}167 {a.type === "extract" ? (168 <div className="nx-set-extract">169 {a.fields.map((f, i) => (170 <div key={i} className="nx-set-extract-row" role="group" aria-label={t("nx.settings.rules.extractFieldN", { n: i + 1 })}>171 <input className="input mono" aria-label={t("nx.settings.rules.extractName")} value={f.name} onChange={(e) => setField(i, { name: e.target.value })} maxLength={40} spellCheck={false} autoCapitalize="off" placeholder="montant" aria-invalid={invalid || undefined} />172 <select className="select" aria-label={t("nx.settings.rules.extractType")} value={f.type} onChange={(e) => setField(i, { type: e.target.value as ExtractType })}>173 {EXTRACT_TYPES.map((x) => (174 <option key={x} value={x}>175 {t(`nx.settings.rules.extract.${x}`)}176 </option>177 ))}178 </select>179 <input className="input" aria-label={t("nx.settings.rules.extractDesc")} value={f.description} onChange={(e) => setField(i, { description: e.target.value })} maxLength={200} placeholder={t("nx.settings.rules.extractDescHint")} />180 <IconButton icon="close" label={t("nx.settings.rules.extractRemove", { n: i + 1 })} disabled={a.fields.length === 1} onClick={() => set({ fields: a.fields.filter((_, k) => k !== i) })} />181 </div>182 ))}183 <div>184 <button type="button" className="btn small" disabled={a.fields.length >= 12} onClick={() => set({ fields: [...a.fields, { name: "", type: "string", description: "" }] })}>185 <Icon name="plus" small />186 <span>{t("nx.settings.rules.extractAdd")}</span>187 </button>188 </div>189 <p className="nx-note">{t("nx.settings.rules.extractHint")}</p>190 </div>191 ) : null}192 {actionNeedsAi(a) ? <AiNote on={ctx.ai} text={a.type === "extract" ? t("nx.settings.rules.aiExtract") : t("nx.settings.rules.aiDraft")} /> : null}193 </div>194 )195}196197// ---------------------------------------------------------------- essai à blanc198function DryRun({ build, ctx }: { build: () => RuleInput | null; ctx: EditorContext }) {199 const mailboxes = useStore(S, (s) => s.me?.mailboxes ?? [])200 const online = useStore(S, (s) => s.online)201 const [mb, setMb] = useState(mailboxes[0]?.id ?? "")202 const [messages, setMessages] = useState<{ status: "loading" | "ready" | "error"; list: MessageSummary[] }>({ status: "loading", list: [] })203 const [emailId, setEmailId] = useState("")204 const [busy, setBusy] = useState(false)205 const [tested, setTested] = useState<{ result: RuleTestResult; rule: RuleInput } | null>(null)206 const [error, setError] = useState<string | null>(null)207 const id = useId()208 const run = useRef(0)209210 useEffect(() => {211 if (!mb) return212 const ac = new AbortController()213 setMessages({ status: "loading", list: [] })214 setEmailId("")215 setTested(null)216 recentMessages(mb, ac.signal).then(217 (list) => {218 if (ac.signal.aborted) return219 setMessages({ status: "ready", list })220 setEmailId(list[0]?.email_id ?? "")221 },222 (e) => {223 if (!isAbort(e) && !ac.signal.aborted) setMessages({ status: "error", list: [] })224 },225 )226 return () => ac.abort()227 }, [mb])228229 const test = async () => {230 const rule = build()231 setTested(null)232 setError(null)233 if (!rule) return setError(t("nx.settings.rules.test.fixFirst"))234 if (!emailId) return235 const my = ++run.current236 setBusy(true)237 try {238 const r = await testRule(rule, mb, emailId)239 if (my === run.current) setTested({ result: r, rule })240 } catch (e) {241 const err = toNextError(e)242 if (my === run.current) setError(err.kind === "offline" ? t("nx.offline") : err.kind === "not_found" ? t("nx.settings.rules.test.gone") : err.kind === "rate_limited" ? t("nx.error.rateLimited") : err.message || t("nx.error.generic"))243 } finally {244 if (my === run.current) setBusy(false)245 }246 }247248 const result = tested?.result ?? null249 return (250 <fieldset className="set-fieldset nx-set-test" data-testid="rule-test">251 <legend>{t("nx.settings.rules.test.title")}</legend>252 <p className="nx-note">{t("nx.settings.rules.test.desc")}</p>253 <div className="nx-set-test-pick">254 {mailboxes.length > 1 ? (255 <FormField id={`${id}-mb`} label={t("nx.settings.rules.test.mailbox")}>256 <select id={`${id}-mb`} className="select" value={mb} onChange={(e) => setMb(e.target.value)}>257 {mailboxes.map((m) => (258 <option key={m.id} value={m.id}>259 {m.address}260 </option>261 ))}262 </select>263 </FormField>264 ) : null}265 <FormField id={`${id}-msg`} label={t("nx.settings.rules.test.message")}>266 <select id={`${id}-msg`} className="select" value={emailId} disabled={messages.status !== "ready" || !messages.list.length} onChange={(e) => (setEmailId(e.target.value), setTested(null))}>267 {messages.status === "loading" ? <option value="">{t("nx.loading")}</option> : null}268 {messages.status === "error" ? <option value="">{t("nx.settings.rules.test.loadFailed")}</option> : null}269 {messages.status === "ready" && !messages.list.length ? <option value="">{t("nx.settings.rules.test.noMessage")}</option> : null}270 {messages.list.map((m) => (271 <option key={m.email_id} value={m.email_id}>272 {`${m.subject || t("nx.settings.rules.test.noSubject")} — ${m.from[0]?.name || m.from[0]?.email || "?"} · ${fmtListDate(m.received_at)}`}273 </option>274 ))}275 </select>276 </FormField>277 <button type="button" className="btn" disabled={!online || busy || !emailId} title={online ? undefined : t("nx.offline")} onClick={() => void test()}>278 {t("nx.settings.rules.test.run")}279 </button>280 {busy ? <Spinner /> : null}281 </div>282 {error ? (283 <p className="set-error" role="alert">284 {error}285 </p>286 ) : null}287 {result && tested ? (288 <div className={`banner ${result.matched ? "ok" : "warn"} nx-set-test-result`} role="status" data-testid="rule-test-result" data-matched={result.matched}>289 <Icon name={result.matched ? "check" : "close"} />290 <div className="stack nx-set-test-body">291 <strong>{result.matched ? t("nx.settings.rules.test.matched") : t("nx.settings.rules.test.notMatched")}</strong>292 {result.conditions.length ? (293 <ul className="nx-set-test-list" aria-label={t("nx.settings.rules.conditions")}>294 {result.conditions.map((c, i) => (295 <li key={i} data-result={c.result}>296 <Icon name={c.result ? "check" : "close"} small />297 <span>{conditionSummary(c)}</span>298 <span className="sr-only">{c.result ? t("nx.settings.rules.test.condTrue") : t("nx.settings.rules.test.condFalse")}</span>299 </li>300 ))}301 </ul>302 ) : (303 <span>{t("nx.settings.rules.test.noCondition")}</span>304 )}305 {result.matched ? (306 <>307 <span className="nx-set-test-sub">{t("nx.settings.rules.test.would")}</span>308 <ul className="nx-set-test-list" aria-label={t("nx.settings.rules.test.would")}>309 {tested.rule.actions.slice(0, result.actions.length).map((a, i) => (310 <li key={i}>311 <Icon name="chevronRight" small />312 <span>{actionSummary(a, ctx)}</span>313 </li>314 ))}315 </ul>316 </>317 ) : null}318 {result.facts.ai_category ? <span className="nx-note">{t("nx.settings.rules.test.category", { category: categoryLabel(result.facts.ai_category) })}</span> : null}319 <span className="nx-note">{t("nx.settings.rules.test.nothingDone")}</span>320 </div>321 </div>322 ) : null}323 </fieldset>324 )325}326327// ---------------------------------------------------------------- dialogue328export function RuleEditor({ initial, isNew, ctx, onSave, onClose }: { initial: RuleForm; isNew: boolean; ctx: EditorContext; onSave: (rule: RuleInput) => Promise<string | null>; onClose: () => void }) {329 const [form, setForm] = useState<RuleForm>(initial)330 const [issues, setIssues] = useState<FormIssue[]>([])331 const [serverError, setServerError] = useState<string | null>(null)332 const [saving, setSaving] = useState(false)333 const online = useStore(S, (s) => s.online)334 const owned = useStore(S, (s) => s.me?.mailboxes ?? []).filter((m) => m.access !== "shared")335 const [scoped, setScoped] = useState(initial.mailboxIds.length > 0)336 const id = useId()337 const patch = (p: Partial<RuleForm>) => {338 setForm((f) => ({ ...f, ...p }))339 setServerError(null)340 }341 const bad = (at: string) => issues.some((i) => i.at === at)342 const current = (): RuleForm => ({ ...form, mailboxIds: scoped ? form.mailboxIds : [] })343344 const submit = async () => {345 const r = formToRule(current())346 if (!r.ok) return setIssues(r.issues)347 if (scoped && !form.mailboxIds.length) return setServerError(t("nx.settings.rules.err.scope"))348 setIssues([])349 setSaving(true)350 const err = await onSave(r.rule)351 setSaving(false)352 if (err) setServerError(err)353 }354 const build = (): RuleInput | null => {355 // l'essai n'exige pas de nom : le serveur l'accepte sans356 const r = formToRule({ ...current(), name: form.name.trim() || "essai" })357 if (r.ok) setIssues([])358 else setIssues(r.issues)359 return r.ok ? r.rule : null360 }361362 return (363 <Dialog364 title={isNew ? t("nx.settings.rules.new") : t("nx.settings.rules.edit")}365 onClose={onClose}366 wide367 footer={368 <>369 {saving ? <Spinner /> : null}370 <button type="button" className="btn" onClick={onClose}>371 {t("common.cancel")}372 </button>373 <button type="button" className="btn primary" disabled={saving || !online} title={online ? undefined : t("nx.offline")} onClick={() => void submit()} data-testid="rule-save">374 {isNew ? t("nx.settings.rules.create") : t("nx.settings.rules.save")}375 </button>376 </>377 }378 >379 <form380 className="stack nx-set-editor"381 onSubmit={(e) => {382 e.preventDefault()383 void submit()384 }}385 >386 <FormField id={`${id}-name`} label={t("nx.settings.rules.name")}>387 <input id={`${id}-name`} className="input" value={form.name} onChange={(e) => patch({ name: e.target.value })} maxLength={80} data-autofocus aria-invalid={issues.some((i) => i.code === "name") || undefined} />388 </FormField>389390 <fieldset className="set-fieldset">391 <legend>{t("nx.settings.rules.conditions")}</legend>392 <div className="stack">393 {form.conditions.length > 1 ? (394 <div className="row wrap" role="radiogroup" aria-label={t("nx.settings.rules.match")}>395 <label className="check">396 <input type="radio" name={`${id}-match`} checked={form.match === "all"} onChange={() => patch({ match: "all" })} />397 <span>{t("nx.settings.rules.matchAll")}</span>398 </label>399 <label className="check">400 <input type="radio" name={`${id}-match`} checked={form.match === "any"} onChange={() => patch({ match: "any" })} />401 <span>{t("nx.settings.rules.matchAny")}</span>402 </label>403 </div>404 ) : null}405 {form.conditions.length === 0 ? <p className="nx-note">{t("nx.settings.rules.noCondition")}</p> : null}406 {form.conditions.map((c, i) => (407 <ConditionRow key={c.key} c={c} n={i + 1} ai={ctx.ai} invalid={bad(`c:${c.key}`)} onChange={(next) => patch({ conditions: form.conditions.map((x) => (x.key === c.key ? next : x)) })} onRemove={() => patch({ conditions: form.conditions.filter((x) => x.key !== c.key) })} />408 ))}409 <div>410 <button type="button" className="btn small" disabled={form.conditions.length >= 20} onClick={() => patch({ conditions: [...form.conditions, newCondition()] })}>411 <Icon name="plus" small />412 <span>{t("nx.settings.rules.addCondition")}</span>413 </button>414 </div>415 </div>416 </fieldset>417418 <fieldset className="set-fieldset">419 <legend>{t("nx.settings.rules.actions")}</legend>420 <div className="stack">421 {form.actions.map((a, i) => (422 <ActionRow key={a.key} a={a} n={i + 1} ctx={ctx} invalid={bad(`a:${a.key}`)} last={form.actions.length === 1} onChange={(next) => patch({ actions: form.actions.map((x) => (x.key === a.key ? next : x)) })} onRemove={() => patch({ actions: form.actions.filter((x) => x.key !== a.key) })} />423 ))}424 <div>425 <button type="button" className="btn small" disabled={form.actions.length >= 10} onClick={() => patch({ actions: [...form.actions, newAction("star")] })}>426 <Icon name="plus" small />427 <span>{t("nx.settings.rules.addAction")}</span>428 </button>429 </div>430 <label className="check">431 <input type="checkbox" checked={form.stop} onChange={(e) => patch({ stop: e.target.checked })} />432 <span>{t("nx.settings.rules.stop")}</span>433 </label>434 </div>435 </fieldset>436437 {owned.length > 1 ? (438 <fieldset className="set-fieldset">439 <legend>{t("nx.settings.rules.scope")}</legend>440 <div className="stack">441 <div className="row wrap" role="radiogroup" aria-label={t("nx.settings.rules.scope")}>442 <label className="check">443 <input type="radio" name={`${id}-scope`} checked={!scoped} onChange={() => setScoped(false)} />444 <span>{t("nx.settings.rules.scopeAll")}</span>445 </label>446 <label className="check">447 <input type="radio" name={`${id}-scope`} checked={scoped} onChange={() => setScoped(true)} />448 <span>{t("nx.settings.rules.scopeSome")}</span>449 </label>450 </div>451 {scoped ? (452 <div className="stack set-indent">453 {owned.map((m) => (454 <label key={m.id} className="check">455 <input type="checkbox" checked={form.mailboxIds.includes(m.id)} onChange={(e) => patch({ mailboxIds: e.target.checked ? [...form.mailboxIds, m.id] : form.mailboxIds.filter((x) => x !== m.id) })} />456 <span>{m.address}</span>457 </label>458 ))}459 </div>460 ) : null}461 </div>462 </fieldset>463 ) : null}464465 <label className="check">466 <input type="checkbox" checked={form.enabled} onChange={(e) => patch({ enabled: e.target.checked })} />467 <span>{t("nx.settings.rules.enabled")}</span>468 </label>469470 {issues.length ? (471 <ul className="set-error nx-set-issues" role="alert">472 {issues.map((i, k) => (473 <li key={k}>{issueText(i)}</li>474 ))}475 </ul>476 ) : null}477 {serverError ? (478 <p className="set-error" role="alert">479 {serverError}480 </p>481 ) : null}482483 <DryRun build={build} ctx={ctx} />484 {/* Entrée dans un champ enregistre la règle */}485 <button type="submit" hidden />486 </form>487 </Dialog>488 )489}490