import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useSubscription, useWorkspace } from "@app/context"; import { useDeleteTrustedIp } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; import { IPAllowlistModal } from "./IPAllowlistModal"; import { IPAllowlistTable } from "./IPAllowlistTable"; export const IPAllowlistSection = () => { const { createNotification } = useNotificationContext(); const { mutateAsync } = useDeleteTrustedIp(); const { subscription } = useSubscription(); const { currentWorkspace } = useWorkspace(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "trustedIp", "deleteTrustedIp", "upgradePlan" ] as const); const onDeleteTrustedIpSubmit = async (trustedIpId: string) => { try { if (!currentWorkspace?.id) return; await mutateAsync({ workspaceId: currentWorkspace.id, trustedIpId }); createNotification({ text: "Successfully deleted IP access range", type: "success" }); handlePopUpClose("deleteTrustedIp"); } catch (err) { console.log(err); createNotification({ text: "Failed to delete IP access range", type: "error" }); } }; return (

IP Allowlist

{(isAllowed) => ( )}
handlePopUpToggle("deleteTrustedIp", isOpen)} deleteKey="confirm" onDeleteApproved={() => onDeleteTrustedIpSubmit( (popUp?.deleteTrustedIp?.data as { trustedIpId: string })?.trustedIpId ) } /> handlePopUpToggle("upgradePlan", isOpen)} text="You can use IP allowlisting if you switch to Infisical's Pro plan." />
); };