2018-10-30 19:15:19 +03:00
|
|
|
/*
|
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
|
|
|
Copyright 2017 Vector Creations Ltd
|
|
|
|
Copyright 2017 New Vector Ltd
|
|
|
|
Copyright 2018 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { _t } from '../../../languageHandler';
|
|
|
|
import HeaderButton from './HeaderButton';
|
|
|
|
import HeaderButtons from './HeaderButtons';
|
|
|
|
import RightPanel from '../../structures/RightPanel';
|
|
|
|
|
2019-04-11 14:31:21 +03:00
|
|
|
const GROUP_PHASES = [
|
|
|
|
RightPanel.Phase.GroupMemberInfo,
|
|
|
|
RightPanel.Phase.GroupMemberList,
|
|
|
|
];
|
|
|
|
const ROOM_PHASES = [
|
|
|
|
RightPanel.Phase.GroupRoomList,
|
|
|
|
RightPanel.Phase.GroupRoomInfo,
|
|
|
|
];
|
|
|
|
|
2018-10-30 19:15:19 +03:00
|
|
|
export default class GroupHeaderButtons extends HeaderButtons {
|
|
|
|
constructor(props) {
|
|
|
|
super(props, RightPanel.Phase.GroupMemberList);
|
2019-04-11 14:22:47 +03:00
|
|
|
this._onMembersClicked = this._onMembersClicked.bind(this);
|
|
|
|
this._onRoomsClicked = this._onRoomsClicked.bind(this);
|
2018-10-30 19:15:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onAction(payload) {
|
|
|
|
super.onAction(payload);
|
|
|
|
|
|
|
|
if (payload.action === "view_user") {
|
|
|
|
if (payload.member) {
|
|
|
|
this.setPhase(RightPanel.Phase.RoomMemberInfo, {member: payload.member});
|
|
|
|
} else {
|
|
|
|
this.setPhase(RightPanel.Phase.GroupMemberList);
|
|
|
|
}
|
|
|
|
} else if (payload.action === "view_group") {
|
|
|
|
this.setPhase(RightPanel.Phase.GroupMemberList);
|
|
|
|
} else if (payload.action === "view_group_room") {
|
2018-12-10 18:52:45 +03:00
|
|
|
this.setPhase(RightPanel.Phase.GroupRoomInfo, {groupRoomId: payload.groupRoomId, groupId: payload.groupId});
|
2018-10-30 19:15:19 +03:00
|
|
|
} else if (payload.action === "view_group_room_list") {
|
|
|
|
this.setPhase(RightPanel.Phase.GroupRoomList);
|
|
|
|
} else if (payload.action === "view_group_member_list") {
|
|
|
|
this.setPhase(RightPanel.Phase.GroupMemberList);
|
|
|
|
} else if (payload.action === "view_group_user") {
|
|
|
|
this.setPhase(RightPanel.Phase.GroupMemberInfo, {member: payload.member});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-11 14:22:47 +03:00
|
|
|
_onMembersClicked() {
|
2019-04-11 14:31:21 +03:00
|
|
|
this.togglePhase(RightPanel.Phase.GroupMemberList, GROUP_PHASES);
|
2019-04-11 14:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
_onRoomsClicked() {
|
2019-04-11 14:31:21 +03:00
|
|
|
this.togglePhase(RightPanel.Phase.GroupRoomList, ROOM_PHASES);
|
2019-04-11 14:22:47 +03:00
|
|
|
}
|
|
|
|
|
2018-10-30 19:15:19 +03:00
|
|
|
renderButtons() {
|
|
|
|
return [
|
2019-02-12 20:31:47 +03:00
|
|
|
<HeaderButton key="groupMembersButton" name="groupMembersButton"
|
|
|
|
title={_t('Members')}
|
2019-04-11 14:31:21 +03:00
|
|
|
isHighlighted={this.isPhase(GROUP_PHASES)}
|
2019-04-11 14:22:47 +03:00
|
|
|
onClick={this._onMembersClicked}
|
2018-10-30 19:15:19 +03:00
|
|
|
analytics={['Right Panel', 'Group Member List Button', 'click']}
|
|
|
|
/>,
|
2019-02-12 20:31:47 +03:00
|
|
|
<HeaderButton key="roomsButton" name="roomsButton"
|
|
|
|
title={_t('Rooms')}
|
2019-04-11 14:31:21 +03:00
|
|
|
isHighlighted={this.isPhase(ROOM_PHASES)}
|
2019-04-11 14:22:47 +03:00
|
|
|
onClick={this._onRoomsClicked}
|
2018-10-30 19:15:19 +03:00
|
|
|
analytics={['Right Panel', 'Group Room List Button', 'click']}
|
2018-10-31 14:20:10 +03:00
|
|
|
/>,
|
2018-10-30 19:15:19 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|