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 { PermissionDeniedBanner, ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useProject, useProjectPermission, useSubscription } from "@app/context"; import { useDeleteWsEnvironment } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; import { AddEnvironmentModal } from "./AddEnvironmentModal"; import { EnvironmentTable } from "./EnvironmentTable"; import { UpdateEnvironmentModal } from "./UpdateEnvironmentModal"; export const EnvironmentSection = () => { const { subscription } = useSubscription(); const { currentProject } = useProject(); const { permission } = useProjectPermission(); const deleteWsEnvironment = useDeleteWsEnvironment(); const isMoreEnvironmentsAllowed = subscription?.environmentLimit && currentProject?.environments ? currentProject.environments.length < subscription.environmentLimit : true; const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "createEnv", "updateEnv", "deleteEnv", "upgradePlan" ] as const); const onEnvDeleteSubmit = async (id: string) => { try { if (!currentProject?.id) return; await deleteWsEnvironment.mutateAsync({ projectId: currentProject.id, id }); createNotification({ text: "Successfully deleted environment", type: "success" }); handlePopUpClose("deleteEnv"); } catch (err) { console.error(err); createNotification({ text: "Failed to delete environment", type: "error" }); } }; return (

Environments

{(isAllowed) => ( )}

Choose which environments will show up in your dashboard like development, staging, production

{permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.Environments) ? ( ) : ( )} handlePopUpToggle("createEnv", isOpen)} /> handlePopUpToggle("deleteEnv", isOpen)} deleteKey={(popUp?.deleteEnv?.data as { slug: string })?.slug || ""} onDeleteApproved={() => onEnvDeleteSubmit((popUp?.deleteEnv?.data as { id: string })?.id)} /> handlePopUpToggle("upgradePlan", isOpen)} text="You have reached the maximum number of environments allowed on the free plan. Upgrade to Infisical Pro plan to add more environments." />
); };