diff --git a/messages/en-US.json b/messages/en-US.json index 8454467b2..1bf6a30ad 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -843,6 +843,10 @@ "policyAuthHeaderAuthSummary": "Header configured", "policyAuthHeaderName": "Header name", "policyAuthHeaderValue": "Expected value", + "policyAuthSetPasscode": "Set Passcode", + "policyAuthSetPincode": "Set PIN Code", + "policyAuthSetEmailWhitelist": "Set Email Whitelist", + "policyAuthSetHeaderAuth": "Set Basic Header Auth", "policyAccessRulesTitle": "Access Rules", "policyAccessRulesEnableDescription": "When enabled, rules are evaluated in descending order until one evaluates as true.", "policyAccessRulesFirstMatch": "Rules are evaluated top to bottom. The first matching rule decides the outcome.", @@ -3131,6 +3135,7 @@ "maintenanceModeType": "Maintenance Mode Type", "showMaintenancePage": "Show a maintenance page to visitors", "enableMaintenanceMode": "Enable Maintenance Mode", + "enableMaintenanceModeDescription": "When enabled, visitors will see a maintenance page instead of your resource.", "automatic": "Automatic", "automaticModeDescription": " Show maintenance page only when all backend targets are down or unhealthy. Your resource continues working normally as long as at least one target is healthy.", "forced": "Forced", diff --git a/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx b/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx index f53afd056..ef909bd9f 100644 --- a/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx +++ b/src/app/[orgId]/settings/resources/public/[niceId]/general/page.tsx @@ -220,6 +220,11 @@ function MaintenanceSectionForm({ + + {t( + "enableMaintenanceModeDescription" + )} + ); @@ -586,6 +591,40 @@ export default function GeneralForm() { className="space-y-4" id="general-settings-form" > + ( + + + + form.setValue( + "enabled", + val + ) + } + /> + + + {t( + "disabledResourceDescription" + )} + + + + )} + /> +
)} - - ( - - - - form.setValue( - "enabled", - val - ) - } - /> - - - {t( - "disabledResourceDescription" - )} - - - - )} - /> diff --git a/src/components/resource-policy/PolicyAuthMethodCredenzas.tsx b/src/components/resource-policy/PolicyAuthMethodCredenzas.tsx index 2daebb9f5..caf9092ab 100644 --- a/src/components/resource-policy/PolicyAuthMethodCredenzas.tsx +++ b/src/components/resource-policy/PolicyAuthMethodCredenzas.tsx @@ -117,7 +117,7 @@ export function PasscodeCredenza({ title={t("resourcePasswordSetupTitle")} description={t("resourcePasswordSetupTitleDescription")} formId="policy-passcode-form" - submitLabel={t("resourcePasswordSubmit")} + submitLabel={t("policyAuthSetPasscode")} >
void; + onSave: (emails: Tag[]) => void; }; export function EmailCredenza({ @@ -377,12 +377,19 @@ export function EmailCredenza({ emailEnabled, disabled, emails, - onEmailsChange + onSave }: EmailCredenzaProps) { const t = useTranslations(); const [activeEmailTagIndex, setActiveEmailTagIndex] = useState< number | null >(null); + const [draftEmails, setDraftEmails] = useState(emails); + + useEffect(() => { + if (open) { + setDraftEmails(emails); + } + }, [open, emails]); return ( @@ -394,72 +401,90 @@ export function EmailCredenza({ -
- {!emailEnabled && ( - - - - {t("otpEmailSmtpRequired")} - - - {t("otpEmailSmtpRequiredDescription")} - - - )} - {emailEnabled && ( -

- {t("otpEmailWhitelistListDescription")} -

- )} - {emailEnabled && ( - - - {t("otpEmailWhitelistList")} - - - { - if (!disabled) { - onEmailsChange( - newEmails as Tag[] - ); + { + event.preventDefault(); + onSave(draftEmails); + onOpenChange(false); + }} + > +
+ {!emailEnabled && ( + + + + {t("otpEmailSmtpRequired")} + + + {t("otpEmailSmtpRequiredDescription")} + + + )} + {emailEnabled && ( +

+ {t("otpEmailWhitelistListDescription")} +

+ )} + {emailEnabled && ( + + + {t("otpEmailWhitelistList")} + + + - z - .email() - .or( - z - .string() - .regex( - /^\*@[\w.-]+\.[a-zA-Z]{2,}$/ - ) - ) - .safeParse(tag).success - } - allowDuplicates={false} - sortTags - size="sm" - disabled={disabled} - /> - - - {t("otpEmailEnterDescription")} - - - )} -
+ placeholder={t("otpEmailEnter")} + tags={draftEmails} + setTags={(newEmails) => { + if (!disabled) { + setDraftEmails( + newEmails as Tag[] + ); + } + }} + validateTag={(tag) => + z + .email() + .or( + z + .string() + .regex( + /^\*@[\w.-]+\.[a-zA-Z]{2,}$/ + ) + ) + .safeParse(tag).success + } + allowDuplicates={false} + sortTags + size="sm" + disabled={disabled} + /> +
+ + {t("otpEmailEnterDescription")} + +
+ )} +
+
+ {emailEnabled && ( + + )}
diff --git a/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx b/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx index c462cd9ae..3f9631b02 100644 --- a/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx +++ b/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx @@ -279,7 +279,7 @@ export function PolicyAuthStackSectionCreate({ onOpenChange={(open) => !open && closeCredenza()} emailEnabled={emailEnabled} emails={emails} - onEmailsChange={(value) => + onSave={(value) => parentForm.setValue( "emails", value as PolicyFormValues["emails"] diff --git a/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx b/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx index f24e4360d..7ecd7a8a8 100644 --- a/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx +++ b/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx @@ -648,9 +648,7 @@ export function PolicyAuthStackSectionEdit({ emailEnabled={emailEnabled} disabled={authReadonly} emails={emails} - onEmailsChange={(value) => - form.setValue("emails", value) - } + onSave={(value) => form.setValue("emails", value)} />