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
|
2020-01-29 01:06:04 +03:00
|
|
|
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
|
2018-10-30 19:15:19 +03:00
|
|
|
|
|
|
|
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';
|
2020-09-08 17:39:58 +03:00
|
|
|
import {_t} from '../../../languageHandler';
|
2018-10-30 19:15:19 +03:00
|
|
|
import HeaderButton from './HeaderButton';
|
2020-07-18 14:08:20 +03:00
|
|
|
import HeaderButtons, {HeaderKind} from './HeaderButtons';
|
|
|
|
import {RightPanelPhases} from "../../../stores/RightPanelStorePhases";
|
2020-05-14 06:03:12 +03:00
|
|
|
import {Action} from "../../../dispatcher/actions";
|
|
|
|
import {ActionPayload} from "../../../dispatcher/payloads";
|
2020-09-08 18:27:09 +03:00
|
|
|
import RightPanelStore from "../../../stores/RightPanelStore";
|
2021-03-09 06:12:00 +03:00
|
|
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
2018-10-30 19:15:19 +03:00
|
|
|
|
2020-09-08 10:48:03 +03:00
|
|
|
const ROOM_INFO_PHASES = [
|
|
|
|
RightPanelPhases.RoomSummary,
|
|
|
|
RightPanelPhases.Widget,
|
|
|
|
RightPanelPhases.FilePanel,
|
2020-07-18 14:08:20 +03:00
|
|
|
RightPanelPhases.RoomMemberList,
|
|
|
|
RightPanelPhases.RoomMemberInfo,
|
|
|
|
RightPanelPhases.EncryptionPanel,
|
|
|
|
RightPanelPhases.Room3pidMemberInfo,
|
2019-04-11 14:31:21 +03:00
|
|
|
];
|
|
|
|
|
2021-03-09 06:12:00 +03:00
|
|
|
@replaceableComponent("views.right_panel.RoomHeaderButtons")
|
2018-10-30 19:15:19 +03:00
|
|
|
export default class RoomHeaderButtons extends HeaderButtons {
|
|
|
|
constructor(props) {
|
2020-07-18 14:08:20 +03:00
|
|
|
super(props, HeaderKind.Room);
|
2018-10-30 19:15:19 +03:00
|
|
|
}
|
|
|
|
|
2020-07-30 13:43:13 +03:00
|
|
|
protected onAction(payload: ActionPayload) {
|
2020-05-14 06:03:12 +03:00
|
|
|
if (payload.action === Action.ViewUser) {
|
2018-10-30 19:15:19 +03:00
|
|
|
if (payload.member) {
|
2020-07-29 14:29:29 +03:00
|
|
|
this.setPhase(RightPanelPhases.RoomMemberInfo, {member: payload.member});
|
2018-10-30 19:15:19 +03:00
|
|
|
} else {
|
2020-07-18 14:08:20 +03:00
|
|
|
this.setPhase(RightPanelPhases.RoomMemberList);
|
2018-10-30 19:15:19 +03:00
|
|
|
}
|
2019-03-29 05:38:15 +03:00
|
|
|
} else if (payload.action === "view_3pid_invite") {
|
|
|
|
if (payload.event) {
|
2020-07-18 14:08:20 +03:00
|
|
|
this.setPhase(RightPanelPhases.Room3pidMemberInfo, {event: payload.event});
|
2019-03-29 05:38:15 +03:00
|
|
|
} else {
|
2020-07-18 14:08:20 +03:00
|
|
|
this.setPhase(RightPanelPhases.RoomMemberList);
|
2019-03-29 05:38:15 +03:00
|
|
|
}
|
2018-10-30 19:15:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 10:48:03 +03:00
|
|
|
private onRoomSummaryClicked = () => {
|
2020-09-08 18:27:09 +03:00
|
|
|
// use roomPanelPhase rather than this.state.phase as it remembers the latest one if we close
|
|
|
|
const lastPhase = RightPanelStore.getSharedInstance().roomPanelPhase;
|
|
|
|
if (ROOM_INFO_PHASES.includes(lastPhase)) {
|
|
|
|
if (this.state.phase === lastPhase) {
|
|
|
|
this.setPhase(lastPhase);
|
|
|
|
} else {
|
|
|
|
this.setPhase(lastPhase, RightPanelStore.getSharedInstance().roomPanelPhaseParams);
|
|
|
|
}
|
2020-09-08 17:39:58 +03:00
|
|
|
} else {
|
|
|
|
// This toggles for us, if needed
|
|
|
|
this.setPhase(RightPanelPhases.RoomSummary);
|
|
|
|
}
|
2020-09-04 14:14:43 +03:00
|
|
|
};
|
2019-04-11 14:22:47 +03:00
|
|
|
|
2020-09-04 14:14:43 +03:00
|
|
|
private onNotificationsClicked = () => {
|
2019-12-06 09:28:06 +03:00
|
|
|
// This toggles for us, if needed
|
2020-07-18 14:08:20 +03:00
|
|
|
this.setPhase(RightPanelPhases.NotificationPanel);
|
2020-09-04 14:14:43 +03:00
|
|
|
};
|
2019-04-11 14:22:47 +03:00
|
|
|
|
2020-07-30 13:28:07 +03:00
|
|
|
public renderButtons() {
|
2021-05-25 15:17:14 +03:00
|
|
|
return <>
|
2020-09-08 10:48:03 +03:00
|
|
|
<HeaderButton
|
|
|
|
name="notifsButton"
|
2019-02-12 20:31:47 +03:00
|
|
|
title={_t('Notifications')}
|
2020-07-18 14:08:20 +03:00
|
|
|
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
|
2020-07-29 21:28:32 +03:00
|
|
|
onClick={this.onNotificationsClicked}
|
2018-10-30 19:15:19 +03:00
|
|
|
analytics={['Right Panel', 'Notification List Button', 'click']}
|
2021-05-25 15:17:14 +03:00
|
|
|
/>
|
2020-09-09 13:06:15 +03:00
|
|
|
<HeaderButton
|
|
|
|
name="roomSummaryButton"
|
|
|
|
title={_t('Room Info')}
|
|
|
|
isHighlighted={this.isPhase(ROOM_INFO_PHASES)}
|
|
|
|
onClick={this.onRoomSummaryClicked}
|
|
|
|
analytics={['Right Panel', 'Room Summary Button', 'click']}
|
2021-05-25 15:17:14 +03:00
|
|
|
/>
|
|
|
|
</>;
|
2018-10-30 19:15:19 +03:00
|
|
|
}
|
|
|
|
}
|