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