mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 08:28:59 +00:00
add bypassers inactive state
This commit is contained in:
+14
-5
@@ -44,6 +44,7 @@ import { EnforcementLevel, PolicyType } from "@app/hooks/api/policies/enums";
|
|||||||
import { TWorkspaceUser } from "@app/hooks/api/users/types";
|
import { TWorkspaceUser } from "@app/hooks/api/users/types";
|
||||||
|
|
||||||
import { PolicyMemberOption } from "./PolicyMemberOption";
|
import { PolicyMemberOption } from "./PolicyMemberOption";
|
||||||
|
import { PolicyBypasserMemberOption } from "./PolicyBypasserMemberOption";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen?: boolean;
|
isOpen?: boolean;
|
||||||
@@ -64,7 +65,7 @@ const formSchema = z
|
|||||||
.object({
|
.object({
|
||||||
type: z.literal(ApproverType.User),
|
type: z.literal(ApproverType.User),
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
isOrgMembershipActive: z.boolean()
|
isOrgMembershipActive: z.boolean().optional().nullable()
|
||||||
})
|
})
|
||||||
.array()
|
.array()
|
||||||
.default([]),
|
.default([]),
|
||||||
@@ -73,7 +74,11 @@ const formSchema = z
|
|||||||
.array()
|
.array()
|
||||||
.default([]),
|
.default([]),
|
||||||
userBypassers: z
|
userBypassers: z
|
||||||
.object({ type: z.literal(BypasserType.User), id: z.string() })
|
.object({
|
||||||
|
type: z.literal(BypasserType.User),
|
||||||
|
id: z.string(),
|
||||||
|
isOrgMembershipActive: z.boolean().optional().nullable()
|
||||||
|
})
|
||||||
.array()
|
.array()
|
||||||
.default([]),
|
.default([]),
|
||||||
groupBypassers: z
|
groupBypassers: z
|
||||||
@@ -89,7 +94,7 @@ const formSchema = z
|
|||||||
.object({
|
.object({
|
||||||
type: z.literal(ApproverType.User),
|
type: z.literal(ApproverType.User),
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
isOrgMembershipActive: z.boolean()
|
isOrgMembershipActive: z.boolean().optional().nullable()
|
||||||
})
|
})
|
||||||
.array()
|
.array()
|
||||||
.default([]),
|
.default([]),
|
||||||
@@ -139,7 +144,7 @@ const Form = ({
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
watch,
|
watch,
|
||||||
resetField,
|
resetField,
|
||||||
formState: { isSubmitting }
|
formState: { isSubmitting, errors }
|
||||||
} = useForm<TFormSchema>({
|
} = useForm<TFormSchema>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
values: editValues
|
values: editValues
|
||||||
@@ -366,7 +371,8 @@ const Form = ({
|
|||||||
() =>
|
() =>
|
||||||
members.map((member) => ({
|
members.map((member) => ({
|
||||||
id: member.user.id,
|
id: member.user.id,
|
||||||
type: BypasserType.User
|
type: BypasserType.User,
|
||||||
|
isOrgMembershipActive: member.user.isOrgMembershipActive
|
||||||
})),
|
})),
|
||||||
[members]
|
[members]
|
||||||
);
|
);
|
||||||
@@ -409,6 +415,8 @@ const Form = ({
|
|||||||
setDragOverItem(null);
|
setDragOverItem(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("error", errors);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col space-y-3">
|
<div className="flex flex-col space-y-3">
|
||||||
<form onSubmit={handleSubmit(handleFormSubmit)}>
|
<form onSubmit={handleSubmit(handleFormSubmit)}>
|
||||||
@@ -804,6 +812,7 @@ const Form = ({
|
|||||||
menuPlacement="top"
|
menuPlacement="top"
|
||||||
isMulti
|
isMulti
|
||||||
placeholder="Select members..."
|
placeholder="Select members..."
|
||||||
|
components={{ Option: PolicyBypasserMemberOption }}
|
||||||
options={bypasserMemberOptions}
|
options={bypasserMemberOptions}
|
||||||
getOptionValue={(option) => option.id}
|
getOptionValue={(option) => option.id}
|
||||||
getOptionLabel={(option) => {
|
getOptionLabel={(option) => {
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
import { components, OptionProps } from "react-select";
|
||||||
|
import { faCheckCircle } from "@fortawesome/free-regular-svg-icons";
|
||||||
|
import { faBan } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import { Badge } from "@app/components/v2";
|
||||||
|
import { BypasserType } from "@app/hooks/api/accessApproval/types";
|
||||||
|
|
||||||
|
export const PolicyBypasserMemberOption = ({
|
||||||
|
isSelected,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: OptionProps<{
|
||||||
|
id: string;
|
||||||
|
type: BypasserType;
|
||||||
|
isOrgMembershipActive?: boolean;
|
||||||
|
}>) => {
|
||||||
|
return (
|
||||||
|
<components.Option isSelected={isSelected} {...props}>
|
||||||
|
<div className="flex flex-row items-center justify-between">
|
||||||
|
<p
|
||||||
|
className={twMerge("truncate", !props.data.isOrgMembershipActive && "text-mineshaft-400")}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</p>
|
||||||
|
{!props.data.isOrgMembershipActive && (
|
||||||
|
<Badge className="pointer-events-none ml-1 mr-auto flex h-5 w-min items-center gap-1.5 whitespace-nowrap bg-mineshaft-400/50 text-bunker-300">
|
||||||
|
<FontAwesomeIcon icon={faBan} />
|
||||||
|
Inactive
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
{isSelected && (
|
||||||
|
<FontAwesomeIcon className="ml-2 text-primary" icon={faCheckCircle} size="sm" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</components.Option>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user