From 22878a035be2132ec14f63b1f82a4be439869d65 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Fri, 19 Jul 2024 15:24:21 +0700 Subject: [PATCH] Continue RolePermissionsTable --- .../src/ee/services/license/licence-fns.ts | 2 +- .../RolePermissionsSection.tsx | 93 +++++++++++++++++++ .../RolePermissionsTable.tsx | 62 +++++++++++++ .../RolePermissionsSection/index.tsx | 1 + 4 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx create mode 100644 frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsTable.tsx create mode 100644 frontend/src/views/Org/RolePage/components/RolePermissionsSection/index.tsx diff --git a/backend/src/ee/services/license/licence-fns.ts b/backend/src/ee/services/license/licence-fns.ts index 3e30276cb..8da8afd39 100644 --- a/backend/src/ee/services/license/licence-fns.ts +++ b/backend/src/ee/services/license/licence-fns.ts @@ -32,7 +32,7 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({ oidcSSO: false, scim: false, ldap: false, - groups: false, + groups: true, status: null, trial_end: null, has_used_trial: true, diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx new file mode 100644 index 000000000..4346bce3b --- /dev/null +++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx @@ -0,0 +1,93 @@ +import { faPlus } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +// import { createNotification } from "@app/components/notifications"; +import { + // DeleteActionModal, + IconButton +} from "@app/components/v2"; +// import { useDeleteIdentityFromWorkspace } from "@app/hooks/api"; +// import { usePopUp } from "@app/hooks/usePopUp"; + +// import { IdentityAddToProjectModal } from "./IdentityAddToProjectModal"; +// import { IdentityProjectsTable } from "./IdentityProjectsTable"; + +export const RolePermissionsSesction = () => { + // const { mutateAsync: deleteMutateAsync } = useDeleteIdentityFromWorkspace(); + + // const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ + // "addIdentityToProject", + // "removeIdentityFromProject" + // ] as const); + + // const onRemoveIdentitySubmit = async (id: string, projectId: string) => { + // try { + // await deleteMutateAsync({ + // identityId: id, + // workspaceId: projectId + // }); + + // createNotification({ + // text: "Successfully removed identity from project", + // type: "success" + // }); + + // handlePopUpClose("removeIdentityFromProject"); + // } catch (err) { + // console.error(err); + // const error = err as any; + // const text = error?.response?.data?.message ?? "Failed to remove identity from project"; + + // createNotification({ + // text, + // type: "error" + // }); + // } + // }; + + return ( +
+
+

Permissions

+ { + console.log("TODO"); + // handlePopUpOpen("addIdentityToProject"); + }} + > + + +
+
+ Permissions Table + {/* */} +
+ {/* handlePopUpToggle("removeIdentityFromProject", isOpen)} + deleteKey="confirm" + onDeleteApproved={() => { + const popupData = popUp?.removeIdentityFromProject?.data as { + identityId: string; + projectId: string; + }; + + return onRemoveIdentitySubmit(popupData.identityId, popupData.projectId); + }} + /> */} + {/* */} +
+ ); +}; diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsTable.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsTable.tsx new file mode 100644 index 000000000..8cf3b857d --- /dev/null +++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsTable.tsx @@ -0,0 +1,62 @@ +import { faKey } from "@fortawesome/free-solid-svg-icons"; + +import { + EmptyState, + Table, + TableContainer, + TableSkeleton, + TBody, + Th, + THead, + Tr +} from "@app/components/v2"; +import { useGetIdentityProjectMemberships } from "@app/hooks/api"; +// import { UsePopUpState } from "@app/hooks/usePopUp"; + +// import { IdentityProjectRow } from "./IdentityProjectRow"; + +type Props = { + identityId: string; + // handlePopUpOpen: ( + // popUpName: keyof UsePopUpState<["removeIdentityFromProject"]>, + // data?: {} + // ) => void; +}; + +export const IdentityProjectsTable = ({ + identityId +}: // handlePopUpOpen +Props) => { + const { data: projectMemberships, isLoading } = useGetIdentityProjectMemberships(identityId); + return ( + + + + + + + + + + + {isLoading && } + {!isLoading && + projectMemberships?.map((membership) => { + return ( +
Row
+ // + ); + })} +
+
NameRoleAdded On +
+ {!isLoading && !projectMemberships?.length && ( + + )} +
+ ); +}; diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/index.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/index.tsx new file mode 100644 index 000000000..9a451ebef --- /dev/null +++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/index.tsx @@ -0,0 +1 @@ +export { RolePermissionsSesction } from "./RolePermissionsSection";