feat(secret-approval): added auto naming policy and minor ux enhancements

This commit is contained in:
Akhil Mohan
2023-10-05 20:34:50 +05:30
parent 4fd227c85f
commit 9dc97f7208
13 changed files with 94 additions and 30 deletions
@@ -87,6 +87,7 @@ export const SecretApprovalPolicyList = ({ workspaceId }: Props) => {
<Table>
<THead>
<Tr>
<Th>Name</Th>
<Th>Environment</Th>
<Th>Secret Path</Th>
<Th>Eligible Approvers</Th>
@@ -38,6 +38,7 @@ export const SecretApprovalPolicyRow = ({
return (
<Tr>
<Td>{policy.name}</Td>
<Td>{policy.environment}</Td>
<Td>{policy.secretPath || "*"}</Td>
<Td>
@@ -33,12 +33,18 @@ type Props = {
editValues?: TSecretApprovalPolicy;
};
const formSchema = z.object({
environment: z.string(),
secretPath: z.string().optional().nullable(),
approvals: z.number().min(1),
approvers: z.string().array().optional()
});
const formSchema = z
.object({
environment: z.string(),
name: z.string().optional(),
secretPath: z.string().optional().nullable(),
approvals: z.number().min(1),
approvers: z.string().array().min(1)
})
.refine((data) => data.approvals <= data.approvers.length, {
path: ["approvals"],
message: "Approvals should be lower than approvals"
});
type TFormSchema = z.infer<typeof formSchema>;
@@ -126,6 +132,15 @@ export const SecretPolicyForm = ({
<Modal isOpen={isOpen} onOpenChange={onToggle}>
<ModalContent title={isEditMode ? "Edit policy" : "Create policy"}>
<form onSubmit={handleSubmit(handleFormSubmit)}>
<Controller
control={control}
name="name"
render={({ field, fieldState: { error } }) => (
<FormControl label="Policy Name" isError={Boolean(error)} errorText={error?.message}>
<Input {...field} value={field.value || ""} />
</FormControl>
)}
/>
<Controller
control={control}
name="environment"