2019-01-25 22:51:33 +03:00
|
|
|
/*
|
|
|
|
Copyright 2019 New Vector Ltd
|
2019-05-10 22:58:32 +03:00
|
|
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
2019-01-25 22:51:33 +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';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import {Tab, TabbedView} from "../../structures/TabbedView";
|
|
|
|
import {_t, _td} from "../../../languageHandler";
|
2019-02-22 20:47:18 +03: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 18:27:30 +03:00
|
|
|
import NotificationSettingsTab from "../settings/tabs/room/NotificationSettingsTab";
|
2019-12-02 20:27:23 +03:00
|
|
|
import BridgeSettingsTab from "../settings/tabs/room/BridgeSettingsTab";
|
2019-04-19 23:42:18 +03:00
|
|
|
import sdk from "../../../index";
|
2019-02-26 02:08:51 +03:00
|
|
|
import MatrixClientPeg from "../../../MatrixClientPeg";
|
2019-05-10 22:58:32 +03:00
|
|
|
import dis from "../../../dispatcher";
|
2019-12-09 16:54:21 +03:00
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
2019-01-25 22:51:33 +03:00
|
|
|
|
2019-01-26 06:38:35 +03:00
|
|
|
export default class RoomSettingsDialog extends React.Component {
|
2019-01-25 22:51:33 +03:00
|
|
|
static propTypes = {
|
2019-01-26 06:38:35 +03:00
|
|
|
roomId: PropTypes.string.isRequired,
|
2019-01-25 22:51:33 +03:00
|
|
|
onFinished: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2019-05-10 22:58:32 +03:00
|
|
|
componentWillMount() {
|
|
|
|
this._dispatcherRef = dis.register(this._onAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
dis.unregister(this._dispatcherRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onAction = (payload) => {
|
|
|
|
// When room changes below us, close the room settings
|
|
|
|
// whilst the modal is open this can only be triggered when someone hits Leave Room
|
|
|
|
if (payload.action === 'view_next_room') {
|
|
|
|
this.props.onFinished();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-25 22:51:33 +03:00
|
|
|
_getTabs() {
|
|
|
|
const tabs = [];
|
2019-12-09 16:28:43 +03:00
|
|
|
const featureFlag = SettingsStore.isFeatureEnabled("feature_bridge_state");
|
|
|
|
const shouldShowBridgeIcon = featureFlag && BridgeSettingsTab.getBridgeStateEvents(this.props.roomId).length > 0;
|
2019-01-25 22:51:33 +03:00
|
|
|
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("General"),
|
|
|
|
"mx_RoomSettingsDialog_settingsIcon",
|
2019-01-28 23:59:09 +03:00
|
|
|
<GeneralRoomSettingsTab roomId={this.props.roomId} />,
|
2019-01-25 22:51:33 +03:00
|
|
|
));
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Security & Privacy"),
|
|
|
|
"mx_RoomSettingsDialog_securityIcon",
|
2019-01-30 00:30:53 +03:00
|
|
|
<SecurityRoomSettingsTab roomId={this.props.roomId} />,
|
2019-01-25 22:51:33 +03:00
|
|
|
));
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Roles & Permissions"),
|
|
|
|
"mx_RoomSettingsDialog_rolesIcon",
|
2019-01-30 01:54:51 +03:00
|
|
|
<RolesRoomSettingsTab roomId={this.props.roomId} />,
|
2019-01-25 22:51:33 +03:00
|
|
|
));
|
2019-06-03 19:35:15 +03:00
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Notifications"),
|
|
|
|
"mx_RoomSettingsDialog_rolesIcon",
|
|
|
|
<NotificationSettingsTab roomId={this.props.roomId} />,
|
|
|
|
));
|
2019-12-02 20:27:23 +03:00
|
|
|
|
|
|
|
if (shouldShowBridgeIcon) {
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Bridge Info"),
|
|
|
|
"mx_RoomSettingsDialog_bridgesIcon",
|
|
|
|
<BridgeSettingsTab roomId={this.props.roomId} />,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2019-01-25 22:51:33 +03:00
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Advanced"),
|
|
|
|
"mx_RoomSettingsDialog_warningIcon",
|
2019-04-11 00:00:02 +03:00
|
|
|
<AdvancedRoomSettingsTab roomId={this.props.roomId} closeSettingsFn={this.props.onFinished} />,
|
2019-01-25 22:51:33 +03:00
|
|
|
));
|
|
|
|
|
|
|
|
return tabs;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-01-30 07:45:15 +03:00
|
|
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
|
|
|
|
2019-02-26 02:26:24 +03:00
|
|
|
const roomName = MatrixClientPeg.get().getRoom(this.props.roomId).name;
|
2019-01-25 22:51:33 +03:00
|
|
|
return (
|
2019-01-30 07:45:15 +03:00
|
|
|
<BaseDialog className='mx_RoomSettingsDialog' hasCancel={true}
|
2019-02-26 02:26:24 +03:00
|
|
|
onFinished={this.props.onFinished} title={_t("Room Settings - %(roomName)s", {roomName})}>
|
2019-01-30 07:45:15 +03:00
|
|
|
<div className='ms_SettingsDialog_content'>
|
|
|
|
<TabbedView tabs={this._getTabs()} />
|
2019-01-25 22:51:33 +03:00
|
|
|
</div>
|
2019-01-30 07:45:15 +03:00
|
|
|
</BaseDialog>
|
2019-01-25 22:51:33 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|