Refactor License Key Settings UI: Simplify conditional rendering for license key management, update contact link to the official site, and enhance user feedback with improved loading states for activation and validation processes.

This commit is contained in:
Mauricio Siu
2026-01-29 08:14:35 -06:00
parent 2b52332e43
commit 2e7f4dc1a2
@@ -1,4 +1,4 @@
import { Key, Loader2 } from "lucide-react"; import { Key, Loader2, ShieldCheck } from "lucide-react";
import Link from "next/link"; import Link from "next/link";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { toast } from "sonner"; import { toast } from "sonner";
@@ -50,6 +50,7 @@ export function LicenseKeySettings() {
<CardTitle className="text-xl">License Key</CardTitle> <CardTitle className="text-xl">License Key</CardTitle>
</div> </div>
{enabled && (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground"> <span className="text-xs text-muted-foreground">
{enabled ? "Enabled" : "Disabled"} {enabled ? "Enabled" : "Disabled"}
@@ -71,13 +72,14 @@ export function LicenseKeySettings() {
}} }}
/> />
</div> </div>
)}
</div> </div>
<p className="text-sm text-muted-foreground"> <p className="text-sm text-muted-foreground">
To unlock extra features you need an enterprise license key. To unlock extra features you need an enterprise license key.
Contact us{" "} Contact us{" "}
<Link <Link
href="http://localhost:3001/contact" href="https://dokploy.com/contact"
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
className="underline underline-offset-4" className="underline underline-offset-4"
@@ -87,7 +89,8 @@ export function LicenseKeySettings() {
. .
</p> </p>
</div> </div>
{enabled && ( {enabled ? (
<>
<div className="grid gap-3 md:grid-cols-[1fr_auto] md:items-end"> <div className="grid gap-3 md:grid-cols-[1fr_auto] md:items-end">
<div className="space-y-2"> <div className="space-y-2">
<label className="text-sm font-medium" htmlFor="licenseKey"> <label className="text-sm font-medium" htmlFor="licenseKey">
@@ -140,7 +143,9 @@ export function LicenseKeySettings() {
isLoading={isValidating} isLoading={isValidating}
onClick={async () => { onClick={async () => {
try { try {
const valid = await validateLicenseKey({ licenseKey }); const valid = await validateLicenseKey({
licenseKey,
});
console.log("valid", valid); console.log("valid", valid);
if (valid) { if (valid) {
toast.success("License key is valid"); toast.success("License key is valid");
@@ -186,6 +191,41 @@ export function LicenseKeySettings() {
)} )}
</div> </div>
</div> </div>
</>
) : (
<div className="flex flex-col items-center gap-4 justify-center min-h-[30vh] text-center">
<div className="flex flex-col items-center gap-2 max-w-[400px]">
<div className="rounded-full bg-muted p-4">
<ShieldCheck className="size-8 text-muted-foreground" />
</div>
<div className="space-y-1">
<h3 className="text-lg font-semibold">Enterprise Features</h3>
<p className="text-sm text-muted-foreground">
Unlock advanced capabilities like SSO, Audit logs,
whitelabeling and more.
</p>
</div>
</div>
<Button
onClick={async () => {
try {
await updateEnterpriseSettings({
enableEnterpriseFeatures: true,
});
await utils.licenseKey.getEnterpriseSettings.invalidate();
toast.success("Enterprise features enabled");
} catch (error) {
console.error(error);
toast.error("Failed to enable enterprise features");
}
}}
isLoading={isSaving}
disabled={isLoading || isDeactivating}
>
Enable Enterprise Features
</Button>
</div>
)} )}
</> </>
)} )}