/* eslint-disable @typescript-eslint/no-unused-vars */ import { useRouter } from "next/router"; import { faChevronLeft, faEllipsis } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { withProjectPermission } from "@app/hoc"; import { useDeleteSshCa, useGetSshCaById } from "@app/hooks/api"; import { ProjectType } from "@app/hooks/api/workspace/types"; import { usePopUp } from "@app/hooks/usePopUp"; import { SshCaModal } from "../SshPage/components/SshCaModal"; import { SshCaDetailsSection, SshCertificateTemplatesSection } from "./components"; export const SshCaPage = withProjectPermission( () => { const { currentWorkspace } = useWorkspace(); const projectId = currentWorkspace?.id || ""; const router = useRouter(); const caId = router.query.caId as string; const { data } = useGetSshCaById(caId); const { mutateAsync: deleteSshCa } = useDeleteSshCa(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "sshCa", "deleteSshCa" ] as const); const onRemoveCaSubmit = async (caIdToDelete: string) => { try { if (!projectId) return; await deleteSshCa({ caId: caIdToDelete }); await createNotification({ text: "Successfully deleted SSH CA", type: "success" }); handlePopUpClose("deleteSshCa"); router.push(`/project/${projectId}/ssh`); } catch (err) { console.error(err); createNotification({ text: "Failed to delete SSH CA", type: "error" }); } }; return (
{data && (

{data.friendlyName}

{(isAllowed) => ( handlePopUpOpen("deleteSshCa", { caId: data.id }) } disabled={!isAllowed} > Delete SSH CA )}
)} handlePopUpToggle("deleteSshCa", isOpen)} deleteKey="confirm" onDeleteApproved={() => onRemoveCaSubmit((popUp?.deleteSshCa?.data as { caId: string })?.caId) } />
); }, { action: ProjectPermissionActions.Read, subject: ProjectPermissionSub.SshCertificateAuthorities } );