-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: User Panel > Tab PENDING #30296
Closed
+238
−93
Closed
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
72bacc5
feat: :sparkles: Filter users list by active users
rique223 444c930
feat: :sparkles: Implement new roles filter in the admin users page
rique223 a98e659
create filter for pending users (work in progress)
felipe-rod123 d70d1b8
create new pendingAction collumn
felipe-rod123 089c669
add pending actions count
felipe-rod123 a1d01d5
WIP: Remove filters
rique223 91046ad
Merge branch 'feat/user-panel' into feat/active-tab
rique223 d3f01f7
feat: :sparkles: WIP: Implement new actions menu for users page table
rique223 c89a193
Merge branch 'feat/active-tab' into WM-164-tab-pending
felipe-rod123 3682720
fix i18n
felipe-rod123 26940ba
feat: :sparkles: Finish users table menu
rique223 58dd010
Merge branch 'feat/active-tab' into WM-164-tab-pending
felipe-rod123 444ab6f
refactor: :recycle: Remove status badge from contextual bar and reorg
rique223 6e2f2ad
Typecheck
rique223 55810be
Re-add icon back to InfoPanelTitle
rique223 b91dce2
create menu component
felipe-rod123 c368d06
Merge branch 'feat/user-panel' into feat/active-tab
rique223 f49a37d
fix spacing
felipe-rod123 270a38e
fix table rows
felipe-rod123 96d0c47
fix button
felipe-rod123 d841d0e
fix review
felipe-rod123 1b938f8
Merge branch 'feat/active-tab' into WM-164-tab-pending
rique223 32a4e91
fix: :bug: Implement Activate button and small fixes
rique223 9d12a02
fix pending actions counter (work in progress)
felipe-rod123 68d8b7d
fix filters (work in progress)
felipe-rod123 9f77840
Merge branch 'feat/user-panel' into WM-164-tab-pending
felipe-rod123 8cf407a
fix lint
felipe-rod123 cd7e702
fix lint
felipe-rod123 bc437dd
fix
felipe-rod123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
106 changes: 106 additions & 0 deletions
106
apps/meteor/client/views/admin/users/UsersTable/ActionsMenu.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,106 @@ | ||
import type { IUser } from '@rocket.chat/core-typings'; | ||
import { isUserFederated } from '@rocket.chat/core-typings'; | ||
import { Menu, Option } from '@rocket.chat/fuselage'; | ||
import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; | ||
import type { useQuery } from '@tanstack/react-query'; | ||
import type { ReactElement } from 'react'; | ||
import React, { useMemo } from 'react'; | ||
|
||
import { useChangeAdminStatusAction } from '../hooks/useChangeAdminStatusAction'; | ||
import { useChangeUserStatusAction } from '../hooks/useChangeUserStatusAction'; | ||
import { useDeleteUserAction } from '../hooks/useDeleteUserAction'; | ||
import { useResetE2EEKeyAction } from '../hooks/useResetE2EEKeyAction'; | ||
import { useResetTOTPAction } from '../hooks/useResetTOTPAction'; | ||
|
||
type ActionsMenuProps = { | ||
user: Pick<IUser, '_id' | 'username' | 'name' | 'status' | 'emails' | 'active' | 'avatarETag' | 'roles'>; | ||
refetchUsers: ReturnType<typeof useQuery>['refetch']; | ||
onReload: () => void; | ||
tab: string; | ||
}; | ||
|
||
const ActionsMenu = ({ user, refetchUsers, onReload, tab }: ActionsMenuProps): ReactElement | null => { | ||
const userId = user._id; | ||
const isAdmin = user.roles?.includes('admin'); | ||
const isActive = user.active; | ||
const isFederatedUser = isUserFederated(user); | ||
|
||
const onChange = useMutableCallback(() => { | ||
onReload(); | ||
refetchUsers(); | ||
}); | ||
|
||
const changeAdminStatusAction = useChangeAdminStatusAction(userId, isAdmin, onChange); | ||
const changeUserStatusAction = useChangeUserStatusAction(userId, isActive, onChange); | ||
const deleteUserAction = useDeleteUserAction(userId, onChange, onReload); | ||
const resetTOTPAction = useResetTOTPAction(userId); | ||
const resetE2EKeyAction = useResetE2EEKeyAction(userId); | ||
|
||
const activeMenuOptions = useMemo( | ||
() => | ||
tab === 'active' | ||
? { | ||
...(changeAdminStatusAction && | ||
!isFederatedUser && { | ||
makeAdmin: { | ||
label: { label: changeAdminStatusAction.label, icon: changeAdminStatusAction.icon }, | ||
action: changeAdminStatusAction.action, | ||
}, | ||
}), | ||
...(resetE2EKeyAction && | ||
!isFederatedUser && { | ||
resetE2EKey: { label: { label: resetE2EKeyAction.label, icon: resetE2EKeyAction.icon }, action: resetE2EKeyAction.action }, | ||
}), | ||
...(resetTOTPAction && | ||
!isFederatedUser && { | ||
resetTOTP: { label: { label: resetTOTPAction.label, icon: resetTOTPAction.icon }, action: resetTOTPAction.action }, | ||
}), | ||
} | ||
: {}, | ||
[changeAdminStatusAction, isFederatedUser, resetE2EKeyAction, resetTOTPAction, tab], | ||
); | ||
|
||
const menuOptions = useMemo( | ||
() => ({ | ||
...activeMenuOptions, | ||
...(changeUserStatusAction && | ||
!isFederatedUser && { | ||
changeActiveStatus: { | ||
label: { label: changeUserStatusAction.label, icon: changeUserStatusAction.icon }, | ||
action: changeUserStatusAction.action, | ||
}, | ||
}), | ||
...(deleteUserAction && { | ||
delete: { label: { label: deleteUserAction.label, icon: deleteUserAction.icon }, action: deleteUserAction.action }, | ||
}), | ||
}), | ||
[activeMenuOptions, changeUserStatusAction, deleteUserAction, isFederatedUser], | ||
); | ||
|
||
return useMemo(() => { | ||
if (!menuOptions) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Menu | ||
mi={4} | ||
placement='bottom-start' | ||
flexShrink={0} | ||
key='menu' | ||
renderItem={({ label: { label, icon }, ...props }): ReactElement => | ||
label === 'Delete' ? ( | ||
<Option label={label} title={label} icon={icon} variant='danger' {...props} /> | ||
) : ( | ||
<Option label={label} title={label} icon={icon} {...props} /> | ||
) | ||
} | ||
options={menuOptions} | ||
aria-keyshortcuts='alt' | ||
tabIndex={-1} | ||
/> | ||
); | ||
}, [menuOptions]); | ||
}; | ||
|
||
export default ActionsMenu; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pendingActionsCount is defined and used but since the set is never ran the number will never change. Why is it incomplete?