feat(secret-approval): updated names to secret policy and fixed approval number bug

This commit is contained in:
Akhil Mohan
2023-09-28 12:23:01 +05:30
parent c67432a56f
commit b0c398688b
11 changed files with 54 additions and 37 deletions
@@ -10,7 +10,7 @@ export type TSecretApprovalPolicy = {
export type TCreateSecretPolicyDTO = {
workspaceId: string;
environment: string;
secretPath?: string;
secretPath?: string | null;
approvers?: string[];
approvals?: number;
};
@@ -18,7 +18,7 @@ export type TCreateSecretPolicyDTO = {
export type TUpdateSecretPolicyDTO = {
id: string;
approvers?: string[];
secretPath?: string;
secretPath?: string | null;
approvals?: number;
// for invalidating list
workspaceId: string;
@@ -1,14 +1,16 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { faFileShield, faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
import {
Button,
DeleteActionModal,
EmptyState,
Table,
TableContainer,
TableSkeleton,
TBody,
Td,
Th,
THead,
Tr
@@ -96,6 +98,11 @@ export const SecretApprovalPolicyList = ({ workspaceId }: Props) => {
{isPoliciesLoading && (
<TableSkeleton columns={4} innerKey="secret-policies" className="bg-mineshaft-700" />
)}
{!isPoliciesLoading && !policies?.length && (
<Td colSpan={5}>
<EmptyState title="No policies found" icon={faFileShield} />
</Td>
)}
{policies?.map((policy) => (
<SecretApprovalPolicyRow
workspaceId={workspaceId}
@@ -35,7 +35,7 @@ type Props = {
const formSchema = z.object({
environment: z.string(),
secretPath: z.string().optional(),
secretPath: z.string().optional().nullable(),
approvals: z.number().min(1),
approvers: z.string().array().optional()
});
@@ -97,7 +97,7 @@ export const SecretPolicyForm = ({
await updateSecretApprovalPolicy({
id: editValues?._id,
...data,
secretPath: data.secretPath ?? "-",
secretPath: data.secretPath || null,
workspaceId
});
createNotification({
@@ -159,7 +159,7 @@ export const SecretPolicyForm = ({
name="secretPath"
render={({ field, fieldState: { error } }) => (
<FormControl label="Secret Path" isError={Boolean(error)} errorText={error?.message}>
<Input {...field} />
<Input {...field} value={field.value || ""} />
</FormControl>
)}
/>
@@ -220,7 +220,11 @@ export const SecretPolicyForm = ({
isError={Boolean(error)}
errorText={error?.message}
>
<Input {...field} type="number" />
<Input
{...field}
type="number"
onChange={(el) => field.onChange(parseInt(el.target.value, 10))}
/>
</FormControl>
)}
/>