Skip to content

Commit

Permalink
User Management Screen improvements (#4454)
Browse files Browse the repository at this point in the history
* pagination added

Signed-off-by: Kartikay <[email protected]>

* manual itemsPerPage limit options

Signed-off-by: Kartikay <[email protected]>

* manual itemsPerPage limit options

Signed-off-by: Kartikay <[email protected]>

Signed-off-by: Kartikay <[email protected]>

* Update chaoscenter/web/src/views/AccountSettingsUserManagement/AccountSettingsUserManagement.tsx

Co-authored-by: Sahil <[email protected]>
Signed-off-by: Kartikay <[email protected]>

* Update chaoscenter/web/src/views/AccountSettingsUserManagement/AccountSettingsUserManagement.tsx

Co-authored-by: Sahil <[email protected]>
Signed-off-by: Kartikay <[email protected]>

* Update chaoscenter/web/src/views/AccountSettingsUserManagement/AccountSettingsUserManagement.tsx

Co-authored-by: Sahil <[email protected]>
Signed-off-by: Kartikay <[email protected]>

* suggestion implemented

Signed-off-by: Kartikay <[email protected]>

---------

Signed-off-by: Kartikay <[email protected]>
Signed-off-by: Kartikay <[email protected]>
Co-authored-by: Saranya Jena <[email protected]>
Co-authored-by: Sarthak Jain <[email protected]>
Co-authored-by: Hrishav <[email protected]>
Co-authored-by: Sahil <[email protected]>
  • Loading branch information
5 people authored Apr 8, 2024
1 parent fc0b70c commit 77336cb
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Checkbox,
Container,
Layout,
Pagination,
TableV2,
Text,
useToggleOpen
Expand Down Expand Up @@ -190,6 +191,18 @@ export default function AccountSettingsUserManagementView(
const { isOpen: isCreateUserModalOpen, open: openCreateUserModal, close: closeCreateUserModal } = useToggleOpen();
const { getString } = useStrings();

function handleItemsPerPageChange(pageSize: number) {
setItemsPerPage(pageSize);
setCurrentPage(1);
}

const [currentPage, setCurrentPage] = React.useState(1);
const [itemsPerPage, setItemsPerPage] = React.useState(5);

const indexOfLastItem = currentPage * itemsPerPage;
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
const currentItems = usersData?.slice(indexOfFirstItem, indexOfLastItem);

return (
<Layout.Vertical height={'100%'}>
<Layout.Horizontal
Expand Down Expand Up @@ -238,8 +251,18 @@ export default function AccountSettingsUserManagementView(
{getString('totalUsers')}: {usersData?.length ?? 0}
</Text>
<Container style={{ flexGrow: 1 }}>
{usersData && <MemoizedUsersTable users={usersData} getUsersRefetch={getUsersRefetch} />}
{currentItems && <MemoizedUsersTable users={currentItems} getUsersRefetch={getUsersRefetch} />}
</Container>
<Pagination
pageSize={itemsPerPage}
pageCount={Math.ceil(usersData?.length / itemsPerPage)}
itemCount={usersData?.length ?? 0}
pageIndex={currentPage - 1}
gotoPage={pageIndex => setCurrentPage(pageIndex + 1)}
showPagination={true}
pageSizeOptions={[5, 10, 20]}
onPageSizeChange={pageSize => handleItemsPerPageChange(pageSize)}
/>
</Loader>
</Layout.Vertical>
</Layout.Vertical>
Expand Down

0 comments on commit 77336cb

Please sign in to comment.