Skip to content
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

[NEW] Add/Create/Remove channel on a team #3090

Merged
merged 43 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2f5f247
Added Create Team
gerzonc Apr 19, 2021
c8a88c9
Merge branch 'develop' into new.create-team
gerzonc Apr 19, 2021
585a9ae
Merge branch 'develop' into new.create-team
gerzonc Apr 19, 2021
8b82bd4
Added actionTypes, actions, ENG strings for Teams and updated NewMess…
gerzonc Apr 20, 2021
c8b8680
Added createTeam sagas, createTeam reducer, new Team string and updat…
gerzonc Apr 20, 2021
a245af6
Remove unnecessary actionTypes, reducers and sagas, e2e tests and nav…
gerzonc Apr 23, 2021
16fd575
Minor tweaks
gerzonc Apr 26, 2021
1ff7711
Show TeamChannelsView only if joined the team
gerzonc Apr 26, 2021
69214be
Minor tweak
gerzonc Apr 26, 2021
0cf173d
Added AddChannelTeamView
gerzonc Apr 26, 2021
27ced96
Merge branch 'develop' into new.create-team
gerzonc Apr 28, 2021
37421d3
Merge branch 'develop' into new.add-remove-channel-teams
gerzonc Apr 29, 2021
bb0632b
Added permissions, translations strings for teams, deleteTeamRoom an…
gerzonc Apr 30, 2021
c3ffa37
Refactor touch component and update removeRoom and deleteRoom methods
gerzonc May 4, 2021
69ae247
Minor tweaks
gerzonc May 5, 2021
4761e21
Minor tweaks for removing channels and addExistingChannelView
gerzonc May 5, 2021
7d2924e
Added missing events and fixed channels list
gerzonc May 5, 2021
4bac054
Minor tweaks for refactored touch component
gerzonc May 5, 2021
7e6a277
Minor tweaks
gerzonc May 11, 2021
cb44fdf
Merge branch 'develop' into new.add-remove-channel-teams
gerzonc May 11, 2021
c890ed3
Merge branch 'new.create-team' into new.add-remove-channel-teams
gerzonc May 11, 2021
feb7862
Merge branch 'new.add-remove-channel-teams' of https://github.com/Roc…
gerzonc May 11, 2021
be3517f
Remove unnecesary changes, update TeamChannelsView, AddExistingChanne…
gerzonc May 11, 2021
7fb1e50
Merge branch 'develop' into new.add-remove-channel-teams
gerzonc May 13, 2021
2d50417
Add screens to ModalStack, events, autoJoin, update createChannel, ad…
gerzonc May 13, 2021
79b1123
Minor tweak
gerzonc May 13, 2021
70e503a
Update loadMessagesForRoom.js
gerzonc May 13, 2021
f42988a
Updated schema, tag component, touch, AddChannelTeamView, AddExisting…
gerzonc May 14, 2021
9820e6e
Fix unnecessary changes
gerzonc May 14, 2021
682dd21
Add i18n, update createChannel, AddExistingChannelTeamView, AddChanne…
gerzonc May 14, 2021
d3fb789
Updated styles, added tag story
gerzonc May 14, 2021
79334af
Minor tweak
gerzonc May 17, 2021
09d6307
Minor tweaks
gerzonc May 17, 2021
4859014
Auto-join tweak
diegolmello May 17, 2021
2fa4ebe
Minor tweaks
gerzonc May 18, 2021
30caba1
Minor tweak on search
gerzonc May 18, 2021
380fe37
One way to refactor :P
diegolmello May 19, 2021
3fb9b73
Next level refactor :)
diegolmello May 19, 2021
cb00330
Fix create group dm
diegolmello May 19, 2021
5ff1225
Refactor renderItem
diegolmello May 19, 2021
0c0b543
Minor bug fixes
diegolmello May 19, 2021
c580ca4
Fix stories
diegolmello May 19, 2021
b59ab64
Merge branch 'develop' into new.add-remove-channel-teams
diegolmello May 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21,893 changes: 11,888 additions & 10,005 deletions __tests__/__snapshots__/Storyshots.test.js.snap

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions app/containers/ActionSheet/Item.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Text } from 'react-native';
import { Text, View } from 'react-native';

import { themes } from '../../constants/colors';
import { CustomIcon } from '../../lib/Icons';
Expand All @@ -20,12 +20,19 @@ export const Item = React.memo(({ item, hide, theme }) => {
theme={theme}
>
<CustomIcon name={item.icon} size={20} color={item.danger ? themes[theme].dangerColor : themes[theme].bodyText} />
<Text
numberOfLines={1}
style={[styles.title, { color: item.danger ? themes[theme].dangerColor : themes[theme].bodyText }]}
>
{item.title}
</Text>
<View style={styles.titleContainer}>
<Text
numberOfLines={1}
style={[styles.title, { color: item.danger ? themes[theme].dangerColor : themes[theme].bodyText }]}
>
{item.title}
</Text>
</View>
{ item.right ? (
<View style={styles.rightContainer}>
{item.right ? item.right() : null}
</View>
) : null }
</Button>
);
});
Expand All @@ -34,7 +41,8 @@ Item.propTypes = {
title: PropTypes.string,
icon: PropTypes.string,
danger: PropTypes.bool,
onPress: PropTypes.func
onPress: PropTypes.func,
right: PropTypes.func
}),
hide: PropTypes.func,
theme: PropTypes.string
Expand Down
6 changes: 6 additions & 0 deletions app/containers/ActionSheet/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default StyleSheet.create({
content: {
paddingTop: 16
},
titleContainer: {
flex: 1
},
title: {
fontSize: 16,
marginLeft: 16,
Expand Down Expand Up @@ -58,5 +61,8 @@ export default StyleSheet.create({
fontSize: 16,
...sharedStyles.textMedium,
...sharedStyles.textAlignCenter
},
rightContainer: {
paddingLeft: 12
}
});
1 change: 1 addition & 0 deletions app/containers/RoomTypeIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const RoomTypeIcon = React.memo(({
return <Status style={[iconStyle, { color: STATUS_COLORS[status] ?? STATUS_COLORS.offline }]} size={size} status={status} />;
}

// TODO: move this to a separate function
let icon = 'channel-private';
if (teamMain) {
icon = `teams${ type === 'p' ? '-private' : '' }`;
Expand Down
14 changes: 12 additions & 2 deletions app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@
"Review_app_unable_store": "Unable to open {{store}}",
"Review_this_app": "Review this app",
"Remove": "Remove",
"remove": "remove",
"Roles": "Roles",
"Room_actions": "Room actions",
"Room_changed_announcement": "Room announcement changed to: {{announcement}} by {{userBy}}",
Expand Down Expand Up @@ -716,5 +717,14 @@
"Read_Only_Team": "Read Only Team",
"Broadcast_Team": "Broadcast Team",
"creating_team": "creating team",
"team-name-already-exists": "A team with that name already exists"
}
"team-name-already-exists": "A team with that name already exists",
"Add_Channel_to_Team": "Add Channel to Team",
"Create_New": "Create New",
"Add_Existing": "Add Existing",
"Add_Existing_Channel": "Add Existing Channel",
"Remove_from_Team": "Remove from Team",
"Auto-join": "Auto-join",
"Delete_Team_Room_Warning": "Woud you like to remove this channel from the team? The channel will be moved back to the workspace",
"Confirmation": "Confirmation",
"invalid-room": "Invalid room"
}
7 changes: 6 additions & 1 deletion app/lib/methods/getPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const PERMISSIONS = [
'add-user-to-any-c-room',
'add-user-to-any-p-room',
'add-user-to-joined-room',
'add-team-channel',
'archive-room',
'auto-translate',
'create-invite-links',
Expand All @@ -21,11 +22,13 @@ const PERMISSIONS = [
'delete-p',
'edit-message',
'edit-room',
'edit-team-channel',
'force-delete-message',
'mute-user',
'pin-message',
'post-readonly',
'remove-user',
'remove-team-channel',
'set-leader',
'set-moderator',
'set-owner',
Expand All @@ -38,7 +41,9 @@ const PERMISSIONS = [
'view-privileged-setting',
'view-room-administration',
'view-statistics',
'view-user-administration'
'view-user-administration',
'view-all-teams',
'view-all-team-channels'
];

export async function setPermissions() {
Expand Down
30 changes: 26 additions & 4 deletions app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,19 @@ const RocketChat = {
},
canOpenRoom,
createChannel({
name, users, type, readOnly, broadcast, encrypted
name, users, type, readOnly, broadcast, encrypted, teamId
}) {
// RC 0.51.0
return this.methodCallWrapper(type ? 'createPrivateGroup' : 'createChannel', name, users, readOnly, {}, { broadcast, encrypted });
const params = {
name,
members: users,
readOnly,
extraData: {
broadcast,
encrypted,
...(teamId && { teamId })
}
};
return this.post(type ? 'groups.create' : 'channels.create', params);
},
async getWebsocketInfo({ server }) {
const sdk = new RocketchatClient({ host: server, protocol: 'ddp', useSsl: useSsl(server) });
Expand Down Expand Up @@ -648,7 +657,8 @@ const RocketChat = {
avatarETag: sub.avatarETag,
t: sub.t,
encrypted: sub.encrypted,
lastMessage: sub.lastMessage
lastMessage: sub.lastMessage,
...(sub.teamId && { teamId: sub.teamId })
}));

return data;
Expand Down Expand Up @@ -751,6 +761,18 @@ const RocketChat = {
// RC 3.13.0
return this.post('teams.create', params);
},
addRoomsToTeam({ teamId, rooms }) {
// RC 3.13.0
return this.post('teams.addRooms', { teamId, rooms });
},
removeTeamRoom({ roomId, teamId }) {
// RC 3.13.0
return this.post('teams.removeRoom', { roomId, teamId });
},
updateTeamRoom({ roomId, isDefault }) {
// RC 3.13.0
return this.post('teams.updateRoom', { roomId, isDefault });
},
joinRoom(roomId, joinCode, type) {
// TODO: join code
// RC 0.48.0
Expand Down
17 changes: 15 additions & 2 deletions app/presentation/RoomItem/RoomItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import LastMessage from './LastMessage';
import Title from './Title';
import UpdatedAt from './UpdatedAt';
import Touchable from './Touchable';
import Tag from './Tag';
import I18n from '../../i18n';

const RoomItem = ({
rid,
Expand Down Expand Up @@ -42,13 +44,16 @@ const RoomItem = ({
testID,
swipeEnabled,
onPress,
onLongPress,
toggleFav,
toggleRead,
hideChannel,
teamMain
teamMain,
autoJoin
}) => (
<Touchable
onPress={onPress}
onLongPress={onLongPress}
width={width}
favorite={favorite}
toggleFav={toggleFav}
Expand Down Expand Up @@ -88,6 +93,9 @@ const RoomItem = ({
hideUnreadStatus={hideUnreadStatus}
alert={alert}
/>
{
autoJoin ? <Tag name={I18n.t('Auto-join')} /> : null
}
<UpdatedAt
date={date}
theme={theme}
Expand Down Expand Up @@ -132,6 +140,9 @@ const RoomItem = ({
hideUnreadStatus={hideUnreadStatus}
alert={alert}
/>
{
autoJoin ? <Tag name={I18n.t('Auto-join')} /> : null
}
<UnreadBadge
unread={unread}
userMentions={userMentions}
Expand Down Expand Up @@ -181,7 +192,9 @@ RoomItem.propTypes = {
toggleFav: PropTypes.func,
toggleRead: PropTypes.func,
onPress: PropTypes.func,
hideChannel: PropTypes.func
onLongPress: PropTypes.func,
hideChannel: PropTypes.func,
autoJoin: PropTypes.bool
};

RoomItem.defaultProps = {
Expand Down
30 changes: 30 additions & 0 deletions app/presentation/RoomItem/Tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { Text, View } from 'react-native';
import PropTypes from 'prop-types';

import { themes } from '../../constants/colors';
import { useTheme } from '../../theme';
import styles from './styles';

const Tag = React.memo(({ name }) => {
const { theme } = useTheme();

return (
<View style={[styles.tagContainer, { backgroundColor: themes[theme].borderColor }]}>
<Text
style={[
styles.tagText, { color: themes[theme].infoText }
]}
numberOfLines={1}
>
{name}
</Text>
</View>
);
});

Tag.propTypes = {
name: PropTypes.string
};

export default Tag;
Loading