2019-01-25 12:51:33 -07:00
|
|
|
/*
|
|
|
|
|
Copyright 2019 New Vector Ltd
|
2019-05-10 20:58:32 +01:00
|
|
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
2019-01-25 12:51:33 -07: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';
|
2019-12-22 19:47:10 -07:00
|
|
|
import TabbedView, {Tab} from "../../structures/TabbedView";
|
2019-01-25 12:51:33 -07:00
|
|
|
import {_t, _td} from "../../../languageHandler";
|
2019-02-22 10:47:18 -07:00
|
|
|
import AdvancedRoomSettingsTab from "../settings/tabs/room/AdvancedRoomSettingsTab";
|
|
|
|
|
import RolesRoomSettingsTab from "../settings/tabs/room/RolesRoomSettingsTab";
|
|
|
|
|
import GeneralRoomSettingsTab from "../settings/tabs/room/GeneralRoomSettingsTab";
|
|
|
|
|
import SecurityRoomSettingsTab from "../settings/tabs/room/SecurityRoomSettingsTab";
|
2019-04-19 16:27:30 +01:00
|
|
|
import NotificationSettingsTab from "../settings/tabs/room/NotificationSettingsTab";
|
2020-01-09 14:15:38 -07:00
|
|
|
import BridgeSettingsTab from "../settings/tabs/room/BridgeSettingsTab";
|
2019-12-19 18:19:56 -07:00
|
|
|
import * as sdk from "../../../index";
|
2019-12-20 14:13:46 -07:00
|
|
|
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
2020-05-13 20:41:41 -06:00
|
|
|
import dis from "../../../dispatcher/dispatcher";
|
2019-12-09 13:54:21 +00:00
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
2020-09-16 12:14:33 +01:00
|
|
|
import {UIFeature} from "../../../settings/UIFeature";
|
2021-03-08 19:59:41 -07:00
|
|
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
2019-01-25 12:51:33 -07:00
|
|
|
|
2020-06-08 08:20:15 -06:00
|
|
|
export const ROOM_GENERAL_TAB = "ROOM_GENERAL_TAB";
|
|
|
|
|
export const ROOM_SECURITY_TAB = "ROOM_SECURITY_TAB";
|
|
|
|
|
export const ROOM_ROLES_TAB = "ROOM_ROLES_TAB";
|
|
|
|
|
export const ROOM_NOTIFICATIONS_TAB = "ROOM_NOTIFICATIONS_TAB";
|
|
|
|
|
export const ROOM_BRIDGES_TAB = "ROOM_BRIDGES_TAB";
|
|
|
|
|
export const ROOM_ADVANCED_TAB = "ROOM_ADVANCED_TAB";
|
|
|
|
|
|
2021-06-10 10:46:21 +01:00
|
|
|
interface IProps {
|
|
|
|
|
roomId: string;
|
|
|
|
|
onFinished: (success: boolean) => void;
|
2021-06-10 11:14:43 +01:00
|
|
|
initialTabId?: string;
|
2021-06-10 10:46:21 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-08 19:59:41 -07:00
|
|
|
@replaceableComponent("views.dialogs.RoomSettingsDialog")
|
2021-06-10 10:46:21 +01:00
|
|
|
export default class RoomSettingsDialog extends React.Component<IProps> {
|
|
|
|
|
private dispatcherRef: string;
|
2019-01-25 12:51:33 -07:00
|
|
|
|
2021-06-10 10:46:21 +01:00
|
|
|
public componentDidMount() {
|
|
|
|
|
this.dispatcherRef = dis.register(this.onAction);
|
2019-05-10 20:58:32 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-10 10:46:21 +01:00
|
|
|
public componentWillUnmount() {
|
|
|
|
|
if (this.dispatcherRef) {
|
|
|
|
|
dis.unregister(this.dispatcherRef);
|
|
|
|
|
}
|
2019-05-10 20:58:32 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-10 10:46:21 +01:00
|
|
|
private onAction = (payload): void => {
|
2020-12-03 11:15:55 +00:00
|
|
|
// When view changes below us, close the room settings
|
2019-05-10 20:58:32 +01:00
|
|
|
// whilst the modal is open this can only be triggered when someone hits Leave Room
|
2020-12-03 11:15:55 +00:00
|
|
|
if (payload.action === 'view_home_page') {
|
2021-06-10 10:46:21 +01:00
|
|
|
this.props.onFinished(true);
|
2019-05-10 20:58:32 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-10 10:46:21 +01:00
|
|
|
private getTabs(): Tab[] {
|
|
|
|
|
const tabs: Tab[] = [];
|
2019-01-25 12:51:33 -07:00
|
|
|
|
|
|
|
|
tabs.push(new Tab(
|
2020-06-08 08:20:15 -06:00
|
|
|
ROOM_GENERAL_TAB,
|
2019-01-25 12:51:33 -07:00
|
|
|
_td("General"),
|
|
|
|
|
"mx_RoomSettingsDialog_settingsIcon",
|
2019-01-28 13:59:09 -07:00
|
|
|
<GeneralRoomSettingsTab roomId={this.props.roomId} />,
|
2019-01-25 12:51:33 -07:00
|
|
|
));
|
|
|
|
|
tabs.push(new Tab(
|
2020-06-08 08:20:15 -06:00
|
|
|
ROOM_SECURITY_TAB,
|
2019-01-25 12:51:33 -07:00
|
|
|
_td("Security & Privacy"),
|
|
|
|
|
"mx_RoomSettingsDialog_securityIcon",
|
2019-01-29 14:30:53 -07:00
|
|
|
<SecurityRoomSettingsTab roomId={this.props.roomId} />,
|
2019-01-25 12:51:33 -07:00
|
|
|
));
|
|
|
|
|
tabs.push(new Tab(
|
2020-06-08 08:20:15 -06:00
|
|
|
ROOM_ROLES_TAB,
|
2019-01-25 12:51:33 -07:00
|
|
|
_td("Roles & Permissions"),
|
|
|
|
|
"mx_RoomSettingsDialog_rolesIcon",
|
2019-01-29 15:54:51 -07:00
|
|
|
<RolesRoomSettingsTab roomId={this.props.roomId} />,
|
2019-01-25 12:51:33 -07:00
|
|
|
));
|
2019-06-03 17:35:15 +01:00
|
|
|
tabs.push(new Tab(
|
2020-06-08 08:20:15 -06:00
|
|
|
ROOM_NOTIFICATIONS_TAB,
|
2019-06-03 17:35:15 +01:00
|
|
|
_td("Notifications"),
|
2020-04-01 12:57:28 +01:00
|
|
|
"mx_RoomSettingsDialog_notificationsIcon",
|
2019-06-03 17:35:15 +01:00
|
|
|
<NotificationSettingsTab roomId={this.props.roomId} />,
|
|
|
|
|
));
|
2019-12-02 17:27:23 +00:00
|
|
|
|
2020-08-17 13:12:18 -06:00
|
|
|
if (SettingsStore.getValue("feature_bridge_state")) {
|
2019-12-02 17:27:23 +00:00
|
|
|
tabs.push(new Tab(
|
2020-06-08 08:20:15 -06:00
|
|
|
ROOM_BRIDGES_TAB,
|
2020-01-21 18:41:43 +00:00
|
|
|
_td("Bridges"),
|
2019-12-02 17:27:23 +00:00
|
|
|
"mx_RoomSettingsDialog_bridgesIcon",
|
|
|
|
|
<BridgeSettingsTab roomId={this.props.roomId} />,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-16 12:14:33 +01:00
|
|
|
if (SettingsStore.getValue(UIFeature.AdvancedSettings)) {
|
|
|
|
|
tabs.push(new Tab(
|
|
|
|
|
ROOM_ADVANCED_TAB,
|
|
|
|
|
_td("Advanced"),
|
|
|
|
|
"mx_RoomSettingsDialog_warningIcon",
|
|
|
|
|
<AdvancedRoomSettingsTab roomId={this.props.roomId} closeSettingsFn={this.props.onFinished} />,
|
|
|
|
|
));
|
|
|
|
|
}
|
2019-01-25 12:51:33 -07:00
|
|
|
|
|
|
|
|
return tabs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2019-01-29 21:45:15 -07:00
|
|
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
|
|
|
|
|
2019-02-25 23:26:24 +00:00
|
|
|
const roomName = MatrixClientPeg.get().getRoom(this.props.roomId).name;
|
2019-01-25 12:51:33 -07:00
|
|
|
return (
|
2021-04-29 19:57:02 +02:00
|
|
|
<BaseDialog
|
|
|
|
|
className='mx_RoomSettingsDialog'
|
|
|
|
|
hasCancel={true}
|
|
|
|
|
onFinished={this.props.onFinished}
|
|
|
|
|
title={_t("Room Settings - %(roomName)s", {roomName})}
|
|
|
|
|
>
|
2021-03-03 22:38:30 +02:00
|
|
|
<div className='mx_SettingsDialog_content'>
|
2021-06-10 11:14:43 +01:00
|
|
|
<TabbedView
|
|
|
|
|
tabs={this.getTabs()}
|
|
|
|
|
initialTabId={this.props.initialTabId}
|
|
|
|
|
/>
|
2019-01-25 12:51:33 -07:00
|
|
|
</div>
|
2019-01-29 21:45:15 -07:00
|
|
|
</BaseDialog>
|
2019-01-25 12:51:33 -07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|