diff --git a/app/client/src/pages/organization/settings.tsx b/app/client/src/pages/organization/settings.tsx index 561e3511c9..1f9e2a54ba 100644 --- a/app/client/src/pages/organization/settings.tsx +++ b/app/client/src/pages/organization/settings.tsx @@ -1,11 +1,7 @@ import React, { useEffect } from "react"; import { connect } from "react-redux"; import { Icon } from "@blueprintjs/core"; -import { - GridComponent, - ColumnsDirective, - ColumnDirective, -} from "@syncfusion/ej2-react-grids"; +import { TableWrapper } from "components/designSystems/appsmith/TableStyledWrappers"; import { AppState } from "reducers"; import { getAllUsers, @@ -27,6 +23,7 @@ import Spinner from "components/editorComponents/Spinner"; import FormDialogComponent from "components/editorComponents/form/FormDialogComponent"; import { getCurrentUser } from "selectors/usersSelectors"; import { User } from "constants/userConstants"; +import { useTable, useFlexLayout } from "react-table"; type OrgProps = { allOrgs: Organization[]; changeOrgName: (value: string) => void; @@ -57,27 +54,25 @@ type DropdownProps = { username: string; }; -const StyledGridComponent = styled(GridComponent)` - &&& { - .e-altrow { - background-color: #fafafa; - } - .e-active { - background: #cccccc; - } - .e-gridcontent { +const StyledDropDown = styled.div` + cursor: pointer; +`; + +const StyledTableWrapped = styled(TableWrapper)` + width: 100%; + height: auto; + font-size: 14px; + .table { + .tbody { + overflow: auto; + height: auto; max-height: calc( 100vh - (100vh / 3) - ${props => props.theme.headerHeight} ); - overflow: auto; } } `; -const StyledDropDown = styled.div` - cursor: pointer; -`; - const StyledMenu = styled(Menu)` &&&&.bp3-menu { max-width: 250px; @@ -103,8 +98,102 @@ export const OrgSettings = (props: PageProps) => { roles: props.allRole, isCurrentUser: user.username === props.currentUser?.username, })); + const data = React.useMemo(() => userTableData, [ + props.allUsers, + props.allRole, + ]); + const columns = React.useMemo(() => { + return [ + { + Header: "Email", + accessor: "username", + }, + { + Header: "Name", + accessor: "name", + }, + { + Header: "Role", + accessor: "roleName", + Cell: (cellProps: any) => { + const { + roleName, + roles, + username, + isCurrentUser, + isChangingRole, + } = cellProps.row.original; + + if (isCurrentUser) { + return
{roleName}
; + } + + return ( + + } + position={Position.BOTTOM_LEFT} + > + + {roleName} + + {isChangingRole ? : undefined} + + + ); + }, + }, + { + Header: "Delete", + accessor: "delete", + Cell: (cellProps: any) => { + const { + username, + isCurrentUser, + isDeleting, + } = cellProps.row.original; + + return ( + !isCurrentUser && + (isDeleting ? ( + + ) : ( + deleteOrgUser(orgId, username)} + style={{ alignSelf: "center", cursor: "pointer" }} + /> + )) + ); + }, + }, + ]; + }, [props.allUsers, props.allRole]); + const currentOrg = allOrgs.find(org => org.organization.id === orgId); const currentOrgName = currentOrg?.organization.name ?? ""; + const { + getTableProps, + getTableBodyProps, + headerGroups, + rows, + prepareRow, + } = useTable( + { + columns, + data, + manualPagination: true, + }, + useFlexLayout, + ); useEffect(() => { fetchUser(orgId); @@ -166,67 +255,61 @@ export const OrgSettings = (props: PageProps) => { {props.isFetchAllUsers && props.isFetchAllRoles ? ( ) : ( - - - - - { - return props.isCurrentUser ? ( -
{props.roleName}
- ) : ( - - } - position={Position.BOTTOM_LEFT} - > - - {props.roleName} - - {props.isChangingRole ? : undefined} - - - ); - }} - /> - { - return ( - !props.isCurrentUser && - (props.isDeleting ? ( - - ) : ( - deleteOrgUser(orgId, props.username)} - style={{ alignSelf: "center", cursor: "pointer" }} - /> - )) - ); - }} - /> -
-
+ +
+
+ {headerGroups.map((headerGroup: any, index: number) => ( +
+ {headerGroup.headers.map( + (column: any, columnIndex: number) => ( +
+
+ {column.render("Header")} +
+
+ ), + )} +
+ ))} +
+ {rows.map((row: any, index: number) => { + prepareRow(row); + return ( +
+ {row.cells.map((cell: any, cellIndex: number) => { + return ( +
+ {cell.render("Cell")} +
+ ); + })} +
+ ); + })} +
+
+
+
)} );