mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat(frontend): add enforcementLevel into SecretPolicy
This commit is contained in:
@@ -9,14 +9,15 @@ export const useCreateSecretApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TCreateSecretPolicyDTO>({
|
||||
mutationFn: async ({ environment, workspaceId, approvals, approvers, secretPath, name }) => {
|
||||
mutationFn: async ({ environment, workspaceId, approvals, approvers, secretPath, name, enforcementLevel }) => {
|
||||
const { data } = await apiRequest.post("/api/v1/secret-approvals", {
|
||||
environment,
|
||||
workspaceId,
|
||||
approvals,
|
||||
approvers,
|
||||
secretPath,
|
||||
name
|
||||
name,
|
||||
enforcementLevel
|
||||
});
|
||||
return data;
|
||||
},
|
||||
@@ -30,12 +31,13 @@ export const useUpdateSecretApprovalPolicy = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSecretPolicyDTO>({
|
||||
mutationFn: async ({ id, approvers, approvals, secretPath, name }) => {
|
||||
mutationFn: async ({ id, approvers, approvals, secretPath, name, enforcementLevel }) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/secret-approvals/${id}`, {
|
||||
approvals,
|
||||
approvers,
|
||||
secretPath,
|
||||
name
|
||||
name,
|
||||
enforcementLevel
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { EnforcementLevel } from "../policies/enums";
|
||||
import { WorkspaceEnv } from "../workspace/types";
|
||||
|
||||
export type TSecretApprovalPolicy = {
|
||||
@@ -29,6 +30,7 @@ export type TCreateSecretPolicyDTO = {
|
||||
secretPath?: string | null;
|
||||
approvers?: string[];
|
||||
approvals?: number;
|
||||
enforcementLevel: EnforcementLevel;
|
||||
};
|
||||
|
||||
export type TUpdateSecretPolicyDTO = {
|
||||
@@ -37,6 +39,7 @@ export type TUpdateSecretPolicyDTO = {
|
||||
approvers?: string[];
|
||||
secretPath?: string | null;
|
||||
approvals?: number;
|
||||
enforcementLevel?: EnforcementLevel;
|
||||
// for invalidating list
|
||||
workspaceId: string;
|
||||
};
|
||||
|
||||
@@ -143,12 +143,12 @@ export const AccessPolicyForm = ({
|
||||
...data,
|
||||
projectSlug
|
||||
});
|
||||
createNotification({
|
||||
type: "success",
|
||||
text: "Successfully updated policy"
|
||||
});
|
||||
onToggle(false);
|
||||
}
|
||||
createNotification({
|
||||
type: "success",
|
||||
text: "Successfully updated policy"
|
||||
});
|
||||
onToggle(false);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
createNotification({
|
||||
|
||||
@@ -18,7 +18,7 @@ import { Badge } from "@app/components/v2/Badge";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context";
|
||||
import { policyDetails } from "@app/helpers/policies";
|
||||
import { useUpdateAccessApprovalPolicy, useUpdateSecretApprovalPolicy } from "@app/hooks/api";
|
||||
import { PolicyType } from "@app/hooks/api/policies/enums";
|
||||
import { EnforcementLevel, PolicyType } from "@app/hooks/api/policies/enums";
|
||||
import { WorkspaceEnv } from "@app/hooks/api/types";
|
||||
import { TWorkspaceUser } from "@app/hooks/api/users/types";
|
||||
|
||||
@@ -33,6 +33,7 @@ interface IPolicy {
|
||||
userApprovers?: { userId: string }[];
|
||||
updatedAt: Date;
|
||||
policyType: PolicyType;
|
||||
enforcementLevel: EnforcementLevel;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
@@ -75,11 +76,7 @@ export const ApprovalPolicyRow = ({
|
||||
id: policy.id,
|
||||
approvers: selectedApprovers
|
||||
},
|
||||
{
|
||||
onSettled: () => {
|
||||
// No changes needed here
|
||||
}
|
||||
}
|
||||
{ onSettled: () => {} }
|
||||
);
|
||||
} else {
|
||||
updateSecretApprovalPolicy(
|
||||
@@ -88,11 +85,7 @@ export const ApprovalPolicyRow = ({
|
||||
id: policy.id,
|
||||
approvers: selectedApprovers
|
||||
},
|
||||
{
|
||||
onSettled: () => {
|
||||
// No changes needed here
|
||||
}
|
||||
}
|
||||
{ onSettled: () => {} }
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user