mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-12 13:46:39 +00:00
add tooltip
This commit is contained in:
@@ -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."
|
||||
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
@@ -511,21 +521,46 @@ export default function GeneralForm() {
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="maintenanceModeEnabled"
|
||||
render={({ field }) => (
|
||||
render={({ field }) => {
|
||||
const isDisabled =
|
||||
isSecurityFeatureDisabled();
|
||||
|
||||
return (
|
||||
|
||||
<FormItem>
|
||||
<div className="flex items-center space-x-2">
|
||||
<FormControl>
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className={isDisabled ? "pointer-events-auto" : ""}
|
||||
>
|
||||
<SwitchInput
|
||||
id="enable-maintenance"
|
||||
checked={field.value}
|
||||
label={t("enableMaintenanceMode")}
|
||||
onCheckedChange={(val) =>
|
||||
form.setValue(
|
||||
"maintenanceModeEnabled",
|
||||
val
|
||||
)
|
||||
disabled={isDisabled}
|
||||
onCheckedChange={(val) => {
|
||||
if (!isDisabled) {
|
||||
form.setValue("maintenanceModeEnabled", val);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
|
||||
{isDisabled && (
|
||||
<TooltipContent className="max-w-xs">
|
||||
<p>{t("maintenanceModeDisabledTooltip")}</p>
|
||||
</TooltipContent>
|
||||
)}
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
|
||||
</FormControl>
|
||||
</div>
|
||||
<FormDescription>
|
||||
@@ -533,7 +568,8 @@ export default function GeneralForm() {
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
{isMaintenanceEnabled && (
|
||||
|
||||
Reference in New Issue
Block a user