2019-01-18 23:09:17 +03:00
|
|
|
/*
|
|
|
|
Copyright 2019 New Vector Ltd
|
2019-10-31 22:19:54 +03:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2019-01-18 23:09:17 +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';
|
2019-01-18 23:43:17 +03:00
|
|
|
import {Tab, TabbedView} from "../../structures/TabbedView";
|
2019-01-19 05:40:21 +03:00
|
|
|
import {_t, _td} from "../../../languageHandler";
|
2019-02-22 20:47:18 +03:00
|
|
|
import GeneralUserSettingsTab from "../settings/tabs/user/GeneralUserSettingsTab";
|
2019-01-24 03:32:27 +03:00
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
2019-02-22 20:47:18 +03:00
|
|
|
import LabsUserSettingsTab from "../settings/tabs/user/LabsUserSettingsTab";
|
|
|
|
import SecurityUserSettingsTab from "../settings/tabs/user/SecurityUserSettingsTab";
|
|
|
|
import NotificationUserSettingsTab from "../settings/tabs/user/NotificationUserSettingsTab";
|
|
|
|
import PreferencesUserSettingsTab from "../settings/tabs/user/PreferencesUserSettingsTab";
|
|
|
|
import VoiceUserSettingsTab from "../settings/tabs/user/VoiceUserSettingsTab";
|
|
|
|
import HelpUserSettingsTab from "../settings/tabs/user/HelpUserSettingsTab";
|
|
|
|
import FlairUserSettingsTab from "../settings/tabs/user/FlairUserSettingsTab";
|
2019-01-30 07:45:15 +03:00
|
|
|
import sdk from "../../../index";
|
2019-05-31 04:57:37 +03:00
|
|
|
import SdkConfig from "../../../SdkConfig";
|
2019-10-31 22:19:54 +03:00
|
|
|
import MjolnirUserSettingsTab from "../settings/tabs/user/MjolnirUserSettingsTab";
|
2019-01-19 06:36:02 +03:00
|
|
|
|
2019-01-18 23:43:17 +03:00
|
|
|
export default class UserSettingsDialog extends React.Component {
|
|
|
|
static propTypes = {
|
2019-01-18 23:09:17 +03:00
|
|
|
onFinished: PropTypes.func.isRequired,
|
2019-01-18 23:43:17 +03:00
|
|
|
};
|
2019-01-18 23:09:17 +03:00
|
|
|
|
2019-10-31 22:19:54 +03:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
mjolnirEnabled: SettingsStore.isFeatureEnabled("feature_mjolnir"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount(): void {
|
|
|
|
this._mjolnirWatcher = SettingsStore.watchSetting("feature_mjolnir", null, this._mjolnirChanged.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount(): void {
|
|
|
|
SettingsStore.unwatchSetting(this._mjolnirWatcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
_mjolnirChanged(settingName, roomId, atLevel, newValue) {
|
|
|
|
// We can cheat because we know what levels a feature is tracked at, and how it is tracked
|
|
|
|
this.setState({mjolnirEnabled: newValue});
|
|
|
|
}
|
|
|
|
|
2019-01-18 23:43:17 +03:00
|
|
|
_getTabs() {
|
2019-01-24 03:32:27 +03:00
|
|
|
const tabs = [];
|
|
|
|
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("General"),
|
|
|
|
"mx_UserSettingsDialog_settingsIcon",
|
2019-07-11 23:54:49 +03:00
|
|
|
<GeneralUserSettingsTab closeSettingsFn={this.props.onFinished} />,
|
2019-01-24 03:32:27 +03:00
|
|
|
));
|
2019-01-26 01:35:32 +03:00
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Flair"),
|
|
|
|
"mx_UserSettingsDialog_flairIcon",
|
2019-02-22 20:47:18 +03:00
|
|
|
<FlairUserSettingsTab />,
|
2019-01-26 01:35:32 +03:00
|
|
|
));
|
2019-01-24 03:32:27 +03:00
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Notifications"),
|
|
|
|
"mx_UserSettingsDialog_bellIcon",
|
2019-02-22 20:47:18 +03:00
|
|
|
<NotificationUserSettingsTab />,
|
2019-01-24 03:32:27 +03:00
|
|
|
));
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Preferences"),
|
|
|
|
"mx_UserSettingsDialog_preferencesIcon",
|
2019-02-22 20:47:18 +03:00
|
|
|
<PreferencesUserSettingsTab />,
|
2019-01-24 03:32:27 +03:00
|
|
|
));
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Voice & Video"),
|
|
|
|
"mx_UserSettingsDialog_voiceIcon",
|
2019-02-22 20:47:18 +03:00
|
|
|
<VoiceUserSettingsTab />,
|
2019-01-24 03:32:27 +03:00
|
|
|
));
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Security & Privacy"),
|
|
|
|
"mx_UserSettingsDialog_securityIcon",
|
2019-02-22 20:47:18 +03:00
|
|
|
<SecurityUserSettingsTab />,
|
2019-01-24 03:32:27 +03:00
|
|
|
));
|
2019-05-31 04:57:37 +03:00
|
|
|
if (SdkConfig.get()['showLabsSettings'] || SettingsStore.getLabsFeatures().length > 0) {
|
2019-01-24 03:32:27 +03:00
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Labs"),
|
|
|
|
"mx_UserSettingsDialog_labsIcon",
|
2019-02-22 20:47:18 +03:00
|
|
|
<LabsUserSettingsTab />,
|
2019-01-24 03:32:27 +03:00
|
|
|
));
|
|
|
|
}
|
2019-10-31 22:19:54 +03:00
|
|
|
if (this.state.mjolnirEnabled) {
|
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Ignored users"),
|
|
|
|
"mx_UserSettingsDialog_mjolnirIcon",
|
|
|
|
<MjolnirUserSettingsTab />,
|
|
|
|
));
|
|
|
|
}
|
2019-01-24 03:32:27 +03:00
|
|
|
tabs.push(new Tab(
|
|
|
|
_td("Help & About"),
|
|
|
|
"mx_UserSettingsDialog_helpIcon",
|
2019-02-22 20:47:18 +03:00
|
|
|
<HelpUserSettingsTab closeSettingsFn={this.props.onFinished} />,
|
2019-01-24 03:32:27 +03:00
|
|
|
));
|
|
|
|
|
|
|
|
return tabs;
|
2019-01-18 23:43:17 +03:00
|
|
|
}
|
2019-01-18 23:09:17 +03:00
|
|
|
|
2019-01-18 23:43:17 +03:00
|
|
|
render() {
|
2019-01-30 07:45:15 +03:00
|
|
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
|
|
|
|
2019-01-18 23:09:17 +03:00
|
|
|
return (
|
2019-01-30 07:45:15 +03:00
|
|
|
<BaseDialog className='mx_UserSettingsDialog' hasCancel={true}
|
|
|
|
onFinished={this.props.onFinished} title={_t("Settings")}>
|
|
|
|
<div className='ms_SettingsDialog_content'>
|
|
|
|
<TabbedView tabs={this._getTabs()} />
|
2019-01-19 06:09:23 +03:00
|
|
|
</div>
|
2019-01-30 07:45:15 +03:00
|
|
|
</BaseDialog>
|
2019-01-18 23:09:17 +03:00
|
|
|
);
|
2019-01-18 23:43:17 +03:00
|
|
|
}
|
|
|
|
}
|