2022-08-26 13:21:25 +00:00
|
|
|
import { NavigationProp, RouteProp, useNavigation, useRoute } from '@react-navigation/native';
|
|
|
|
import React, { useEffect, useReducer } from 'react';
|
|
|
|
import { FlatList, Text, View } from 'react-native';
|
2023-11-17 18:48:32 +00:00
|
|
|
import { shallowEqual } from 'react-redux';
|
2022-08-26 13:21:25 +00:00
|
|
|
|
|
|
|
import { TActionSheetOptionsItem, useActionSheet } from '../../containers/ActionSheet';
|
2022-02-25 16:43:42 +00:00
|
|
|
import ActivityIndicator from '../../containers/ActivityIndicator';
|
2023-11-17 18:48:32 +00:00
|
|
|
import { CustomIcon, TIconsName } from '../../containers/CustomIcon';
|
2022-02-25 16:43:42 +00:00
|
|
|
import * as HeaderButton from '../../containers/HeaderButton';
|
2021-09-13 20:41:05 +00:00
|
|
|
import * as List from '../../containers/List';
|
2022-08-26 13:21:25 +00:00
|
|
|
import { RadioButton } from '../../containers/RadioButton';
|
2022-02-25 16:43:42 +00:00
|
|
|
import SafeAreaView from '../../containers/SafeAreaView';
|
|
|
|
import SearchBox from '../../containers/SearchBox';
|
|
|
|
import StatusBar from '../../containers/StatusBar';
|
2022-04-09 02:43:31 +00:00
|
|
|
import UserItem from '../../containers/UserItem';
|
2024-01-09 18:14:55 +00:00
|
|
|
import { IGetRoomRoles, TSubscriptionModel, TUserModel } from '../../definitions';
|
2022-08-26 13:21:25 +00:00
|
|
|
import I18n from '../../i18n';
|
|
|
|
import { useAppSelector, usePermissions } from '../../lib/hooks';
|
2023-11-17 18:48:32 +00:00
|
|
|
import { compareServerVersion, getRoomTitle, isGroupChat } from '../../lib/methods/helpers';
|
2022-10-13 21:29:55 +00:00
|
|
|
import { handleIgnore } from '../../lib/methods/helpers/handleIgnore';
|
2022-08-26 13:21:25 +00:00
|
|
|
import { showConfirmationAlert } from '../../lib/methods/helpers/info';
|
2022-06-06 14:17:51 +00:00
|
|
|
import log from '../../lib/methods/helpers/log';
|
|
|
|
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
|
2022-08-26 13:21:25 +00:00
|
|
|
import { Services } from '../../lib/services';
|
2022-05-03 00:48:08 +00:00
|
|
|
import { TSupportedPermissions } from '../../reducers/permissions';
|
2022-08-26 13:21:25 +00:00
|
|
|
import { getUserSelector } from '../../selectors/login';
|
|
|
|
import { ModalStackParamList } from '../../stacks/MasterDetailStack/types';
|
|
|
|
import { useTheme } from '../../theme';
|
|
|
|
import ActionsSection from './components/ActionsSection';
|
|
|
|
import {
|
|
|
|
fetchRole,
|
|
|
|
fetchRoomMembersRoles,
|
|
|
|
handleLeader,
|
|
|
|
handleModerator,
|
|
|
|
handleMute,
|
|
|
|
handleOwner,
|
|
|
|
handleRemoveFromTeam,
|
|
|
|
handleRemoveUserFromRoom,
|
|
|
|
navToDirectMessage,
|
|
|
|
TRoomType
|
|
|
|
} from './helpers';
|
2021-09-13 20:41:05 +00:00
|
|
|
import styles from './styles';
|
2018-03-02 15:11:34 +00:00
|
|
|
|
2019-04-17 17:01:03 +00:00
|
|
|
const PAGE_SIZE = 25;
|
|
|
|
|
2022-02-25 16:43:42 +00:00
|
|
|
interface IRoomMembersViewState {
|
|
|
|
isLoading: boolean;
|
|
|
|
allUsers: boolean;
|
2022-08-19 17:27:04 +00:00
|
|
|
filtering: string;
|
2022-02-25 16:43:42 +00:00
|
|
|
members: TUserModel[];
|
2022-05-03 00:48:08 +00:00
|
|
|
room: TSubscriptionModel;
|
2022-02-25 16:43:42 +00:00
|
|
|
end: boolean;
|
2024-01-09 18:14:55 +00:00
|
|
|
roomRoles?: IGetRoomRoles[];
|
2022-08-26 13:21:25 +00:00
|
|
|
filter: string;
|
2022-08-19 17:27:04 +00:00
|
|
|
page: number;
|
2022-02-25 16:43:42 +00:00
|
|
|
}
|
2018-03-02 15:11:34 +00:00
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
const RightIcon = ({ check, label }: { check: boolean; label: string }) => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
|
|
|
<CustomIcon
|
|
|
|
testID={check ? `action-sheet-set-${label}-checked` : `action-sheet-set-${label}-unchecked`}
|
|
|
|
name={check ? 'checkbox-checked' : 'checkbox-unchecked'}
|
|
|
|
size={20}
|
|
|
|
color={check ? colors.tintActive : colors.auxiliaryTintColor}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const RoomMembersView = (): React.ReactElement => {
|
|
|
|
const { showActionSheet } = useActionSheet();
|
|
|
|
const { colors } = useTheme();
|
|
|
|
|
|
|
|
const { params } = useRoute<RouteProp<ModalStackParamList, 'RoomMembersView'>>();
|
|
|
|
const navigation = useNavigation<NavigationProp<ModalStackParamList, 'RoomMembersView'>>();
|
|
|
|
|
2023-11-17 18:48:32 +00:00
|
|
|
const { isMasterDetail, serverVersion, useRealName, user } = useAppSelector(
|
|
|
|
state => ({
|
|
|
|
isMasterDetail: state.app.isMasterDetail,
|
|
|
|
useRealName: state.settings.UI_Use_Real_Name,
|
|
|
|
user: getUserSelector(state),
|
|
|
|
serverVersion: state.server.version
|
|
|
|
}),
|
|
|
|
shallowEqual
|
|
|
|
);
|
2022-08-26 13:21:25 +00:00
|
|
|
|
|
|
|
const [state, updateState] = useReducer(
|
|
|
|
(state: IRoomMembersViewState, newState: Partial<IRoomMembersViewState>) => ({ ...state, ...newState }),
|
|
|
|
{
|
2019-04-17 17:01:03 +00:00
|
|
|
isLoading: false,
|
2018-03-02 15:11:34 +00:00
|
|
|
allUsers: false,
|
2022-08-19 17:27:04 +00:00
|
|
|
filtering: '',
|
2019-04-17 17:01:03 +00:00
|
|
|
members: [],
|
2022-08-26 13:21:25 +00:00
|
|
|
room: params.room || ({} as TSubscriptionModel),
|
2022-08-19 17:27:04 +00:00
|
|
|
end: false,
|
2024-01-09 18:14:55 +00:00
|
|
|
roomRoles: undefined,
|
2022-08-26 13:21:25 +00:00
|
|
|
filter: '',
|
2022-08-19 17:27:04 +00:00
|
|
|
page: 0
|
2019-09-17 14:43:49 +00:00
|
|
|
}
|
2022-08-26 13:21:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const teamPermissions: TSupportedPermissions[] = state.room.teamMain
|
|
|
|
? ['edit-team-member', 'view-all-team-channels', 'view-all-teams']
|
|
|
|
: [];
|
|
|
|
|
|
|
|
const [
|
|
|
|
muteUserPermission,
|
|
|
|
setLeaderPermission,
|
|
|
|
setOwnerPermission,
|
|
|
|
setModeratorPermission,
|
|
|
|
removeUserPermission,
|
|
|
|
editTeamMemberPermission,
|
|
|
|
viewAllTeamChannelsPermission,
|
|
|
|
viewAllTeamsPermission
|
|
|
|
] = usePermissions(['mute-user', 'set-leader', 'set-owner', 'set-moderator', 'remove-user', ...teamPermissions], params.rid);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const subscription = params?.room?.observe && params.room.observe().subscribe(changes => updateState({ room: changes }));
|
2023-01-04 14:36:51 +00:00
|
|
|
setHeader(false);
|
|
|
|
fetchMembers(false);
|
2022-08-26 13:21:25 +00:00
|
|
|
return () => subscription?.unsubscribe();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchRoles = () => {
|
|
|
|
if (isGroupChat(state.room)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
muteUserPermission ||
|
|
|
|
setLeaderPermission ||
|
|
|
|
setOwnerPermission ||
|
|
|
|
setModeratorPermission ||
|
|
|
|
removeUserPermission ||
|
|
|
|
editTeamMemberPermission ||
|
|
|
|
viewAllTeamChannelsPermission ||
|
|
|
|
viewAllTeamsPermission
|
|
|
|
) {
|
|
|
|
fetchRoomMembersRoles(state.room.t as any, state.room.rid, updateState);
|
|
|
|
}
|
2021-02-25 16:41:44 +00:00
|
|
|
};
|
2022-08-26 13:21:25 +00:00
|
|
|
fetchRoles();
|
|
|
|
}, [
|
|
|
|
muteUserPermission,
|
|
|
|
setLeaderPermission,
|
|
|
|
setOwnerPermission,
|
|
|
|
setModeratorPermission,
|
|
|
|
removeUserPermission,
|
|
|
|
editTeamMemberPermission,
|
|
|
|
viewAllTeamChannelsPermission,
|
|
|
|
viewAllTeamsPermission
|
|
|
|
]);
|
|
|
|
|
|
|
|
const toggleStatus = (status: boolean) => {
|
|
|
|
try {
|
|
|
|
updateState({ members: [], allUsers: status, end: false });
|
|
|
|
fetchMembers(status);
|
|
|
|
setHeader(status);
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
2019-09-16 20:26:32 +00:00
|
|
|
}
|
2022-08-26 13:21:25 +00:00
|
|
|
};
|
2018-04-24 19:34:03 +00:00
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
const setHeader = (allUsers: boolean) => {
|
2020-06-15 14:00:46 +00:00
|
|
|
navigation.setOptions({
|
|
|
|
title: I18n.t('Members'),
|
|
|
|
headerRight: () => (
|
2020-10-30 16:15:58 +00:00
|
|
|
<HeaderButton.Container>
|
2022-08-26 13:21:25 +00:00
|
|
|
<HeaderButton.Item
|
|
|
|
iconName='filter'
|
|
|
|
onPress={() =>
|
|
|
|
showActionSheet({
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
title: I18n.t('Online'),
|
|
|
|
onPress: () => toggleStatus(true),
|
|
|
|
right: () => <RadioButton check={allUsers} />,
|
|
|
|
testID: 'room-members-view-toggle-status-online'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: I18n.t('All'),
|
|
|
|
onPress: () => toggleStatus(false),
|
|
|
|
right: () => <RadioButton check={!allUsers} />,
|
|
|
|
testID: 'room-members-view-toggle-status-all'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
testID='room-members-view-filter'
|
|
|
|
/>
|
2020-10-30 16:15:58 +00:00
|
|
|
</HeaderButton.Container>
|
2020-06-15 14:00:46 +00:00
|
|
|
)
|
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-06-15 14:00:46 +00:00
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
const getUserDisplayName = (user: TUserModel) => (useRealName ? user.name : user.username) || user.username;
|
2022-08-19 17:27:04 +00:00
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
const onPressUser = (selectedUser: TUserModel) => {
|
|
|
|
const { room, roomRoles, members } = state;
|
2018-12-21 10:55:35 +00:00
|
|
|
|
2022-05-03 00:48:08 +00:00
|
|
|
const options: TActionSheetOptionsItem[] = [
|
2021-09-13 20:41:05 +00:00
|
|
|
{
|
|
|
|
icon: 'message',
|
|
|
|
title: I18n.t('Direct_message'),
|
2022-08-26 13:21:25 +00:00
|
|
|
onPress: () => navToDirectMessage(selectedUser, isMasterDetail)
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
];
|
2020-06-15 19:35:45 +00:00
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
// Owner
|
2022-08-26 13:21:25 +00:00
|
|
|
if (setOwnerPermission) {
|
|
|
|
const isOwner = fetchRole('owner', selectedUser, roomRoles);
|
2020-11-30 20:00:31 +00:00
|
|
|
options.push({
|
|
|
|
icon: 'shield-check',
|
[NEW] Remove member from team (#3117)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Added confirmationAlert for missing permissions case
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-26 21:01:06 +00:00
|
|
|
title: I18n.t('Owner'),
|
2022-08-26 13:21:25 +00:00
|
|
|
onPress: () =>
|
|
|
|
handleOwner(selectedUser, !isOwner, getUserDisplayName(selectedUser), room, () =>
|
|
|
|
fetchRoomMembersRoles(room.t as TRoomType, room.rid, updateState)
|
|
|
|
),
|
|
|
|
right: () => <RightIcon check={isOwner} label='owner' />,
|
[TEST] E2E Tests for Teams (#3178)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Added deleteTeam function
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update index.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Update rocketchat.js
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Update RoomActionsView
* Update en.json
* updated deleteTeam function and permissions
* Added showConfirmationAlert
* Added string translations for teams
* Fix permission
* Added moveChannelToTeam and convertToTeam functionality
* Fix SelectListView RadioButton
* Fix moveToTeam
* Added searchBar to SelectListVIew
* Update RoomView , SelectListVIew and string translation for error
* E2E for Teams
* Fix tests and cleanup
* Minor refactor
* Wrong label
* Move/convert
* Fix convert
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-06-04 16:16:05 +00:00
|
|
|
testID: 'action-sheet-set-owner'
|
2020-11-30 20:00:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Leader
|
2022-08-26 13:21:25 +00:00
|
|
|
if (setLeaderPermission) {
|
|
|
|
const isLeader = fetchRole('leader', selectedUser, roomRoles);
|
2020-11-30 20:00:31 +00:00
|
|
|
options.push({
|
|
|
|
icon: 'shield-alt',
|
[NEW] Remove member from team (#3117)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Added confirmationAlert for missing permissions case
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-26 21:01:06 +00:00
|
|
|
title: I18n.t('Leader'),
|
2022-08-26 13:21:25 +00:00
|
|
|
onPress: () =>
|
|
|
|
handleLeader(selectedUser, !isLeader, room, getUserDisplayName(selectedUser), () =>
|
|
|
|
fetchRoomMembersRoles(room.t as TRoomType, room.rid, updateState)
|
|
|
|
),
|
|
|
|
right: () => <RightIcon check={isLeader} label='leader' />,
|
[TEST] E2E Tests for Teams (#3178)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Added deleteTeam function
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update index.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Update rocketchat.js
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Update RoomActionsView
* Update en.json
* updated deleteTeam function and permissions
* Added showConfirmationAlert
* Added string translations for teams
* Fix permission
* Added moveChannelToTeam and convertToTeam functionality
* Fix SelectListView RadioButton
* Fix moveToTeam
* Added searchBar to SelectListVIew
* Update RoomView , SelectListVIew and string translation for error
* E2E for Teams
* Fix tests and cleanup
* Minor refactor
* Wrong label
* Move/convert
* Fix convert
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-06-04 16:16:05 +00:00
|
|
|
testID: 'action-sheet-set-leader'
|
2020-11-30 20:00:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Moderator
|
2022-08-26 13:21:25 +00:00
|
|
|
if (setModeratorPermission) {
|
|
|
|
const isModerator = fetchRole('moderator', selectedUser, roomRoles);
|
2020-11-30 20:00:31 +00:00
|
|
|
options.push({
|
|
|
|
icon: 'shield',
|
[NEW] Remove member from team (#3117)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Added confirmationAlert for missing permissions case
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-26 21:01:06 +00:00
|
|
|
title: I18n.t('Moderator'),
|
2022-08-26 13:21:25 +00:00
|
|
|
onPress: () =>
|
|
|
|
handleModerator(selectedUser, !isModerator, room, getUserDisplayName(selectedUser), () =>
|
|
|
|
fetchRoomMembersRoles(room.t as TRoomType, room.rid, updateState)
|
|
|
|
),
|
|
|
|
right: () => <RightIcon check={isModerator} label='moderator' />,
|
[TEST] E2E Tests for Teams (#3178)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Added deleteTeam function
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update index.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Update rocketchat.js
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Update RoomActionsView
* Update en.json
* updated deleteTeam function and permissions
* Added showConfirmationAlert
* Added string translations for teams
* Fix permission
* Added moveChannelToTeam and convertToTeam functionality
* Fix SelectListView RadioButton
* Fix moveToTeam
* Added searchBar to SelectListVIew
* Update RoomView , SelectListVIew and string translation for error
* E2E for Teams
* Fix tests and cleanup
* Minor refactor
* Wrong label
* Move/convert
* Fix convert
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-06-04 16:16:05 +00:00
|
|
|
testID: 'action-sheet-set-moderator'
|
2020-11-30 20:00:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-11-17 18:48:32 +00:00
|
|
|
if (muteUserPermission) {
|
|
|
|
const { muted = [], ro: readOnly, unmuted = [] } = room;
|
|
|
|
let userIsMuted = !!muted.find?.(m => m === selectedUser.username);
|
|
|
|
let icon: TIconsName = userIsMuted ? 'audio' : 'audio-disabled';
|
|
|
|
let title = I18n.t(userIsMuted ? 'Unmute' : 'Mute');
|
|
|
|
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.4.0')) {
|
|
|
|
if (readOnly) {
|
|
|
|
userIsMuted = !unmuted?.find?.(m => m === selectedUser.username);
|
|
|
|
}
|
|
|
|
icon = userIsMuted ? 'message' : 'message-disabled';
|
|
|
|
title = I18n.t(userIsMuted ? 'Enable_writing_in_room' : 'Disable_writing_in_room');
|
|
|
|
}
|
|
|
|
selectedUser.muted = !!userIsMuted;
|
|
|
|
options.push({
|
|
|
|
icon,
|
|
|
|
title,
|
|
|
|
onPress: () => {
|
|
|
|
showConfirmationAlert({
|
|
|
|
message: I18n.t(`The_user_${userIsMuted ? 'will' : 'wont'}_be_able_to_type_in_roomName`, {
|
|
|
|
roomName: getRoomTitle(room)
|
|
|
|
}),
|
|
|
|
confirmationText: title,
|
|
|
|
onPress: () => handleMute(selectedUser, room.rid)
|
|
|
|
});
|
|
|
|
},
|
|
|
|
testID: 'action-sheet-mute-user'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ignore
|
|
|
|
if (selectedUser._id !== user.id) {
|
|
|
|
const { ignored } = room;
|
|
|
|
const isIgnored = ignored?.includes?.(selectedUser._id);
|
|
|
|
options.push({
|
|
|
|
icon: 'ignore',
|
|
|
|
title: I18n.t(isIgnored ? 'Unignore' : 'Ignore'),
|
|
|
|
onPress: () => handleIgnore(selectedUser._id, !isIgnored, room.rid),
|
|
|
|
testID: 'action-sheet-ignore-user'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
[NEW] Remove member from team (#3117)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Added confirmationAlert for missing permissions case
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-26 21:01:06 +00:00
|
|
|
// Remove from team
|
2022-08-26 13:21:25 +00:00
|
|
|
if (editTeamMemberPermission) {
|
2020-11-30 20:00:31 +00:00
|
|
|
options.push({
|
[NEW] Remove member from team (#3117)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Added confirmationAlert for missing permissions case
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-26 21:01:06 +00:00
|
|
|
icon: 'logout',
|
|
|
|
danger: true,
|
|
|
|
title: I18n.t('Remove_from_Team'),
|
2022-08-26 13:21:25 +00:00
|
|
|
onPress: () => handleRemoveFromTeam(selectedUser, updateState, room, members),
|
[TEST] E2E Tests for Teams (#3178)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Added deleteTeam function
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update index.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Update rocketchat.js
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Update RoomActionsView
* Update en.json
* updated deleteTeam function and permissions
* Added showConfirmationAlert
* Added string translations for teams
* Fix permission
* Added moveChannelToTeam and convertToTeam functionality
* Fix SelectListView RadioButton
* Fix moveToTeam
* Added searchBar to SelectListVIew
* Update RoomView , SelectListVIew and string translation for error
* E2E for Teams
* Fix tests and cleanup
* Minor refactor
* Wrong label
* Move/convert
* Fix convert
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-06-04 16:16:05 +00:00
|
|
|
testID: 'action-sheet-remove-from-team'
|
2020-11-30 20:00:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove from room
|
2022-08-26 13:21:25 +00:00
|
|
|
if (removeUserPermission && !room.teamMain) {
|
2020-11-30 20:00:31 +00:00
|
|
|
options.push({
|
|
|
|
icon: 'logout',
|
|
|
|
title: I18n.t('Remove_from_room'),
|
|
|
|
danger: true,
|
|
|
|
onPress: () => {
|
|
|
|
showConfirmationAlert({
|
2022-04-28 20:37:25 +00:00
|
|
|
message: I18n.t('The_user_will_be_removed_from_s', { s: getRoomTitle(room) }),
|
2020-11-30 20:00:31 +00:00
|
|
|
confirmationText: I18n.t('Yes_remove_user'),
|
2022-08-26 13:21:25 +00:00
|
|
|
onPress: () => {
|
|
|
|
handleRemoveUserFromRoom(selectedUser, room, () =>
|
|
|
|
updateState({
|
|
|
|
members: members.filter(member => member._id !== selectedUser._id)
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2020-11-30 20:00:31 +00:00
|
|
|
});
|
[TEST] E2E Tests for Teams (#3178)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Added deleteTeam function
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update index.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Update rocketchat.js
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Update RoomActionsView
* Update en.json
* updated deleteTeam function and permissions
* Added showConfirmationAlert
* Added string translations for teams
* Fix permission
* Added moveChannelToTeam and convertToTeam functionality
* Fix SelectListView RadioButton
* Fix moveToTeam
* Added searchBar to SelectListVIew
* Update RoomView , SelectListVIew and string translation for error
* E2E for Teams
* Fix tests and cleanup
* Minor refactor
* Wrong label
* Move/convert
* Fix convert
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-06-04 16:16:05 +00:00
|
|
|
},
|
|
|
|
testID: 'action-sheet-remove-from-room'
|
2020-11-30 20:00:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
showActionSheet({
|
|
|
|
options,
|
2020-06-15 19:35:45 +00:00
|
|
|
hasCancel: true
|
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-01-30 12:11:02 +00:00
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
const fetchMembers = async (status: boolean) => {
|
|
|
|
const { members, isLoading, end, room, filter, page } = state;
|
2021-09-16 16:26:05 +00:00
|
|
|
const { t } = room;
|
2022-08-19 17:27:04 +00:00
|
|
|
|
2019-04-17 17:01:03 +00:00
|
|
|
if (isLoading || end) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
updateState({ isLoading: true });
|
2019-04-08 12:35:28 +00:00
|
|
|
try {
|
2022-04-28 20:37:25 +00:00
|
|
|
const membersResult = await Services.getRoomMembers({
|
2022-08-26 13:21:25 +00:00
|
|
|
rid: room.rid,
|
2021-09-16 16:26:05 +00:00
|
|
|
roomType: t,
|
2022-08-26 13:21:25 +00:00
|
|
|
type: !status ? 'all' : 'online',
|
|
|
|
filter,
|
2022-08-19 17:27:04 +00:00
|
|
|
skip: PAGE_SIZE * page,
|
2021-10-01 20:37:50 +00:00
|
|
|
limit: PAGE_SIZE,
|
2022-08-26 13:21:25 +00:00
|
|
|
allUsers: !status
|
2021-09-16 16:26:05 +00:00
|
|
|
});
|
2022-08-19 17:27:04 +00:00
|
|
|
const end = membersResult?.length < PAGE_SIZE;
|
|
|
|
const membersResultFiltered = membersResult?.filter((member: TUserModel) => !members.some(m => m._id === member._id));
|
2022-08-26 13:21:25 +00:00
|
|
|
updateState({
|
|
|
|
members: [...members, ...membersResultFiltered],
|
2019-04-17 17:01:03 +00:00
|
|
|
isLoading: false,
|
2022-08-19 17:27:04 +00:00
|
|
|
end,
|
|
|
|
page: page + 1
|
2019-04-17 17:01:03 +00:00
|
|
|
});
|
2020-11-30 20:00:31 +00:00
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
2022-08-26 13:21:25 +00:00
|
|
|
updateState({ isLoading: false });
|
2020-11-30 20:00:31 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-11-30 20:00:31 +00:00
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
const filteredMembers =
|
|
|
|
state.members && state.members.length > 0 && state.filter
|
|
|
|
? state.members.filter(
|
|
|
|
m =>
|
|
|
|
m.username.toLowerCase().match(state.filter.toLowerCase()) || m.name?.toLowerCase().match(state.filter.toLowerCase())
|
|
|
|
)
|
|
|
|
: null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SafeAreaView testID='room-members-view'>
|
|
|
|
<StatusBar />
|
|
|
|
<FlatList
|
|
|
|
data={filteredMembers || state.members}
|
|
|
|
renderItem={({ item }) => (
|
|
|
|
<View style={{ backgroundColor: colors.backgroundColor }}>
|
|
|
|
<UserItem
|
|
|
|
name={item.name as string}
|
|
|
|
username={item.username}
|
|
|
|
onPress={() => onPressUser(item)}
|
|
|
|
testID={`room-members-view-item-${item.username}`}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
style={styles.list}
|
|
|
|
keyExtractor={item => item._id}
|
|
|
|
ItemSeparatorComponent={List.Separator}
|
|
|
|
ListHeaderComponent={
|
|
|
|
<>
|
|
|
|
<ActionsSection joined={params.joined as boolean} rid={state.room.rid} t={state.room.t} />
|
2022-09-23 02:03:02 +00:00
|
|
|
<SearchBox onChangeText={text => updateState({ filter: text.trim() })} testID='room-members-view-search' />
|
2022-08-26 13:21:25 +00:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
ListFooterComponent={() => (state.isLoading ? <ActivityIndicator /> : null)}
|
|
|
|
onEndReachedThreshold={0.1}
|
|
|
|
onEndReached={() => fetchMembers(state.allUsers)}
|
|
|
|
ListEmptyComponent={() =>
|
|
|
|
state.end ? <Text style={[styles.noResult, { color: colors.titleText }]}>{I18n.t('No_members_found')}</Text> : null
|
|
|
|
}
|
|
|
|
{...scrollPersistTaps}
|
2018-09-25 19:28:42 +00:00
|
|
|
/>
|
2022-08-26 13:21:25 +00:00
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
};
|
2019-08-07 13:51:34 +00:00
|
|
|
|
2022-08-26 13:21:25 +00:00
|
|
|
export default RoomMembersView;
|