From bb5594ab2ff0ccbce1a087cc164416fd1f1838b6 Mon Sep 17 00:00:00 2001 From: Owen Date: Thu, 13 Nov 2025 21:05:13 -0500 Subject: [PATCH] Update form --- messages/en-US.json | 4 +- .../resources/[niceId]/general/page.tsx | 270 +++++++++++------- 2 files changed, 175 insertions(+), 99 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 46c12d6c..13d002d1 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -2386,7 +2386,5 @@ "maintenanceTime": "e.g., 2 hours, Nov 1 at 5:00 PM", "maintenanceEstimatedTimeDescription": "When you expect maintenance to be completed", "editDomain": "Edit Domain", - "editDomainDescription": "Select a domain for your resource", - "maintenanceModeDisabledTooltip": "This feature requires a valid license to enable." - + "editDomainDescription": "Select a domain for your resource" } diff --git a/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx b/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx index 82d319de..d9b79371 100644 --- a/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx +++ b/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx @@ -61,7 +61,13 @@ import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusCo import { useUserContext } from "@app/hooks/useUserContext"; import { Alert, AlertDescription } from "@app/components/ui/alert"; import { RadioGroup, RadioGroupItem } from "@app/components/ui/radio-group"; -import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@app/components/ui/tooltip"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger +} from "@app/components/ui/tooltip"; +import { LicenseOrSubscriptionRequiredAlert } from "@app/components/SecurityFeaturesAlert"; export default function GeneralForm() { const [formKey, setFormKey] = useState(0); @@ -122,7 +128,7 @@ export default function GeneralForm() { maintenanceModeType: z.enum(["forced", "automatic"]).optional(), maintenanceTitle: z.string().max(255).optional(), maintenanceMessage: z.string().max(2000).optional(), - maintenanceEstimatedTime: z.string().max(100).optional(), + maintenanceEstimatedTime: z.string().max(100).optional() }) .refine( (data) => { @@ -155,9 +161,12 @@ export default function GeneralForm() { // enableProxy: resource.enableProxy || false maintenanceModeEnabled: resource.maintenanceModeEnabled || false, maintenanceModeType: resource.maintenanceModeType || "automatic", - maintenanceTitle: resource.maintenanceTitle || "We'll be back soon!", - maintenanceMessage: resource.maintenanceMessage || "We are currently performing scheduled maintenance. Please check back soon.", - maintenanceEstimatedTime: resource.maintenanceEstimatedTime || "", + maintenanceTitle: + resource.maintenanceTitle || "We'll be back soon!", + maintenanceMessage: + resource.maintenanceMessage || + "We are currently performing scheduled maintenance. Please check back soon.", + maintenanceEstimatedTime: resource.maintenanceEstimatedTime || "" }, mode: "onChange" }); @@ -193,7 +202,7 @@ export default function GeneralForm() { const rawDomains = res.data.data.domains as DomainRow[]; const domains = rawDomains.map((domain) => ({ ...domain, - baseDomain: toUnicode(domain.baseDomain), + baseDomain: toUnicode(domain.baseDomain) })); setBaseDomains(domains); setFormKey((key) => key + 1); @@ -220,7 +229,9 @@ export default function GeneralForm() { enabled: data.enabled, name: data.name, niceId: data.niceId, - subdomain: data.subdomain ? toASCII(data.subdomain) : undefined, + subdomain: data.subdomain + ? toASCII(data.subdomain) + : undefined, domainId: data.domainId, proxyPort: data.proxyPort, // ...(!resource.http && { @@ -230,7 +241,8 @@ export default function GeneralForm() { maintenanceModeType: data.maintenanceModeType, maintenanceTitle: data.maintenanceTitle || null, maintenanceMessage: data.maintenanceMessage || null, - maintenanceEstimatedTime: data.maintenanceEstimatedTime || null, + maintenanceEstimatedTime: + data.maintenanceEstimatedTime || null } ) .catch((e) => { @@ -261,7 +273,7 @@ export default function GeneralForm() { maintenanceModeType: data.maintenanceModeType, maintenanceTitle: data.maintenanceTitle || null, maintenanceMessage: data.maintenanceMessage || null, - maintenanceEstimatedTime: data.maintenanceEstimatedTime || null, + maintenanceEstimatedTime: data.maintenanceEstimatedTime || null }); toast({ @@ -270,7 +282,9 @@ export default function GeneralForm() { }); if (data.niceId && data.niceId !== resource?.niceId) { - router.replace(`/${updated.orgId}/settings/resources/${data.niceId}/general`); + router.replace( + `/${updated.orgId}/settings/resources/${data.niceId}/general` + ); } else { router.refresh(); } @@ -355,11 +369,15 @@ export default function GeneralForm() { name="niceId" render={({ field }) => ( - {t("identifier")} + + {t("identifier")} + @@ -395,10 +413,10 @@ export default function GeneralForm() { .target .value ? parseInt( - e - .target - .value - ) + e + .target + .value + ) : undefined ) } @@ -485,20 +503,6 @@ export default function GeneralForm() { - - - - @@ -515,6 +519,8 @@ export default function GeneralForm() { + +
@@ -526,45 +532,49 @@ export default function GeneralForm() { isSecurityFeatureDisabled(); return ( -
- +
- - { - if (!isDisabled) { - form.setValue("maintenanceModeEnabled", val); - } - }} - /> - + { + if ( + !isDisabled + ) { + form.setValue( + "maintenanceModeEnabled", + val + ); + } + }} + />
- - {isDisabled && ( - -

{t("maintenanceModeDisabledTooltip")}

-
- )}
- -
- {t("showMaintenancePage")} + {t( + "showMaintenancePage" + )}
@@ -580,12 +590,19 @@ export default function GeneralForm() { render={({ field }) => ( - {t("maintenanceModeType")} + {t( + "maintenanceModeType" + )} @@ -594,10 +611,22 @@ export default function GeneralForm() {
- {t("automatic")} ({t("recommended")}) + + {t( + "automatic" + )} + {" "} + ( + {t( + "recommended" + )} + + ) - {t("automaticModeDescription")} + {t( + "automaticModeDescription" + )}
@@ -607,10 +636,16 @@ export default function GeneralForm() {
- {t("forced")} + + {t( + "forced" + )} + - {t("forcedModeDescription")} + {t( + "forcedModeDescription" + )}
@@ -621,11 +656,19 @@ export default function GeneralForm() { )} /> - {maintenanceModeType === "forced" && ( + {maintenanceModeType === + "forced" && ( - {t("warning:")} {t("forcedeModeWarning")} + + {t( + "warning:" + )} + {" "} + {t( + "forcedeModeWarning" + )} )} @@ -635,15 +678,22 @@ export default function GeneralForm() { name="maintenanceTitle" render={({ field }) => ( - {t("pageTitle")} + + {t( + "pageTitle" + )} + - {t("pageTitleDescription")} + {t( + "pageTitleDescription" + )} @@ -655,16 +705,25 @@ export default function GeneralForm() { name="maintenanceMessage" render={({ field }) => ( - {t("maintenancePageMessage")} + + {t( + "maintenancePageMessage" + )} +