mattermost-mobile/app/components
Jason Frerich 218f98e3e0
[Gekidou - MM-47653] Implement Manage Members Screen (#6771)
* move user_list to component

* start the modal from create_direct_message

* initial commit

* Add managing options to user profile

* s/showManage/showManageMode/

* simplify

* use helper functions

* add dependency

* fix togglling manage/done button

* remove close button in navbar

* remove close button. The only exit from this screen is the back button

* utilize LeaveChannelLabel component actions

* nit

* nit

* slight refactor

* return earlier if not showManageMode

* use defineMessages

* don't modify leave channel component

* add manage_members_label component

* rename variables to imply manage actions

* remove user from channel on server and locally in channel membership

* prevent managing yourself. In V1, this is done by not allowing you to
select yourself for channel removal

* remove useReducer

* - fix typography
- fix icon size
- don't allow tapping on yourself in manage mode

* sort props

* sort props

* sort props

* - combine try blocks
- use getServerDatabaseAndOperator function to get the operator

* fetchChannelStats after removing users from a channel

* currently, the UI does not provide a need to remove multiple members
from a channel, only one member. modify the function to only accept and
remove one user

* no need to pass the entire channel object. only need the channelId which
is already passed into the screen

* do not pass the entire user model, only the userid and if user canManage
  (is sysadmin or channel admin)

* move members constants to its own file and out of general.ts file

* pass channel displayName instead of the entire channel object

* not need to store the user as it is already in the store from the
fetchProfilesInChannel call

* implement device emitter to notify the parent to remove to the user from
the user list

* rename constant in reveal removing a member from a channel.  Might need for another team removal later.

* add snackbar after user is removed

* remove unnessary filter

* remove paging. Server response is not paginated
deconstruct intl

* create EMPTY const

* simplify getProfiles function

* move constants to top of file

* add function to remove the user from the server

* clean up dependencies

* remove @app/ prefix from imports

* add comment describing reason for switch / case

* rename varaible to be more intention revealing

* calculate isDefaultChannel and pass in as prop so don't need to
query for each user

* if user cannot manage, do not show the manage nav button

* move options const into function that uses it

* have the caller of handeRemoveMemberFromChannel fetch channel stats, not
the action

* nit formatting

* s/canManage/canManageMembers/

* use existing observeCanManageChannelMembers function
function only requires channel id

* move userInfo and manage user options to their own components

* calculate bottom sheet snap points when in manage mode

* implement correct permissions for managing users.  For now, only channel
admins can manage users (including deleting members)

* working on section creation

* use map instead of arrays

* - handle user profile sections differently when in members are provided (manage mode)
- emit event when user role is changed
  - modify the channelMembers in manage members modal after changing
    user role

* remove commented code

* deconstruct options

* sort dependencies and add loading dependency

* - when removing a user, remove them from channelMembers state also
- don't add empty sections to the user list results

* user profile coming from ManageChannelMembers is UserProfile joined with
their ChannelMembership.  Can now check for scheme_admin to see if the
user is a channel admin

* deconstruct locale from intl and remove intl const

* Add SearchUserOptions type to provide type checking when creating options for searchProfile
action and searchUsers client api

* correct comment

* deconstruct MANAGE_OPTIONS

* Remove unused event constant

* nits

* Push header title in to the UserProfileTitle component

* Put constants back so Diff of file is smaller

* Combine switch statements
Remove isOptionItem.  These are always action items

* Wrap onAction in a usecallback

* Add help comments

* Add i18n to section titles

* Create RenderItemType for renderItem callback

* update testID
update snapshots

* CanManageMembers is deterimined by observeCanManageChannelMembers

* Add members chanenl option

* Update after merge

* Sort in order of options shown

* nit refactor

* Modify client getProfilesInChannel allow passing more options than sort.
- sort the profiles by admin
- do not show deactivated users in the manage members modal

* Profiles are now sorted by admin.  We can maintain the alphabetical sort
also by iterating over the profiles instead of members which are not alphabetical

* Type the get users Api object

* Add type.
Active option is a boolean, not a string

* only initialize if needed. Moved inside the check for members

* Create type for Manage Member Options

* Remove one liners and call directly in the switch block

* Keys to the map do not need to be translated. Only translate the title
Place the Admins section always on top

* Add removeFromChannel as a dependency

* Remove manageMode option from the title component
- add imageSize prop
- add headerText prop

* Do not show deactivated users in search

* When users are showing and not in manage mode, allow the user to tap and
open the profile for the user (in non-manage mode)

* Add fetchOnly to getMemberInChannel function
Add fetchOnly to updateChannelMembersSchemeRoles function
Remove getMemberInChannel from handleUserChangeRole in manage_channel_members because it is already called via updateChannelMembersSchemeRoles

* Remove todo from comment

* Don't use state for defining action text, icon, and isDestructive. just
set them based on the prop value manageOption

* Added correct permission check for can user manage member roles

* Add can manage member roles prop

* Calculate snap points based on manageMemberRoles prop

* Calculate snap point based on if user can remove other users

* Do not show options if you cannot remove or manage members

* Fix post merge issues

* No need to batch because only manipulating a single model

* Remove comment

* Rename variable

* Split and sort props into multiple lines for readability

* Nit

* Make dependency more specific

* Remove comment.  Doing this requires writing a custom search function in
the app that would need to guarantee the same results as a server call

* Add logError to functions with catch

* Add ticket reference

* Remove await from functions that are updating the database.  Components
that observe models these modify will get the update based from the
observable change.

* Keep track of which section is first so that the tutorial highlight
selects the first user profile of the first section

* Add a second user that creates a new section for testing tutorial

* Remove unused prop

* Update snapshot to include second user

* Use getServerDatabaseAndOperator

* remove testID change. Added a ticket to fix later

* Revert tests to only one user to test if previous tests worked

* Add new test that has 2 users

* Add ticket context as comment

* Add channelId as dependency

* Use useCallback for updateChannelMemberSchemeRole

* Remove async

* mounted.current should only be used in an effect that executes on the
first render

when user has permission to manage members changed, there is no need to
get the profiles again

* Add await for function

* Always reset loading to false after getting profiles

* use !text instead of const value using Boolean()

* add dependency

* Add manage members ids back

* When fetching users for the channel, always store them in the database.
Otherwise tapping a user might not be in the database and tapping on
them will cause a crash

* Fetch the user profile from the server when opening the user profile

* Checking management permissions should be based on the current user, not
the user of the profile being opened

---------

Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>
2023-02-03 10:42:12 +02:00
..
announcement_banner BottomSheet migration to react-native-bottom-sheet (#6907) 2023-01-05 09:51:51 +02:00
app_version [Gekidou] update deps (#6667) 2022-10-13 08:41:18 -03:00
autocomplete Filter unused preferences (#7015) 2023-01-30 21:00:19 +02:00
autocomplete_selector App framework - Post menu and channel info bindings, App forms (#6735) 2022-11-30 21:25:08 +02:00
badge Detox/E2E: Migrate e2e javascript to typescript (#6059) 2022-03-17 17:35:26 -07:00
block Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
button Add support for review app (#6772) 2022-11-24 18:52:15 +01:00
channel_actions [Gekidou - MM-47653] Implement Manage Members Screen (#6771) 2023-02-03 10:42:12 +02:00
channel_icon Gekidou Android share extension (#6803) 2022-11-30 23:18:56 +02:00
channel_item Do not access record children directly to avoid crashes if the child is not present in the db (#7028) 2023-01-27 17:57:38 +02:00
channel_list_row Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
common_post_options Do not access record children directly to avoid crashes if the child is not present in the db (#7028) 2023-01-27 17:57:38 +02:00
compass_icon [Gekidou] compass icons (#5940) 2022-02-08 16:16:30 -03:00
connection_banner Fix connection banner showing when not needed (#6948) 2023-01-11 21:37:09 +02:00
custom_status Filter unused preferences (#7015) 2023-01-30 21:00:19 +02:00
emoji Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
error_text [Gekidou] update deps (#6667) 2022-10-13 08:41:18 -03:00
files Do not access record children directly to avoid crashes if the child is not present in the db (#7028) 2023-01-27 17:57:38 +02:00
floating_text_input_label Fix floating input style (#6916) 2022-12-29 20:13:32 +02:00
formatted_date Fix and add missing locales (#6396) 2022-06-16 21:50:59 -04:00
formatted_markdown_text Refactor makeStylesFromTheme to use the correct types (#6801) 2022-12-12 10:53:54 +01:00
formatted_relative_time Add support for review app (#6772) 2022-11-24 18:52:15 +01:00
formatted_text Refactor makeStylesFromTheme to use the correct types (#6801) 2022-12-12 10:53:54 +01:00
formatted_time Fix and add missing locales (#6396) 2022-06-16 21:50:59 -04:00
freeze_screen [Gekidou] optimizations, fix & moved files (#6177) 2022-04-18 08:49:17 -04:00
friendly_date Refactor makeStylesFromTheme to use the correct types (#6801) 2022-12-12 10:53:54 +01:00
illustrations MM-42835_Invite People - add email+user invites 2022-12-16 10:45:48 -05:00
jumbo_emoji Detox/E2E: Messaging e2e tests in Gekidou (#6228) 2022-05-05 13:04:33 -04:00
loading [Gekidou MM-44927] Add Recent Searches Component (#6454) 2022-07-14 14:56:08 +02:00
loading_error Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
markdown Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
navigation_header Detox/E2E: Search Messages e2e tests in Gekidou (#6756) 2022-11-21 12:58:51 -08:00
no_results_with_term [Gekidou MM-47765] Add horizontal padding to empty results (#6745) 2022-11-08 12:54:57 -06:00
option_box fix option box minHeight so that it fits on iPhone SE (#6588) 2022-08-24 08:55:26 -04:00
option_item [Gekidou MM-46365] fix reaction bar space and update bottom sheet styles (#6634) 2022-12-23 14:08:51 +02:00
post_draft Do not access record children directly to avoid crashes if the child is not present in the db (#7028) 2023-01-27 17:57:38 +02:00
post_list [Gekidou - MM-47653] Implement Manage Members Screen (#6771) 2023-02-03 10:42:12 +02:00
post_priority BottomSheet migration to react-native-bottom-sheet (#6907) 2023-01-05 09:51:51 +02:00
post_with_channel_info Do not access record children directly to avoid crashes if the child is not present in the db (#7028) 2023-01-27 17:57:38 +02:00
profile_picture Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
progress_bar [Gekidou] Post input (#5844) 2022-02-03 08:59:15 -03:00
progressive_image Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
remove_markdown Fix inline code blocks in thread preview (#6835) 2022-12-06 14:09:38 +02:00
rounded_header_context [Gekidou] Navigation bar refactored (#6319) 2022-06-01 17:07:54 -04:00
search Place cursor position in between the phrase modifier (#6828) 2022-12-06 18:36:48 +02:00
selected_chip MM-42835_Invite People - add email+user invites 2023-01-23 12:59:57 -05:00
selected_users Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
server_icon Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
server_user_list Fix multiselect on users list integration selector (#6826) 2022-12-05 12:13:48 +01:00
server_version Gekidou Android share extension (#6803) 2022-11-30 23:18:56 +02:00
settings Refactor makeStylesFromTheme to use the correct types (#6801) 2022-12-12 10:53:54 +01:00
slide_up_panel_item Refactor makeStylesFromTheme to use the correct types (#6801) 2022-12-12 10:53:54 +01:00
status_label Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
syntax_highlight Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
system_avatar [Gekidou] post list (#5893) 2022-01-17 07:06:26 -03:00
system_header Filter unused preferences (#7015) 2023-01-30 21:00:19 +02:00
tablet_title Detox/E2E: Account e2e tests in Gekidou (#6584) 2022-08-18 03:18:46 -07:00
tag Gekidou cleanup (#6263) 2022-05-13 09:29:35 -04:00
team_list BottomSheet migration to react-native-bottom-sheet (#6907) 2023-01-05 09:51:51 +02:00
team_sidebar Filter unused preferences (#7015) 2023-01-30 21:00:19 +02:00
threads_button Filter unused preferences (#7015) 2023-01-30 21:00:19 +02:00
toast Move config to its own database table (#6744) 2022-11-11 21:20:42 +04:00
touchable_emoji New UI for Emoji picker (#6933) 2023-01-12 13:38:44 +02:00
touchable_with_feedback Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
tutorial_highlight iPad: enable rotation in all directions (#7007) 2023-01-24 21:48:37 +02:00
user_avatars_stack Update Dependencies and bug fixes (#7000) 2023-01-24 09:14:23 +02:00
user_item MM-42835_Invite People - add email+user invites 2023-01-09 12:33:51 -05:00
user_list [Gekidou - MM-47653] Implement Manage Members Screen (#6771) 2023-02-03 10:42:12 +02:00
user_list_row [Gekidou - MM-47653] Implement Manage Members Screen (#6771) 2023-02-03 10:42:12 +02:00
user_status [Gekidou] update deps (#6667) 2022-10-13 08:41:18 -03:00