From fd7d8ddf2d2b3b4c82e96e77a187193331fc73c1 Mon Sep 17 00:00:00 2001 From: Meet Date: Mon, 23 Sep 2024 20:59:05 +0530 Subject: [PATCH] fix: group selection on create policy --- .../components/AccessPolicyModal.tsx | 211 +++++++++--------- 1 file changed, 106 insertions(+), 105 deletions(-) diff --git a/frontend/src/views/SecretApprovalPage/components/ApprovalPolicyList/components/AccessPolicyModal.tsx b/frontend/src/views/SecretApprovalPage/components/ApprovalPolicyList/components/AccessPolicyModal.tsx index f2da72603..b0ec53acc 100644 --- a/frontend/src/views/SecretApprovalPage/components/ApprovalPolicyList/components/AccessPolicyModal.tsx +++ b/frontend/src/views/SecretApprovalPage/components/ApprovalPolicyList/components/AccessPolicyModal.tsx @@ -255,115 +255,14 @@ export const AccessPolicyForm = ({ name="secretPath" render={({ field, fieldState: { error } }) => ( )} - /> - ( - - - - - - - - Select members that are allowed to approve requests - - {members.map(({ user }) => { - const { id: userId } = user; - const isChecked = value?.filter((el: {id: string, type: ApproverType}) => el.id === userId && el.type === ApproverType.User).length > 0; - return ( - { - evt.preventDefault(); - onChange( - isChecked - ? value?.filter((el: {id: string, type: ApproverType}) => el.id !== userId && el.type !== ApproverType.User) - : [...(value || []), {id:userId, type: ApproverType.User}] - ); - }} - key={`create-policy-members-${userId}`} - iconPos="right" - icon={isChecked && } - > - {user.username} - - ); - })} - - - - )} - /> - ( - - - - - - - - Select groups that are allowed to approve requests - - {groups && groups.map(({ group }) => { - const { id } = group; - const isChecked = value?.includes({id, type: ApproverType.Group}); - - return ( - { - evt.preventDefault(); - onChange( - isChecked - ? value?.filter((el: {id: string, type: ApproverType}) => el.id !== id && el.type !== ApproverType.Group) - : [...(value || []), {id, type: ApproverType.Group}] - ); - }} - key={`create-policy-members-${id}`} - iconPos="right" - icon={isChecked && } - > - {group.name} - - ); - })} - - - - )} - /> + /> )} /> +

Approvers

+ ( + + + + e.type=== ApproverType.User).length ? `${value.filter((e) => e.type=== ApproverType.User).length} selected` : "None"} + className="text-left" + /> + + + + Select members that are allowed to approve requests + + {members.map(({ user }) => { + const { id: userId } = user; + const isChecked = value?.filter((el: {id: string, type: ApproverType}) => el.id === userId && el.type === ApproverType.User).length > 0; + return ( + { + evt.preventDefault(); + onChange( + isChecked + ? value?.filter((el: {id: string, type: ApproverType}) => el.id !== userId && el.type !== ApproverType.User) + : [...(value || []), {id:userId, type: ApproverType.User}] + ); + }} + key={`create-policy-members-${userId}`} + iconPos="right" + icon={isChecked && } + > + {user.username} + + ); + })} + + + + )} + /> + ( + + + + e.type=== ApproverType.Group).length ? `${value?.filter((e) => e.type=== ApproverType.Group).length} selected` : "None"} + className="text-left" + /> + + + + Select groups that are allowed to approve requests + + {groups && groups.map(({ group }) => { + const { id } = group; + const isChecked = value?.filter((el: {id: string, type: ApproverType}) => el.id === id && el.type === ApproverType.Group).length > 0; + + return ( + { + evt.preventDefault(); + onChange( + isChecked + ? value?.filter((el: {id: string, type: ApproverType}) => el.id !== id && el.type !== ApproverType.Group) + : [...(value || []), {id, type: ApproverType.Group}] + ); + }} + key={`create-policy-members-${id}`} + iconPos="right" + icon={isChecked && } + > + {group.name} + + ); + })} + + + + )} + />