From 662e63317b3d105f4d85d20327da96292c080cf8 Mon Sep 17 00:00:00 2001 From: Owen Date: Sat, 20 Dec 2025 15:42:10 -0500 Subject: [PATCH] add tooltip --- messages/en-US.json | 4 +- .../resources/[niceId]/general/page.tsx | 166 +++++++++++------- 2 files changed, 104 insertions(+), 66 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 13d002d1..46c12d6c 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -2386,5 +2386,7 @@ "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" + "editDomainDescription": "Select a domain for your resource", + "maintenanceModeDisabledTooltip": "This feature requires a valid license to enable." + } diff --git a/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx b/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx index 57729c0b..82d319de 100644 --- a/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx +++ b/src/app/[orgId]/settings/resources/[niceId]/general/page.tsx @@ -51,7 +51,7 @@ import { CredenzaTitle } from "@app/components/Credenza"; import DomainPicker from "@app/components/DomainPicker"; -import { AlertCircle, Globe } from "lucide-react"; +import { AlertCircle, Globe, Info } from "lucide-react"; import { build } from "@server/build"; import { finalizeSubdomainSanitize } from "@app/lib/subdomain-utils"; import { DomainRow } from "../../../../../../components/DomainsTable"; @@ -61,6 +61,7 @@ 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"; export default function GeneralForm() { const [formKey, setFormKey] = useState(0); @@ -70,8 +71,9 @@ export default function GeneralForm() { const router = useRouter(); const t = useTranslations(); const [editDomainOpen, setEditDomainOpen] = useState(false); - const { licenseStatus } = useLicenseStatusContext(); const subscriptionStatus = useSubscriptionStatusContext(); + const { licenseStatus, isUnlocked } = useLicenseStatusContext(); + const subscription = useSubscriptionStatusContext(); const { user } = useUserContext(); const { env } = useEnvContext(); @@ -99,6 +101,14 @@ export default function GeneralForm() { baseDomain: string; } | null>(null); + // Check if security features are disabled due to licensing/subscription + const isSecurityFeatureDisabled = () => { + const isEnterpriseNotLicensed = build === "enterprise" && !isUnlocked(); + const isSaasNotSubscribed = + build === "saas" && !subscription?.isSubscribed(); + return isEnterpriseNotLicensed || isSaasNotSubscribed; + }; + const GeneralFormSchema = z .object({ enabled: z.boolean(), @@ -360,19 +370,19 @@ export default function GeneralForm() { {!resource.http && ( <> - ( - - + ( + + {t( "resourcePortNumber" )} - - - + + - field.onChange( + field.onChange( e .target .value @@ -389,20 +399,20 @@ export default function GeneralForm() { .target .value ) - : undefined - ) - } - /> - - - + : undefined + ) + } + /> + + + {t( "resourcePortNumberDescription" )} - - - )} - /> + + + )} + /> {/* {build == "oss" && (
- +
@@ -458,15 +468,15 @@ export default function GeneralForm() { type="button" size="sm" onClick={() => - setEditDomainOpen( - true - ) - } - > - {t( - "resourceEditDomain" - )} - + setEditDomainOpen( + true + ) + } + > + {t( + "resourceEditDomain" + )} +
@@ -511,29 +521,55 @@ export default function GeneralForm() { ( - -
- - - form.setValue( - "maintenanceModeEnabled", - val - ) - } - /> - -
- - {t("showMaintenancePage")} - - -
- )} + render={({ field }) => { + const isDisabled = + isSecurityFeatureDisabled(); + + return ( + + +
+ + + + +
+ + { + if (!isDisabled) { + form.setValue("maintenanceModeEnabled", val); + } + }} + /> + +
+
+ + {isDisabled && ( + +

{t("maintenanceModeDisabledTooltip")}

+
+ )} +
+
+ + +
+
+ + {t("showMaintenancePage")} + + +
+ ); + }} /> {isMaintenanceEnabled && ( @@ -601,7 +637,7 @@ export default function GeneralForm() { {t("pageTitle")} - @@ -621,7 +657,7 @@ export default function GeneralForm() { {t("maintenancePageMessage")} -