Merge branch 'develop' into fix.switch-to-channel-with-thread-selected

This commit is contained in:
Reinaldo Neto 2021-07-12 16:43:25 -03:00 committed by GitHub
commit 9fe4666d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 162 additions and 25 deletions

View File

@ -756,7 +756,7 @@
"member-does-not-exist": "Member does not exist", "member-does-not-exist": "Member does not exist",
"Convert": "Convert", "Convert": "Convert",
"Convert_to_Team": "Convert to Team", "Convert_to_Team": "Convert to Team",
"Convert_to_Team_Warning": "This can't be undone. Once you convert a channel to a team, you can not turn it back to a channel.", "Convert_to_Team_Warning": "You are converting this Channel to a Team. All Members will be kept.",
"Move_to_Team": "Move to Team", "Move_to_Team": "Move to Team",
"Move_Channel_Paragraph": "Moving a channel inside a team means that this channel will be added in the teams context, however, all channels members, which are not members of the respective team, will still have access to this channel, but will not be added as teams members. \n\nAll channels management will still be made by the owners of this channel.\n\nTeams members and even teams owners, if not a member of this channel, can not have access to the channels content. \n\nPlease notice that the Teams owner will be able remove members from the Channel.", "Move_Channel_Paragraph": "Moving a channel inside a team means that this channel will be added in the teams context, however, all channels members, which are not members of the respective team, will still have access to this channel, but will not be added as teams members. \n\nAll channels management will still be made by the owners of this channel.\n\nTeams members and even teams owners, if not a member of this channel, can not have access to the channels content. \n\nPlease notice that the Teams owner will be able remove members from the Channel.",
"Move_to_Team_Warning": "After reading the previous intructions about this behavior, do you still want to move this channel to the selected team?", "Move_to_Team_Warning": "After reading the previous intructions about this behavior, do you still want to move this channel to the selected team?",
@ -765,5 +765,9 @@
"Load_Older": "Load Older", "Load_Older": "Load Older",
"Left_The_Room_Successfully": "Left the room successfully", "Left_The_Room_Successfully": "Left the room successfully",
"Deleted_The_Team_Successfully": "Team deleted successfully", "Deleted_The_Team_Successfully": "Team deleted successfully",
"Deleted_The_Room_Successfully": "Room deleted successfully" "Deleted_The_Room_Successfully": "Room deleted successfully",
"Convert_to_Channel": "Convert to Channel",
"Converting_Team_To_Channel": "Converting Team to Channel",
"Select_Team_Channels_To_Delete": "Select the Teams Channels you would like to delete, the ones you do not select will be moved to the Workspace. \n\nNotice that public Channels will be public and visible to everyone.",
"You_are_converting_the_team": "You are converting this Team to a Channel"
} }

View File

@ -669,5 +669,6 @@
"invalid-room": "Sala inválida", "invalid-room": "Sala inválida",
"Left_The_Room_Successfully": "Saiu da sala com sucesso", "Left_The_Room_Successfully": "Saiu da sala com sucesso",
"Deleted_The_Team_Successfully": "Time deletado com sucesso", "Deleted_The_Team_Successfully": "Time deletado com sucesso",
"Deleted_The_Room_Successfully": "Sala deletada com sucesso" "Deleted_The_Room_Successfully": "Sala deletada com sucesso",
"Convert_to_Channel": "Converter para um Canal"
} }

View File

@ -75,7 +75,7 @@ export default class Root extends React.Component {
theme: defaultTheme(), theme: defaultTheme(),
themePreferences: { themePreferences: {
currentTheme: supportSystemTheme() ? 'automatic' : 'light', currentTheme: supportSystemTheme() ? 'automatic' : 'light',
darkLevel: 'dark' darkLevel: 'black'
}, },
width, width,
height, height,

View File

@ -47,7 +47,8 @@ const PERMISSIONS = [
'view-statistics', 'view-statistics',
'view-user-administration', 'view-user-administration',
'view-all-teams', 'view-all-teams',
'view-all-team-channels' 'view-all-team-channels',
'convert-team'
]; ];
export async function setPermissions() { export async function setPermissions() {

View File

@ -866,6 +866,13 @@ const RocketChat = {
}; };
return this.sdk.post(type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam', params); return this.sdk.post(type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam', params);
}, },
convertTeamToChannel({ teamId, selected }) {
const params = {
teamId,
...(selected.length && { roomsToRemove: selected })
};
return this.sdk.post('teams.convertToChannel', params);
},
joinRoom(roomId, joinCode, type) { joinRoom(roomId, joinCode, type) {
// TODO: join code // TODO: join code
// RC 0.48.0 // RC 0.48.0

View File

@ -41,10 +41,10 @@ const handleRequest = function* handleRequest({ data }) {
encrypted encrypted
} = data; } = data;
logEvent(events.CT_CREATE, { logEvent(events.CT_CREATE, {
type, type: `${ type }`,
readOnly, readOnly: `${ readOnly }`,
broadcast, broadcast: `${ broadcast }`,
encrypted encrypted: `${ encrypted }`
}); });
const result = yield call(createTeam, data); const result = yield call(createTeam, data);
sub = { sub = {

View File

@ -124,7 +124,7 @@ class Root extends React.Component {
theme: defaultTheme(), theme: defaultTheme(),
themePreferences: { themePreferences: {
currentTheme: supportSystemTheme() ? 'automatic' : 'light', currentTheme: supportSystemTheme() ? 'automatic' : 'light',
darkLevel: 'dark' darkLevel: 'black'
}, },
root: '', root: '',
width, width,

View File

@ -259,6 +259,8 @@ export default {
RA_LEAVE_TEAM_F: 'ra_leave_team_f', RA_LEAVE_TEAM_F: 'ra_leave_team_f',
RA_CONVERT_TO_TEAM: 'ra_convert_to_team', RA_CONVERT_TO_TEAM: 'ra_convert_to_team',
RA_CONVERT_TO_TEAM_F: 'ra_convert_to_team_f', RA_CONVERT_TO_TEAM_F: 'ra_convert_to_team_f',
RA_CONVERT_TEAM_TO_CHANNEL: 'ra_convert_team_to_channel',
RA_CONVERT_TEAM_TO_CHANNEL_F: 'ra_convert_team_to_channel_f',
RA_MOVE_TO_TEAM: 'ra_move_to_team', RA_MOVE_TO_TEAM: 'ra_move_to_team',
RA_MOVE_TO_TEAM_F: 'ra_move_to_team_f', RA_MOVE_TO_TEAM_F: 'ra_move_to_team_f',
RA_SEARCH_TEAM: 'ra_search_team', RA_SEARCH_TEAM: 'ra_search_team',

View File

@ -39,16 +39,16 @@ const openLink = async(url, theme = 'light') => {
try { try {
const browser = await UserPreferences.getStringAsync(DEFAULT_BROWSER_KEY); const browser = await UserPreferences.getStringAsync(DEFAULT_BROWSER_KEY);
if (browser) { if (browser === 'inApp') {
const schemeUrl = appSchemeURL(url, browser.replace(':', ''));
await Linking.openURL(schemeUrl);
} else {
await WebBrowser.openBrowserAsync(url, { await WebBrowser.openBrowserAsync(url, {
toolbarColor: themes[theme].headerBackground, toolbarColor: themes[theme].headerBackground,
controlsColor: themes[theme].headerTintColor, controlsColor: themes[theme].headerTintColor,
collapseToolbar: true, collapseToolbar: true,
showTitle: true showTitle: true
}); });
} else {
const schemeUrl = appSchemeURL(url, browser.replace(':', ''));
await Linking.openURL(schemeUrl);
} }
} catch { } catch {
try { try {

View File

@ -83,7 +83,7 @@ class DefaultBrowserView extends React.Component {
isSelected = (value) => { isSelected = (value) => {
const { browser } = this.state; const { browser } = this.state;
if (!browser && value === 'inApp') { if (!browser && value === 'systemDefault:') {
return true; return true;
} }
return browser === value; return browser === value;
@ -92,7 +92,7 @@ class DefaultBrowserView extends React.Component {
changeDefaultBrowser = async(newBrowser) => { changeDefaultBrowser = async(newBrowser) => {
logEvent(events.DB_CHANGE_DEFAULT_BROWSER, { browser: newBrowser }); logEvent(events.DB_CHANGE_DEFAULT_BROWSER, { browser: newBrowser });
try { try {
const browser = newBrowser !== 'inApp' ? newBrowser : null; const browser = newBrowser !== 'systemDefault:' ? newBrowser : null;
await UserPreferences.setStringAsync(DEFAULT_BROWSER_KEY, browser); await UserPreferences.setStringAsync(DEFAULT_BROWSER_KEY, browser);
this.setState({ browser }); this.setState({ browser });
} catch { } catch {

View File

@ -67,7 +67,8 @@ class RoomActionsView extends React.Component {
viewBroadcastMemberListPermission: PropTypes.array, viewBroadcastMemberListPermission: PropTypes.array,
transferLivechatGuestPermission: PropTypes.array, transferLivechatGuestPermission: PropTypes.array,
createTeamPermission: PropTypes.array, createTeamPermission: PropTypes.array,
addTeamChannelPermission: PropTypes.array addTeamChannelPermission: PropTypes.array,
convertTeamPermission: PropTypes.array
} }
constructor(props) { constructor(props) {
@ -91,7 +92,8 @@ class RoomActionsView extends React.Component {
canEdit: false, canEdit: false,
canToggleEncryption: false, canToggleEncryption: false,
canCreateTeam: false, canCreateTeam: false,
canAddChannelToTeam: false canAddChannelToTeam: false,
canConvertTeam: false
}; };
if (room && room.observe && room.rid) { if (room && room.observe && room.rid) {
this.roomObservable = room.observe(); this.roomObservable = room.observe();
@ -142,9 +144,10 @@ class RoomActionsView extends React.Component {
const canViewMembers = await this.canViewMembers(); const canViewMembers = await this.canViewMembers();
const canCreateTeam = await this.canCreateTeam(); const canCreateTeam = await this.canCreateTeam();
const canAddChannelToTeam = await this.canAddChannelToTeam(); const canAddChannelToTeam = await this.canAddChannelToTeam();
const canConvertTeam = await this.canConvertTeam();
this.setState({ this.setState({
canAutoTranslate, canAddUser, canInviteUser, canEdit, canToggleEncryption, canViewMembers, canCreateTeam, canAddChannelToTeam canAutoTranslate, canAddUser, canInviteUser, canEdit, canToggleEncryption, canViewMembers, canCreateTeam, canAddChannelToTeam, canConvertTeam
}); });
// livechat permissions // livechat permissions
@ -240,6 +243,16 @@ class RoomActionsView extends React.Component {
return canAddChannelToTeam; return canAddChannelToTeam;
} }
canConvertTeam = async() => {
const { room } = this.state;
const { convertTeamPermission } = this.props;
const { rid } = room;
const permissions = await RocketChat.hasPermission([convertTeamPermission], rid);
const canConvertTeam = permissions[0];
return canConvertTeam;
}
canToggleEncryption = async() => { canToggleEncryption = async() => {
const { room } = this.state; const { room } = this.state;
const { toggleRoomE2EEncryptionPermission } = this.props; const { toggleRoomE2EEncryptionPermission } = this.props;
@ -433,6 +446,59 @@ class RoomActionsView extends React.Component {
}); });
} }
convertTeamToChannel = async() => {
const { room } = this.state;
const { navigation } = this.props;
try {
const result = await RocketChat.teamListRoomsOfUser({ teamId: room.teamId, userId: room.u._id });
if (result.rooms?.length) {
const teamChannels = result.rooms.map(r => ({
rid: r._id,
name: r.name,
teamId: r.teamId
}));
navigation.navigate('SelectListView', {
title: 'Converting_Team_To_Channel',
data: teamChannels,
infoText: 'Select_Team_Channels_To_Delete',
nextAction: data => this.convertTeamToChannelConfirmation(data)
});
} else {
this.convertTeamToChannelConfirmation();
}
} catch (e) {
this.convertTeamToChannelConfirmation();
}
}
handleConvertTeamToChannel = async(selected) => {
logEvent(events.RA_CONVERT_TEAM_TO_CHANNEL);
try {
const { room } = this.state;
const { navigation } = this.props;
const result = await RocketChat.convertTeamToChannel({ teamId: room.teamId, selected });
if (result.success) {
navigation.navigate('RoomView');
}
} catch (e) {
logEvent(events.RA_CONVERT_TEAM_TO_CHANNEL_F);
log(e);
}
}
convertTeamToChannelConfirmation = (selected = []) => {
showConfirmationAlert({
title: I18n.t('Confirmation'),
message: I18n.t('You_are_converting_the_team'),
confirmationText: I18n.t('Convert'),
onPress: () => this.handleConvertTeamToChannel(selected)
});
}
leaveTeam = async() => { leaveTeam = async() => {
const { room } = this.state; const { room } = this.state;
const { navigation, leaveRoom } = this.props; const { navigation, leaveRoom } = this.props;
@ -806,6 +872,32 @@ class RoomActionsView extends React.Component {
); );
} }
teamToChannelActions = (t, room) => {
const { canEdit, canConvertTeam } = this.state;
const canConvertTeamToChannel = canEdit && canConvertTeam && !!room?.teamMain;
return (
<>
{['c', 'p'].includes(t) && canConvertTeamToChannel
? (
<>
<List.Item
title='Convert_to_Channel'
onPress={() => this.onPressTouchable({
event: this.convertTeamToChannel
})}
testID='room-actions-convert-channel-to-team'
left={() => <List.Icon name='channel-public' />}
showActionIndicator
/>
<List.Separator />
</>
)
: null}
</>
);
}
render() { render() {
const { const {
room, membersCount, canViewMembers, canAddUser, canInviteUser, joined, canAutoTranslate, canForwardGuest, canReturnQueue room, membersCount, canViewMembers, canAddUser, canInviteUser, joined, canAutoTranslate, canForwardGuest, canReturnQueue
@ -1007,7 +1099,9 @@ class RoomActionsView extends React.Component {
) )
: null} : null}
{ this.teamChannelActions(t, room) } { this.teamChannelActions(t, room) }
{this.teamToChannelActions(t, room)}
{['l'].includes(t) && !this.isOmnichannelPreview {['l'].includes(t) && !this.isOmnichannelPreview
? ( ? (
@ -1099,7 +1193,8 @@ const mapStateToProps = state => ({
viewBroadcastMemberListPermission: state.permissions['view-broadcast-member-list'], viewBroadcastMemberListPermission: state.permissions['view-broadcast-member-list'],
transferLivechatGuestPermission: state.permissions['transfer-livechat-guest'], transferLivechatGuestPermission: state.permissions['transfer-livechat-guest'],
createTeamPermission: state.permissions['create-team'], createTeamPermission: state.permissions['create-team'],
addTeamChannelPermission: state.permissions['add-team-channel'] addTeamChannelPermission: state.permissions['add-team-channel'],
convertTeamPermission: state.permissions['convert-team']
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({

View File

@ -30,14 +30,14 @@ const THEMES = [
label: 'Dark', label: 'Dark',
value: 'dark', value: 'dark',
group: THEME_GROUP group: THEME_GROUP
}, {
label: 'Dark',
value: 'dark',
group: DARK_GROUP
}, { }, {
label: 'Black', label: 'Black',
value: 'black', value: 'black',
group: DARK_GROUP group: DARK_GROUP
}, {
label: 'Dark',
value: 'dark',
group: DARK_GROUP
} }
]; ];

View File

@ -51,7 +51,7 @@ describe('Move/Convert Team', () => {
await element(by.id('room-actions-scrollview')).scrollTo('bottom'); await element(by.id('room-actions-scrollview')).scrollTo('bottom');
await waitFor(element(by.id('room-actions-convert-to-team'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-actions-convert-to-team'))).toExist().withTimeout(2000);
await element(by.id('room-actions-convert-to-team')).tap(); await element(by.id('room-actions-convert-to-team')).tap();
await waitFor(element(by.label('This can\'t be undone. Once you convert a channel to a team, you can not turn it back to a channel.'))).toExist().withTimeout(2000); await waitFor(element(by.label('You are converting this Channel to a Team. All Members will be kept.'))).toExist().withTimeout(2000);
await element(by.text('Convert')).tap(); await element(by.text('Convert')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000); await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);
await waitFor(element(by.id(`room-view-title-${ toBeConverted }`))).toExist().withTimeout(6000); await waitFor(element(by.id(`room-view-title-${ toBeConverted }`))).toExist().withTimeout(6000);
@ -84,5 +84,32 @@ describe('Move/Convert Team', () => {
await element(by.text('Yes, move it!')).tap(); await element(by.text('Yes, move it!')).tap();
await waitFor(element(by.id('room-view-header-team-channels'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-view-header-team-channels'))).toExist().withTimeout(10000);
}); });
after(async() => {
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
});
});
describe('Convert Team to Channel and Delete toBeMoved channel within the Converted', () => {
it('should convert a team to a channel', async() => {
await navigateToRoomActions(toBeConverted);
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
await waitFor(element(by.id('room-actions-convert-channel-to-team'))).toExist().withTimeout(2000);
await element(by.id('room-actions-convert-channel-to-team')).tap();
await sleep(2000);
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${ toBeMoved }`))).toExist().withTimeout(2000);
await element(by.id(`select-list-view-item-${ toBeMoved }`)).tap();
await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);
await element(by.id('select-list-view-submit')).tap();
await waitFor(element(by.label('You are converting this Team to a Channel'))).toExist().withTimeout(2000);
await element(by.text('Convert')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);
await waitFor(element(by.id(`room-view-title-${ toBeConverted }`))).toExist().withTimeout(6000);
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ toBeMoved }`))).toBeNotVisible().withTimeout(60000);
});
}); });
}); });