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 <kartikay_2101ce32@iitp.ac.in>

* manual itemsPerPage limit options

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>

* manual itemsPerPage limit options

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>

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

Co-authored-by: Sahil <sahil.kumar@harness.io>
Signed-off-by: Kartikay <120778728+kartikaysaxena@users.noreply.github.com>

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

Co-authored-by: Sahil <sahil.kumar@harness.io>
Signed-off-by: Kartikay <120778728+kartikaysaxena@users.noreply.github.com>

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

Co-authored-by: Sahil <sahil.kumar@harness.io>
Signed-off-by: Kartikay <120778728+kartikaysaxena@users.noreply.github.com>

* suggestion implemented

Signed-off-by: Kartikay <120778728+kartikaysaxena@users.noreply.github.com>

---------

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
Signed-off-by: Kartikay <120778728+kartikaysaxena@users.noreply.github.com>
Co-authored-by: Saranya Jena <saranya.jena@harness.io>
Co-authored-by: Sarthak Jain <sarthak.jain@harness.io>
Co-authored-by: Hrishav <hrishav.kumar@harness.io>
Co-authored-by: Sahil <sahil.kumar@harness.io>
  • 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.