mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 14:27:59 +00:00
fix: update badge variants for certificate renewal
This commit is contained in:
@@ -5,12 +5,12 @@ import {
|
|||||||
faEllipsis,
|
faEllipsis,
|
||||||
faEye,
|
faEye,
|
||||||
faFileExport,
|
faFileExport,
|
||||||
faQuestionCircle,
|
|
||||||
faRedo,
|
faRedo,
|
||||||
faTrash
|
faTrash
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
import { CircleQuestionMarkIcon } from "lucide-react";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
@@ -58,7 +58,7 @@ const isExpiringWithinOneDay = (notAfter: string): boolean => {
|
|||||||
|
|
||||||
const getAutoRenewalInfo = (certificate: TCertificate) => {
|
const getAutoRenewalInfo = (certificate: TCertificate) => {
|
||||||
if (certificate.renewedByCertificateId) {
|
if (certificate.renewedByCertificateId) {
|
||||||
return { text: "Renewed", variant: "instance" as const };
|
return { text: "Renewed", variant: "neutral" as const };
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRevoked = certificate.status === CertStatus.REVOKED;
|
const isRevoked = certificate.status === CertStatus.REVOKED;
|
||||||
@@ -69,7 +69,7 @@ const getAutoRenewalInfo = (certificate: TCertificate) => {
|
|||||||
if (isRevoked) {
|
if (isRevoked) {
|
||||||
return {
|
return {
|
||||||
text: "Not Available",
|
text: "Not Available",
|
||||||
variant: "instance" as const,
|
variant: "neutral" as const,
|
||||||
tooltip: "Renewal is not available for revoked certificates"
|
tooltip: "Renewal is not available for revoked certificates"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ const getAutoRenewalInfo = (certificate: TCertificate) => {
|
|||||||
if (isExpired) {
|
if (isExpired) {
|
||||||
return {
|
return {
|
||||||
text: "Not Available",
|
text: "Not Available",
|
||||||
variant: "instance" as const,
|
variant: "neutral" as const,
|
||||||
tooltip: "Renewal is not available for expired certificates"
|
tooltip: "Renewal is not available for expired certificates"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ const getAutoRenewalInfo = (certificate: TCertificate) => {
|
|||||||
if (hasNoProfile) {
|
if (hasNoProfile) {
|
||||||
return {
|
return {
|
||||||
text: "Not Available",
|
text: "Not Available",
|
||||||
variant: "instance" as const,
|
variant: "neutral" as const,
|
||||||
tooltip: "Renewal requires a certificate profile"
|
tooltip: "Renewal requires a certificate profile"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ const getAutoRenewalInfo = (certificate: TCertificate) => {
|
|||||||
if (certificate.hasPrivateKey === false) {
|
if (certificate.hasPrivateKey === false) {
|
||||||
return {
|
return {
|
||||||
text: "Not Available",
|
text: "Not Available",
|
||||||
variant: "instance" as const,
|
variant: "neutral" as const,
|
||||||
tooltip: "Renewal is not available for certificates with externally generated private keys"
|
tooltip: "Renewal is not available for certificates with externally generated private keys"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ const getAutoRenewalInfo = (certificate: TCertificate) => {
|
|||||||
if (isExpiringWithinDay) {
|
if (isExpiringWithinDay) {
|
||||||
return {
|
return {
|
||||||
text: "Not Available",
|
text: "Not Available",
|
||||||
variant: "instance" as const,
|
variant: "neutral" as const,
|
||||||
tooltip: "Auto-renewal is not available for certificates expiring within 24 hours"
|
tooltip: "Auto-renewal is not available for certificates expiring within 24 hours"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ const getAutoRenewalInfo = (certificate: TCertificate) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!certificate.renewBeforeDays) {
|
if (!certificate.renewBeforeDays) {
|
||||||
return { text: "Auto-Renewal Disabled", variant: "primary" as const };
|
return { text: "Auto-Renewal Disabled", variant: "warning" as const };
|
||||||
}
|
}
|
||||||
|
|
||||||
const notAfterDate = new Date(certificate.notAfter);
|
const notAfterDate = new Date(certificate.notAfter);
|
||||||
@@ -133,11 +133,11 @@ const getAutoRenewalInfo = (certificate: TCertificate) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (daysUntilRenewal === 0) {
|
if (daysUntilRenewal === 0) {
|
||||||
return { text: "Renews today", variant: "primary" as const };
|
return { text: "Renews today", variant: "warning" as const };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (daysUntilRenewal <= 7) {
|
if (daysUntilRenewal <= 7) {
|
||||||
return { text: `Renews in ${daysUntilRenewal}d`, variant: "primary" as const };
|
return { text: `Renews in ${daysUntilRenewal}d`, variant: "warning" as const };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { text: `Renews in ${daysUntilRenewal}d`, variant: "success" as const };
|
return { text: `Renews in ${daysUntilRenewal}d`, variant: "success" as const };
|
||||||
@@ -279,16 +279,12 @@ export const CertificatesTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
{autoRenewalInfo &&
|
{autoRenewalInfo &&
|
||||||
(autoRenewalInfo.tooltip ? (
|
(autoRenewalInfo.tooltip ? (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Badge variant={autoRenewalInfo.variant}>
|
<Tooltip content={autoRenewalInfo.tooltip}>
|
||||||
{autoRenewalInfo.text}
|
<Badge variant={autoRenewalInfo.variant}>
|
||||||
<Tooltip content={autoRenewalInfo.tooltip}>
|
{autoRenewalInfo.text}
|
||||||
<FontAwesomeIcon
|
<CircleQuestionMarkIcon />
|
||||||
icon={faQuestionCircle}
|
</Badge>
|
||||||
className="ml-1 cursor-help text-red-400 hover:text-red-300"
|
</Tooltip>
|
||||||
size="sm"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</Badge>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Badge variant={autoRenewalInfo.variant}>{autoRenewalInfo.text}</Badge>
|
<Badge variant={autoRenewalInfo.variant}>{autoRenewalInfo.text}</Badge>
|
||||||
|
|||||||
Reference in New Issue
Block a user