import { useState } from "react"; import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { createNotification } from "@app/components/notifications"; import { Button, DeleteActionModal } from "@app/components/v2"; import { useProjectPermission } from "@app/context"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context/ProjectPermissionContext/types"; import { TCertificateProfileWithDetails, useDeleteCertificateProfile } from "@app/hooks/api/certificateProfiles"; import { CreateProfileModal } from "./CreateProfileModal"; import { ProfileList } from "./ProfileList"; export const CertificateProfilesTab = () => { const { permission } = useProjectPermission(); const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const [isEditModalOpen, setIsEditModalOpen] = useState(false); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [selectedProfile, setSelectedProfile] = useState( null ); const deleteProfile = useDeleteCertificateProfile(); const canCreateProfile = permission.can( ProjectPermissionActions.Create, ProjectPermissionSub.CertificateAuthorities ); const handleCreateProfile = () => { setIsCreateModalOpen(true); }; const handleEditProfile = (profile: TCertificateProfileWithDetails) => { setSelectedProfile(profile); setIsEditModalOpen(true); }; const handleDeleteProfile = (profile: TCertificateProfileWithDetails) => { setSelectedProfile(profile); setIsDeleteModalOpen(true); }; const handleDeleteConfirm = async () => { if (!selectedProfile) return; try { await deleteProfile.mutateAsync({ profileId: selectedProfile.id }); setIsDeleteModalOpen(false); setSelectedProfile(null); createNotification({ text: `Certificate profile "${selectedProfile.slug}" deleted successfully`, type: "success" }); } catch (error) { console.error( `Failed to delete profile "${selectedProfile.slug}" (ID: ${selectedProfile.id}):`, error ); } }; return (

Certificate Profiles

Unified certificate issuance configurations combining CA, template, and enrollment method

{canCreateProfile && ( )}
setIsCreateModalOpen(false)} /> {selectedProfile && ( <> { setIsEditModalOpen(false); setSelectedProfile(null); }} profile={selectedProfile} mode="edit" /> { setIsDeleteModalOpen(isOpen); if (!isOpen) { setSelectedProfile(null); } }} deleteKey={selectedProfile.slug} onDeleteApproved={handleDeleteConfirm} /> )}
); };