mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 21:28:59 +00:00
Address greptile comments
This commit is contained in:
@@ -129,7 +129,8 @@ export enum ProjectPermissionCertificateProfileActions {
|
||||
Create = "create",
|
||||
Edit = "edit",
|
||||
Delete = "delete",
|
||||
IssueCert = "issue-cert"
|
||||
IssueCert = "issue-cert",
|
||||
ListCerts = "list-certs"
|
||||
}
|
||||
|
||||
export enum ProjectPermissionSecretRotationActions {
|
||||
|
||||
@@ -176,7 +176,7 @@ export const PkiManagerLayout = () => {
|
||||
}}
|
||||
>
|
||||
{({ isActive }) => (
|
||||
<MenuItem isSelected={isActive}>
|
||||
<MenuItem isSelected={isActive} variant="project">
|
||||
<div className="mx-1 flex gap-2">
|
||||
<div className="w-6">
|
||||
<FontAwesomeIcon icon={faSitemap} />
|
||||
@@ -195,7 +195,7 @@ export const PkiManagerLayout = () => {
|
||||
}}
|
||||
>
|
||||
{({ isActive }) => (
|
||||
<MenuItem isSelected={isActive}>
|
||||
<MenuItem isSelected={isActive} variant="project">
|
||||
<div className="mx-1 flex gap-2">
|
||||
<div className="w-6">
|
||||
<FontAwesomeIcon icon={faFileLines} />
|
||||
|
||||
@@ -140,8 +140,8 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
|
||||
maxPathLength: ca.configuration.maxPathLength
|
||||
? String(ca.configuration.maxPathLength)
|
||||
: "",
|
||||
keyAlgorithm: (Object.values(CertKeyAlgorithm) as string[]).includes(
|
||||
ca.configuration.keyAlgorithm
|
||||
keyAlgorithm: Object.values(CertKeyAlgorithm).includes(
|
||||
ca.configuration.keyAlgorithm as CertKeyAlgorithm
|
||||
)
|
||||
? ca.configuration.keyAlgorithm
|
||||
: CertKeyAlgorithm.RSA_2048
|
||||
|
||||
@@ -25,7 +25,7 @@ export const CertificatesSection = () => {
|
||||
const { subscription } = useSubscription();
|
||||
const { mutateAsync: deleteCert } = useDeleteCert();
|
||||
|
||||
const useOldCertificateFlow = subscription.pkiLegacyTemplates;
|
||||
const isLegacyTemplatesEnabled = subscription.pkiLegacyTemplates;
|
||||
|
||||
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
||||
"certificateIssuance",
|
||||
@@ -80,7 +80,7 @@ export const CertificatesSection = () => {
|
||||
type="submit"
|
||||
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
||||
onClick={() =>
|
||||
handlePopUpOpen(useOldCertificateFlow ? "certificate" : "certificateIssuance")
|
||||
handlePopUpOpen(isLegacyTemplatesEnabled ? "certificate" : "certificateIssuance")
|
||||
}
|
||||
isDisabled={!isAllowed}
|
||||
>
|
||||
@@ -91,7 +91,7 @@ export const CertificatesSection = () => {
|
||||
</ProjectPermissionCan>
|
||||
</div>
|
||||
<CertificatesTable handlePopUpOpen={handlePopUpOpen} />
|
||||
{useOldCertificateFlow ? (
|
||||
{isLegacyTemplatesEnabled ? (
|
||||
<CertificateModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
|
||||
) : (
|
||||
<CertificateIssuanceModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ export const PkiSubscriberSection = () => {
|
||||
const { subscription } = useSubscription();
|
||||
const projectId = currentProject.id;
|
||||
|
||||
const allowNewSubscriberCreation = subscription.pkiLegacyTemplates;
|
||||
const canCreateLegacySubscribers = subscription.pkiLegacyTemplates;
|
||||
const { mutateAsync: deletePkiSubscriber } = useDeletePkiSubscriber();
|
||||
const { mutateAsync: updatePkiSubscriber } = useUpdatePkiSubscriber();
|
||||
|
||||
@@ -104,7 +104,7 @@ export const PkiSubscriberSection = () => {
|
||||
/>
|
||||
</span>
|
||||
</a>
|
||||
{allowNewSubscriberCreation && (
|
||||
{canCreateLegacySubscribers && (
|
||||
<ProjectPermissionCan
|
||||
I={ProjectPermissionPkiSubscriberActions.Create}
|
||||
a={ProjectPermissionSub.PkiSubscribers}
|
||||
|
||||
+56
-40
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-nested-ternary */
|
||||
import { useCallback } from "react";
|
||||
import {
|
||||
faCheck,
|
||||
@@ -34,6 +33,59 @@ import { TCertificateProfile } from "@app/hooks/api/certificateProfiles";
|
||||
import { useGetCertificateTemplateV2ById } from "@app/hooks/api/certificateTemplates/queries";
|
||||
import { CertificateIssuanceModal } from "@app/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal";
|
||||
|
||||
const MetricsBadges = ({
|
||||
metrics
|
||||
}: {
|
||||
metrics?: {
|
||||
totalCertificates: number;
|
||||
activeCertificates: number;
|
||||
expiringCertificates: number;
|
||||
expiredCertificates: number;
|
||||
revokedCertificates: number;
|
||||
};
|
||||
}) => {
|
||||
if (!metrics) {
|
||||
return (
|
||||
<Badge variant="primary" className="text-xs">
|
||||
No metrics
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
|
||||
if (metrics.totalCertificates === 0) {
|
||||
return (
|
||||
<Badge variant="primary" className="text-xs">
|
||||
No certificates
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{metrics.activeCertificates > 0 && (
|
||||
<Badge variant="success" className="text-xs">
|
||||
{metrics.activeCertificates} active
|
||||
</Badge>
|
||||
)}
|
||||
{metrics.expiringCertificates > 0 && (
|
||||
<Badge variant="primary" className="text-xs">
|
||||
{metrics.expiringCertificates} expiring
|
||||
</Badge>
|
||||
)}
|
||||
{metrics.expiredCertificates > 0 && (
|
||||
<Badge variant="danger" className="text-xs">
|
||||
{metrics.expiredCertificates} expired
|
||||
</Badge>
|
||||
)}
|
||||
{metrics.revokedCertificates > 0 && (
|
||||
<Badge variant="danger" className="text-xs">
|
||||
{metrics.revokedCertificates} revoked
|
||||
</Badge>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
interface Props {
|
||||
profile: TCertificateProfile;
|
||||
onEditProfile: (profile: TCertificateProfile) => void;
|
||||
@@ -58,11 +110,8 @@ export const ProfileRow = ({ profile, onEditProfile, onDeleteProfile }: Props) =
|
||||
type: "info"
|
||||
});
|
||||
|
||||
const timer = setTimeout(() => setIsIdCopied.off(), 2000);
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
return () => clearTimeout(timer);
|
||||
}, [isIdCopied, setIsIdCopied]);
|
||||
setTimeout(() => setIsIdCopied.off(), 2000);
|
||||
}, [setIsIdCopied]);
|
||||
|
||||
const { data: templateData } = useGetCertificateTemplateV2ById({
|
||||
templateId: profile.certificateTemplateId
|
||||
@@ -122,40 +171,7 @@ export const ProfileRow = ({ profile, onEditProfile, onDeleteProfile }: Props) =
|
||||
</Td>
|
||||
<Td>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{profile.metrics ? (
|
||||
profile.metrics.totalCertificates === 0 ? (
|
||||
<Badge variant="primary" className="text-xs">
|
||||
No certificates
|
||||
</Badge>
|
||||
) : (
|
||||
<>
|
||||
{profile.metrics.activeCertificates > 0 && (
|
||||
<Badge variant="success" className="text-xs">
|
||||
{profile.metrics.activeCertificates} active
|
||||
</Badge>
|
||||
)}
|
||||
{profile.metrics.expiringCertificates > 0 && (
|
||||
<Badge variant="primary" className="text-xs">
|
||||
{profile.metrics.expiringCertificates} expiring
|
||||
</Badge>
|
||||
)}
|
||||
{profile.metrics.expiredCertificates > 0 && (
|
||||
<Badge variant="danger" className="text-xs">
|
||||
{profile.metrics.expiredCertificates} expired
|
||||
</Badge>
|
||||
)}
|
||||
{profile.metrics.revokedCertificates > 0 && (
|
||||
<Badge variant="danger" className="text-xs">
|
||||
{profile.metrics.revokedCertificates} revoked
|
||||
</Badge>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
) : (
|
||||
<Badge variant="primary" className="text-xs">
|
||||
No metrics
|
||||
</Badge>
|
||||
)}
|
||||
<MetricsBadges metrics={profile.metrics} />
|
||||
</div>
|
||||
</Td>
|
||||
<Td className="text-right">
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ import { createNotification } from "@app/components/notifications";
|
||||
import { Button, DeleteActionModal } from "@app/components/v2";
|
||||
import { useProjectPermission } from "@app/context";
|
||||
import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionPkiTemplateActions,
|
||||
ProjectPermissionSub
|
||||
} from "@app/context/ProjectPermissionContext/types";
|
||||
import { useDeleteCertificateTemplateV2New } from "@app/hooks/api/certificateTemplates/mutations";
|
||||
@@ -26,8 +26,8 @@ export const CertificateTemplatesV2Tab = () => {
|
||||
const deleteTemplateV2 = useDeleteCertificateTemplateV2New();
|
||||
|
||||
const canCreateTemplate = permission.can(
|
||||
ProjectPermissionActions.Create,
|
||||
ProjectPermissionSub.CertificateAuthorities
|
||||
ProjectPermissionPkiTemplateActions.Create,
|
||||
ProjectPermissionSub.CertificateTemplates
|
||||
);
|
||||
|
||||
const handleCreateTemplate = () => {
|
||||
|
||||
+4
@@ -42,6 +42,10 @@ export const TemplateList = ({ onEditTemplate, onDeleteTemplate }: Props) => {
|
||||
|
||||
const templates = data?.certificateTemplates || [];
|
||||
|
||||
if (!currentProject?.id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const canEditTemplate = permission.can(
|
||||
ProjectPermissionPkiTemplateActions.Edit,
|
||||
ProjectPermissionSub.CertificateTemplates
|
||||
|
||||
+1
-11
@@ -114,17 +114,7 @@ export const apiTemplateSchema = z.object({
|
||||
.object({
|
||||
max: z
|
||||
.string()
|
||||
.refine((val) => {
|
||||
if (!val) return true;
|
||||
if (val.length < 2 || val.length > 10) return false;
|
||||
|
||||
const lastChar = val.slice(-1);
|
||||
if (!["d", "h", "m", "y"].includes(lastChar)) return false;
|
||||
|
||||
const numberPart = val.slice(0, -1);
|
||||
const num = parseInt(numberPart, 10);
|
||||
return !Number.isNaN(num) && num > 0 && numberPart === num.toString();
|
||||
}, "Must be in format like '365d', '12m', '1y', or '24h'")
|
||||
.regex(/^[1-9]\d*[dhmy]$/, "Must be in format like '365d', '12m', '1y', or '24h'")
|
||||
.optional()
|
||||
})
|
||||
.optional()
|
||||
|
||||
Reference in New Issue
Block a user