Skip to content

Commit f64f293

Browse files
authored
Merge pull request element-hq#5125 from vector-im/luke/groups-add-rooms
Implement "Add room to group" feature
2 parents 94855c0 + 888e3ab commit f64f293

5 files changed

Lines changed: 67 additions & 20 deletions

File tree

‎src/components/structures/RightPanel.js‎

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
2525
import Analytics from 'matrix-react-sdk/lib/Analytics';
2626
import rate_limited_func from 'matrix-react-sdk/lib/ratelimitedfunc';
2727
import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton';
28-
import { showGroupInviteDialog } from 'matrix-react-sdk/lib/GroupInvite';
28+
import { showGroupInviteDialog, showGroupAddRoomDialog } from 'matrix-react-sdk/lib/GroupAddressPicker';
2929

3030
class HeaderButton extends React.Component {
3131
constructor() {
@@ -87,6 +87,7 @@ module.exports = React.createClass({
8787
Phase: {
8888
RoomMemberList: 'RoomMemberList',
8989
GroupMemberList: 'GroupMemberList',
90+
GroupRoomList: 'GroupRoomList',
9091
FilePanel: 'FilePanel',
9192
NotificationPanel: 'NotificationPanel',
9293
RoomMemberInfo: 'RoomMemberInfo',
@@ -132,6 +133,10 @@ module.exports = React.createClass({
132133

133134
if (this.state.phase === this.Phase.GroupMemberList) {
134135
showGroupInviteDialog(this.props.groupId);
136+
} else if (this.state.phase === this.Phase.GroupRoomList) {
137+
showGroupAddRoomDialog(this.props.groupId).then(() => {
138+
this.forceUpdate();
139+
});
135140
} else {
136141
// call AddressPickerDialog
137142
dis.dispatch({
@@ -205,10 +210,16 @@ module.exports = React.createClass({
205210

206211
render: function() {
207212
const MemberList = sdk.getComponent('rooms.MemberList');
208-
const GroupMemberList = sdk.getComponent('groups.GroupMemberList');
213+
const MemberInfo = sdk.getComponent('rooms.MemberInfo');
209214
const NotificationPanel = sdk.getComponent('structures.NotificationPanel');
210215
const FilePanel = sdk.getComponent('structures.FilePanel');
216+
217+
const GroupMemberList = sdk.getComponent('groups.GroupMemberList');
218+
const GroupMemberInfo = sdk.getComponent('groups.GroupMemberInfo');
219+
const GroupRoomList = sdk.getComponent('groups.GroupRoomList');
220+
211221
const TintableSvg = sdk.getComponent("elements.TintableSvg");
222+
212223
let inviteGroup;
213224

214225
let membersBadge;
@@ -256,6 +267,19 @@ module.exports = React.createClass({
256267
analytics={['Right Panel', 'Notification List Button', 'click']}
257268
/>,
258269
];
270+
} else if (this.props.groupId) {
271+
headerButtons = [
272+
<HeaderButton key="_groupMembersButton" title={_t('Members')} iconSrc="img/icons-people.svg"
273+
isHighlighted={this.state.phase === this.Phase.GroupMemberList}
274+
clickPhase={this.Phase.GroupMemberList}
275+
analytics={['Right Panel', 'Group Member List Button', 'click']}
276+
/>,
277+
<HeaderButton key="_roomsButton" title={_t('Rooms')} iconSrc="img/icons-files.svg"
278+
isHighlighted={this.state.phase === this.Phase.GroupRoomList}
279+
clickPhase={this.Phase.GroupRoomList}
280+
analytics={['Right Panel', 'Group Room List Button', 'click']}
281+
/>,
282+
];
259283
}
260284

261285
if (this.props.roomId || this.props.groupId) {
@@ -277,19 +301,11 @@ module.exports = React.createClass({
277301
panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} />;
278302
} else if (this.props.groupId && this.state.phase == this.Phase.GroupMemberList) {
279303
panel = <GroupMemberList groupId={this.props.groupId} key={this.props.groupId} />;
280-
inviteGroup = (
281-
<AccessibleButton className="mx_RightPanel_invite" onClick={ this.onInviteButtonClick } >
282-
<div className="mx_RightPanel_icon" >
283-
<TintableSvg src="img/icon-invite-people.svg" width="35" height="35" />
284-
</div>
285-
<div className="mx_RightPanel_message">{ _t('Invite to this group') }</div>
286-
</AccessibleButton>
287-
);
304+
} else if (this.state.phase === this.Phase.GroupRoomList) {
305+
panel = <GroupRoomList groupId={this.props.groupId} key={this.props.groupId} />;
288306
} else if (this.state.phase == this.Phase.RoomMemberInfo) {
289-
const MemberInfo = sdk.getComponent('rooms.MemberInfo');
290307
panel = <MemberInfo member={this.state.member} key={this.props.roomId || this.state.member.userId} />;
291308
} else if (this.state.phase == this.Phase.GroupMemberInfo) {
292-
const GroupMemberInfo = sdk.getComponent('groups.GroupMemberInfo');
293309
panel = <GroupMemberInfo
294310
groupMember={this.state.member}
295311
groupId={this.props.groupId}
@@ -305,6 +321,24 @@ module.exports = React.createClass({
305321
panel = <div className="mx_RightPanel_blank"></div>;
306322
}
307323

324+
if (this.props.groupId) {
325+
inviteGroup = this.state.phase === this.Phase.GroupMemberList ? (
326+
<AccessibleButton className="mx_RightPanel_invite" onClick={ this.onInviteButtonClick } >
327+
<div className="mx_RightPanel_icon" >
328+
<TintableSvg src="img/icon-invite-people.svg" width="35" height="35" />
329+
</div>
330+
<div className="mx_RightPanel_message">{ _t('Invite to this group') }</div>
331+
</AccessibleButton>
332+
) : (
333+
<AccessibleButton className="mx_RightPanel_invite" onClick={ this.onInviteButtonClick } >
334+
<div className="mx_RightPanel_icon" >
335+
<TintableSvg src="img/icons-files.svg" width="35" height="35" />
336+
</div>
337+
<div className="mx_RightPanel_message">{ _t('Add room to this group') }</div>
338+
</AccessibleButton>
339+
);
340+
}
341+
308342
let classes = "mx_RightPanel mx_fadable";
309343
if (this.props.collapsed) {
310344
classes += " collapsed";

‎src/i18n/strings/en_EN.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,6 @@
220220
"To return to your account in future you need to <u>set a password</u>": "To return to your account in future you need to <u>set a password</u>",
221221
"Set Password": "Set Password",
222222
"Couldn't load home page": "Couldn't load home page",
223-
"Invite to this group": "Invite to this group"
223+
"Invite to this group": "Invite to this group",
224+
"Add room to this group": "Add room to this group"
224225
}

‎src/skins/vector/css/matrix-react-sdk/views/rooms/_EntityTile.scss‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
.mx_EntityTile {
17+
.mx_EntityTile,
18+
.mx_GroupRoomTile {
1819
display: table-row;
1920
position: relative;
2021
color: $primary-fg-color;
@@ -28,7 +29,8 @@ limitations under the License.
2829
width: 26px;
2930
}
3031

31-
.mx_EntityTile_avatar {
32+
.mx_EntityTile_avatar,
33+
.mx_GroupRoomTile_avatar {
3234
display: table-cell;
3335
padding-left: 3px;
3436
padding-right: 12px;
@@ -48,7 +50,8 @@ limitations under the License.
4850
right: 6px;
4951
}
5052

51-
.mx_EntityTile_name {
53+
.mx_EntityTile_name,
54+
.mx_GroupRoomTile_name {
5255
display: table-cell;
5356
vertical-align: middle;
5457
overflow: hidden;

‎src/skins/vector/css/matrix-react-sdk/views/rooms/_MemberList.scss‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
.mx_MemberList {
17+
.mx_MemberList,
18+
.mx_GroupMemberList,
19+
.mx_GroupRoomList {
1820
height: 100%;
1921

2022
margin-top: 12px;
@@ -44,7 +46,9 @@ limitations under the License.
4446
flex: 1 1 0px;
4547
}
4648

47-
.mx_MemberList_query {
49+
.mx_MemberList_query,
50+
.mx_GroupMemberList_query,
51+
.mx_GroupRoomList_query {
4852
font-family: 'Open Sans', Arial, Helvetica, Sans-Serif;
4953
border-radius: 3px;
5054
border: 1px solid $input-border-color;
@@ -57,13 +61,17 @@ limitations under the License.
5761
width: 189px;
5862
}
5963

60-
.mx_MemberList_query::-moz-placeholder {
64+
.mx_MemberList_query::-moz-placeholder,
65+
.mx_GroupMemberList_query::-moz-placeholder,
66+
.mx_GroupRoomList_query::-moz-placeholder {
6167
color: $primary-fg-color;
6268
opacity: 0.5;
6369
font-size: 14px;
6470
}
6571

66-
.mx_MemberList_query::-webkit-input-placeholder {
72+
.mx_MemberList_query::-webkit-input-placeholder,
73+
.mx_GroupMemberList_query::-webkit-input-placeholder,
74+
.mx_GroupRoomList_query::-webkit-input-placeholder {
6775
color: $primary-fg-color;
6876
opacity: 0.5;
6977
font-size: 14px;

‎src/skins/vector/css/vector-web/structures/_RightPanel.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ limitations under the License.
7878

7979
.mx_RightPanel .mx_MemberList,
8080
.mx_RightPanel .mx_MemberInfo,
81+
.mx_RightPanel .mx_GroupRoomList,
8182
.mx_RightPanel_blank {
8283
order: 2;
8384
flex: 1 1 0;

0 commit comments

Comments
 (0)