From 0f74a1a011ccf3dec5f719a6bdf79af5b47aeffd Mon Sep 17 00:00:00 2001 From: = Date: Tue, 1 Oct 2024 20:52:18 +0530 Subject: [PATCH] feat: updated layout and fixed item not getting removed --- .../RolePermissionsSection.tsx | 121 +++++++------ .../components/GeneralPermissionOptions.tsx | 165 ++++++++---------- .../components/SecretPermissionConditions.tsx | 8 +- 3 files changed, 141 insertions(+), 153 deletions(-) diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx index d906a19fa..7e37e076c 100644 --- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx +++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx @@ -2,9 +2,10 @@ import { FormProvider, useForm } from "react-hook-form"; import { faCancel, faPlus, faSave } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; +import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; -import { Button, Modal, ModalContent, ModalTrigger, Spinner } from "@app/components/v2"; +import { Button, IconButton, Modal, ModalContent, ModalTrigger, Tooltip } from "@app/components/v2"; import { ProjectPermissionSub, useWorkspace } from "@app/context"; import { usePopUp } from "@app/hooks"; import { useGetProjectRoleBySlug, useUpdateProjectRole } from "@app/hooks/api"; @@ -78,67 +79,73 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
{isCustomRole && ( <> - - + {isDirty && ( + + )} +
+ + handlePopUpToggle("createPolicy", isOpen)} + > + + + + + + + + + handlePopUpToggle("createPolicy")} /> + + +
)}
- {isSubmitting ? ( -
- -

Saving your policy.

-
- ) : ( - <> -
- {!isLoading && } - {(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => ( - - {subject === ProjectPermissionSub.Secrets ? ( - - ) : undefined} - - ))} -
- handlePopUpToggle("createPolicy", isOpen)} +
+ {!isLoading && } + {(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => ( + - - - - - handlePopUpToggle("createPolicy")} /> - - - - )} + {subject === ProjectPermissionSub.Secrets ? ( + + ) : undefined} + + ))} +
); diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx index 3dc4dcb86..cdf0f5151 100644 --- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx +++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx @@ -2,7 +2,7 @@ import { cloneElement } from "react"; import { Controller, useFieldArray, useFormContext } from "react-hook-form"; import { faChevronDown, faChevronRight, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { AnimatePresence, motion } from "framer-motion"; +import { twMerge } from "tailwind-merge"; import { Button, Checkbox, Tag } from "@app/components/v2"; import { ProjectPermissionSub } from "@app/context"; @@ -59,94 +59,81 @@ export const GeneralPermissionOptions = )} - - {isOpen && ( - - - {items.fields.map((el, rootIndex) => ( - -
-
Actions
-
- {actions.map(({ label, value }) => { - if (typeof value !== "string") return undefined; - return ( - ( -
- - {label} - -
- )} - /> - ); - })} -
-
- {children && - cloneElement(children, { - position: rootIndex - })} -
- {!isDisabled && subject === ProjectPermissionSub.Secrets && ( - - )} - {!isDisabled && ( - - )}{" "} -
-
- ))} -
-
- )} -
+ {isOpen && ( +
+ {items.fields.map((el, rootIndex) => ( +
+
+
Actions
+
+ {actions.map(({ label, value }) => { + if (typeof value !== "string") return undefined; + return ( + ( +
+ + {label} + +
+ )} + /> + ); + })} +
+
+ {children && + cloneElement(children, { + position: rootIndex + })} +
+ {!isDisabled && subject === ProjectPermissionSub.Secrets && ( + + )} + {!isDisabled && ( + + )}{" "} +
+
+ ))} +
+ )} ); }; diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx index 54b1c49af..38f60cc71 100644 --- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx +++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/SecretPermissionConditions.tsx @@ -1,7 +1,6 @@ import { Controller, useFieldArray, useFormContext } from "react-hook-form"; import { faPlus, faTrash, faWarning } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { twMerge } from "tailwind-merge"; import { Button, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2"; import { PermissionConditionOperators } from "@app/context/ProjectPermissionContext/types"; @@ -31,12 +30,7 @@ export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props) }); return ( -
+
{items.fields.map((el, index) => { const lhs = watch(`permissions.secrets.${position}.conditions.${index}.lhs`);