import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context"; import { CaStatus, CaType, useDeleteCa, useUpdateCa } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; import { ExternalCaModal } from "./ExternalCaModal"; import { ExternalCaTable } from "./ExternalCaTable"; export const ExternalCaSection = () => { const { currentProject } = useProject(); const { mutateAsync: deleteCa } = useDeleteCa(); const { mutateAsync: updateCa } = useUpdateCa(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "ca", "deleteCa", "caStatus", // enable / disable "upgradePlan" ] as const); const onRemoveCaSubmit = async (caName: string, type: CaType) => { try { if (!currentProject?.id) return; await deleteCa({ caName, type, projectId: currentProject.id }); createNotification({ text: "Successfully deleted CA", type: "success" }); handlePopUpClose("deleteCa"); } catch { createNotification({ text: "Failed to delete CA", type: "error" }); } }; const onUpdateCaStatus = async ({ name, type, status }: { name: string; type: CaType; status: CaStatus; }) => { try { if (!currentProject?.slug) return; await updateCa({ caName: name, type, status, projectId: currentProject.id }); createNotification({ text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`, type: "success" }); handlePopUpClose("caStatus"); } catch (err) { console.error(err); createNotification({ text: `Failed to ${status === CaStatus.ACTIVE ? "enable" : "disable"} CA`, type: "error" }); } }; return (
External Certificate Authorities