From 90da483aa7094fa9893a25cab15a7d09726aebaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20Guimar=C3=A3es=20Ribeiro?= Date: Wed, 4 Oct 2023 16:32:28 -0300 Subject: [PATCH] feat: Implement users page active tab (#30242) * feat: :sparkles: Filter users list by active users Implemented the necessary resources to filter the list of users and to return only those who are active, when the active tab is enabled. * feat: :sparkles: Implement new roles filter in the admin users page Implemented a new filter on the users' page that retrieves the roles list and creates a dropdown menu. When any of its options is selected, it will filter the users' list to display only those with the selected roles. Additionally, I made some minor adjustments to the MultiSelectCustom component and introduced some new hooks. * WIP: Remove filters * feat: :sparkles: WIP: Implement new actions menu for users page table * feat: :sparkles: Finish users table menu Completed the implementation of the users table actions menu by preventing the propagation of the click event that triggered the opening of the contextual bar when the menu was clicked. Also, ensured that the contextual bar only opens when the "Enter" or "Space" keys are used for keyboard navigation and enhanced the options menu in the contextual bar as specified in Figma. * refactor: :recycle: Remove status badge from contextual bar and reorg Removed the status from the users page contextual bar (the need to remove this may not be concrete, for now it will be only commented until the final decision is made). Also changed the order of the contextual bar info and changed some minor styles to follow figma specs. * Typecheck * Re-add icon back to InfoPanelTitle * Hide registration status and justify actions menu * Review, reintroduce contextual bar full name and status --- .../components/InfoPanel/InfoPanelTitle.tsx | 6 +- .../components/UserCard/UserCardRoles.tsx | 2 +- .../client/components/UserInfo/UserInfo.tsx | 40 ++--- .../admin/users/AdminUserInfoActions.tsx | 10 +- .../views/admin/users/AdminUsersPage.tsx | 12 +- .../admin/users/UsersTable/UsersTable.tsx | 152 +++++++++--------- .../admin/users/UsersTable/UsersTableRow.tsx | 94 ++++++++++- .../admin/users/hooks/useFilterActiveUsers.ts | 10 ++ .../admin/users/hooks/useFilterUsersByrole.ts | 12 ++ .../views/admin/users/hooks/useListUsers.ts | 69 ++++++++ .../rocketchat-i18n/i18n/en.i18n.json | 6 +- .../MultiSelectCustom/MultiSelectCustom.tsx | 4 +- .../MultiSelectCustomAnchor.tsx | 9 +- .../MultiSelectCustomList.tsx | 4 +- 14 files changed, 307 insertions(+), 123 deletions(-) create mode 100644 apps/meteor/client/views/admin/users/hooks/useFilterActiveUsers.ts create mode 100644 apps/meteor/client/views/admin/users/hooks/useFilterUsersByrole.ts create mode 100644 apps/meteor/client/views/admin/users/hooks/useListUsers.ts diff --git a/apps/meteor/client/components/InfoPanel/InfoPanelTitle.tsx b/apps/meteor/client/components/InfoPanel/InfoPanelTitle.tsx index 7ea4de6d9867..615f6762efd1 100644 --- a/apps/meteor/client/components/InfoPanel/InfoPanelTitle.tsx +++ b/apps/meteor/client/components/InfoPanel/InfoPanelTitle.tsx @@ -5,15 +5,15 @@ import React from 'react'; type InfoPanelTitleProps = { title: string; - icon: ReactNode; + icon?: ReactNode; }; const isValidIcon = (icon: ReactNode): icon is IconName => typeof icon === 'string'; const InfoPanelTitle: FC = ({ title, icon }) => ( - + {isValidIcon(icon) ? : icon} - + {title} diff --git a/apps/meteor/client/components/UserCard/UserCardRoles.tsx b/apps/meteor/client/components/UserCard/UserCardRoles.tsx index 9cd22ebdff35..f7a977d4a4dc 100644 --- a/apps/meteor/client/components/UserCard/UserCardRoles.tsx +++ b/apps/meteor/client/components/UserCard/UserCardRoles.tsx @@ -6,7 +6,7 @@ import UserCardInfo from './UserCardInfo'; const UserCardRoles = ({ children }: { children: ReactNode }): ReactElement => ( - + {children} diff --git a/apps/meteor/client/components/UserInfo/UserInfo.tsx b/apps/meteor/client/components/UserInfo/UserInfo.tsx index bdce27d028ad..8a42f1b87026 100644 --- a/apps/meteor/client/components/UserInfo/UserInfo.tsx +++ b/apps/meteor/client/components/UserInfo/UserInfo.tsx @@ -81,12 +81,19 @@ const UserInfo = ({ {userDisplayName && } {statusText && ( - + )} + {nickname && ( + + {t('Nickname')} + {nickname} + + )} + {roles.length !== 0 && ( {t('Roles')} @@ -94,6 +101,13 @@ const UserInfo = ({ )} + {username && username !== name && ( + + {t('Username')} + {username} + + )} + {Number.isInteger(utcOffset) && ( {t('Local_Time')} @@ -101,10 +115,12 @@ const UserInfo = ({ )} - {username && username !== name && ( + {bio && ( - {t('Username')} - {username} + {t('Bio')} + + + )} @@ -122,22 +138,6 @@ const UserInfo = ({ )} - {nickname && ( - - {t('Nickname')} - {nickname} - - )} - - {bio && ( - - {t('Bio')} - - - - - )} - {phone && ( {t('Phone')} diff --git a/apps/meteor/client/views/admin/users/AdminUserInfoActions.tsx b/apps/meteor/client/views/admin/users/AdminUserInfoActions.tsx index d003b47ba2af..dd0bf833f72b 100644 --- a/apps/meteor/client/views/admin/users/AdminUserInfoActions.tsx +++ b/apps/meteor/client/views/admin/users/AdminUserInfoActions.tsx @@ -83,8 +83,8 @@ const AdminUserInfoActions = ({ ...(changeAdminStatusAction && !isFederatedUser && { makeAdmin: changeAdminStatusAction }), ...(resetE2EKeyAction && !isFederatedUser && { resetE2EKey: resetE2EKeyAction }), ...(resetTOTPAction && !isFederatedUser && { resetTOTP: resetTOTPAction }), - ...(deleteUserAction && { delete: deleteUserAction }), ...(changeUserStatusAction && !isFederatedUser && { changeActiveStatus: changeUserStatusAction }), + ...(deleteUserAction && { delete: deleteUserAction }), }), [ t, @@ -116,7 +116,13 @@ const AdminUserInfoActions = ({ secondary flexShrink={0} key='menu' - renderItem={({ label: { label, icon }, ...props }): ReactElement =>