import { faFileShield, faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, EmptyState, Modal, ModalContent, Table, TableContainer, TableSkeleton, TBody, Td, Th, THead, Tr, UpgradePlanModal } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission, useSubscription } from "@app/context"; import { usePopUp } from "@app/hooks"; import { useDeleteSecretApprovalPolicy, useGetSecretApprovalPolicies, useGetWorkspaceUsers } from "@app/hooks/api"; import { TSecretApprovalPolicy } from "@app/hooks/api/types"; import { SecretApprovalPolicyRow } from "./components/SecretApprovalPolicyRow"; import { SecretPolicyForm } from "./components/SecretPolicyForm"; type Props = { workspaceId: string; }; export const SecretApprovalPolicyList = ({ workspaceId }: Props) => { const { handlePopUpToggle, handlePopUpOpen, handlePopUpClose, popUp } = usePopUp([ "secretPolicyForm", "deletePolicy", "upgradePlan" ] as const); const { permission } = useProjectPermission(); const { subscription } = useSubscription(); const { data: members } = useGetWorkspaceUsers(workspaceId); const { data: policies, isLoading: isPoliciesLoading } = useGetSecretApprovalPolicies({ workspaceId, options: { enabled: permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval) } }); const { mutateAsync: deleteSecretApprovalPolicy } = useDeleteSecretApprovalPolicy(); const handleDeletePolicy = async () => { const { id } = popUp.deletePolicy.data as TSecretApprovalPolicy; try { await deleteSecretApprovalPolicy({ workspaceId, id }); createNotification({ type: "success", text: "Successfully deleted policy" }); handlePopUpClose("deletePolicy"); } catch (err) { console.log(err); createNotification({ type: "error", text: "Failed to delete policy" }); } }; return (
Approval Policies
Implement policies to prevent unauthorized secret changes.
{(isAllowed) => ( )}
{isPoliciesLoading && ( )} {!isPoliciesLoading && !policies?.length && ( )} {policies?.map((policy) => ( handlePopUpOpen("secretPolicyForm", policy)} onDelete={() => handlePopUpOpen("deletePolicy", policy)} /> ))}
Name Environment Secret Path Eligible Approvers Approval Required
handlePopUpToggle("secretPolicyForm", isOpen)} > handlePopUpToggle("secretPolicyForm", isOpen)} members={members} editValues={popUp.secretPolicyForm.data as TSecretApprovalPolicy} /> handlePopUpToggle("deletePolicy", isOpen)} onDeleteApproved={handleDeletePolicy} /> handlePopUpToggle("upgradePlan", isOpen)} text="You can add secret approval policy if you switch to Infisical's Enterprise plan." />
); };