mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 16:27:46 +00:00
Fix: Creation of secret approval policies
This commit is contained in:
@@ -9,7 +9,15 @@ export const useCreateSecretApprovalPolicy = () => {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation<{}, {}, TCreateSecretPolicyDTO>({
|
return useMutation<{}, {}, TCreateSecretPolicyDTO>({
|
||||||
mutationFn: async ({ environment, workspaceId, approvals, approvers, secretPath, name, enforcementLevel }) => {
|
mutationFn: async ({
|
||||||
|
environment,
|
||||||
|
workspaceId,
|
||||||
|
approvals,
|
||||||
|
approvers,
|
||||||
|
secretPath,
|
||||||
|
name,
|
||||||
|
enforcementLevel
|
||||||
|
}) => {
|
||||||
const { data } = await apiRequest.post("/api/v1/secret-approvals", {
|
const { data } = await apiRequest.post("/api/v1/secret-approvals", {
|
||||||
environment,
|
environment,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
|
|||||||
+4
-5
@@ -45,11 +45,11 @@ const formSchema = z
|
|||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
secretPath: z.string().optional(),
|
secretPath: z.string().optional(),
|
||||||
approvals: z.number().min(1),
|
approvals: z.number().min(1),
|
||||||
approverUserIds: z.string().array().min(1),
|
approvers: z.string().array().min(1),
|
||||||
policyType: z.nativeEnum(PolicyType),
|
policyType: z.nativeEnum(PolicyType),
|
||||||
enforcementLevel: z.nativeEnum(EnforcementLevel)
|
enforcementLevel: z.nativeEnum(EnforcementLevel)
|
||||||
})
|
})
|
||||||
.refine((data) => data.approvals <= data.approverUserIds.length, {
|
.refine((data) => data.approvals <= data.approvers.length, {
|
||||||
path: ["approvals"],
|
path: ["approvals"],
|
||||||
message: "The number of approvals should be lower than the number of approvers."
|
message: "The number of approvals should be lower than the number of approvers."
|
||||||
});
|
});
|
||||||
@@ -75,8 +75,7 @@ export const AccessPolicyForm = ({
|
|||||||
? {
|
? {
|
||||||
...editValues,
|
...editValues,
|
||||||
environment: editValues.environment.slug,
|
environment: editValues.environment.slug,
|
||||||
approverUserIds:
|
approvers: editValues?.userApprovers?.map((user) => user.userId) || editValues?.approvers
|
||||||
editValues?.userApprovers?.map((user) => user.userId) || editValues?.approvers
|
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
});
|
});
|
||||||
@@ -264,7 +263,7 @@ export const AccessPolicyForm = ({
|
|||||||
/>
|
/>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="approverUserIds"
|
name="approvers"
|
||||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
label="Required Approvers"
|
label="Required Approvers"
|
||||||
|
|||||||
Reference in New Issue
Block a user