-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New users page active tab (#32024)
Co-authored-by: Tasso Evangelista <[email protected]>
- Loading branch information
Showing
10 changed files
with
126 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@rocket.chat/meteor": minor | ||
"@rocket.chat/i18n": patch | ||
"@rocket.chat/ui-client": patch | ||
--- | ||
|
||
Implemented a new tab to the users page called 'Active', this tab lists all users who have logged in for the first time and are active. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
apps/meteor/client/views/admin/users/UsersTable/UsersTableFilters.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import type { IRole } from '@rocket.chat/core-typings'; | ||
import { useBreakpoints } from '@rocket.chat/fuselage-hooks'; | ||
import type { OptionProp } from '@rocket.chat/ui-client'; | ||
import { MultiSelectCustom } from '@rocket.chat/ui-client'; | ||
import React, { useCallback, useMemo, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import FilterByText from '../../../../components/FilterByText'; | ||
import type { UsersFilters } from '../AdminUsersPage'; | ||
|
||
type UsersTableFiltersProps = { | ||
setUsersFilters: React.Dispatch<React.SetStateAction<UsersFilters>>; | ||
roleData: { roles: IRole[] } | undefined; | ||
}; | ||
|
||
const UsersTableFilters = ({ roleData, setUsersFilters }: UsersTableFiltersProps) => { | ||
const { t } = useTranslation(); | ||
|
||
const [selectedRoles, setSelectedRoles] = useState<OptionProp[]>([]); | ||
const [text, setText] = useState(''); | ||
|
||
const handleSearchTextChange = useCallback( | ||
({ text }) => { | ||
setUsersFilters({ text, roles: selectedRoles }); | ||
setText(text); | ||
}, | ||
[selectedRoles, setUsersFilters], | ||
); | ||
|
||
const handleRolesChange = useCallback( | ||
(roles: OptionProp[]) => { | ||
setUsersFilters({ text, roles }); | ||
setSelectedRoles(roles); | ||
}, | ||
[setUsersFilters, text], | ||
); | ||
|
||
const userRolesFilterStructure = useMemo( | ||
() => [ | ||
{ | ||
id: 'filter_by_role', | ||
text: 'Filter_by_role', | ||
}, | ||
{ | ||
id: 'all', | ||
text: 'All_roles', | ||
checked: false, | ||
}, | ||
...(roleData | ||
? roleData.roles.map((role) => ({ | ||
id: role._id, | ||
text: role.description || role.name || role._id, | ||
checked: false, | ||
})) | ||
: []), | ||
], | ||
[roleData], | ||
); | ||
|
||
const breakpoints = useBreakpoints(); | ||
const fixFiltersSize = breakpoints.includes('lg') ? { maxWidth: 'x224', minWidth: 'x224' } : null; | ||
|
||
return ( | ||
<FilterByText shouldAutoFocus placeholder={t('Search_Users')} onChange={handleSearchTextChange}> | ||
<MultiSelectCustom | ||
dropdownOptions={userRolesFilterStructure} | ||
defaultTitle='All_roles' | ||
selectedOptionsTitle='Roles' | ||
setSelectedOptions={handleRolesChange} | ||
selectedOptions={selectedRoles} | ||
searchBarText='Search_roles' | ||
{...fixFiltersSize} | ||
/> | ||
</FilterByText> | ||
); | ||
}; | ||
|
||
export default UsersTableFilters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters