Merge pull request #857 from t3chguy/t3chguy/settings_versions_improvements
T3chguy/settings versions improvements
This commit is contained in:
commit
7918ff2fc2
1 changed files with 101 additions and 95 deletions
|
@ -14,31 +14,40 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
var React = require('react');
|
const React = require('react');
|
||||||
var ReactDOM = require('react-dom');
|
const ReactDOM = require('react-dom');
|
||||||
var sdk = require('../../index');
|
const sdk = require('../../index');
|
||||||
var MatrixClientPeg = require("../../MatrixClientPeg");
|
const MatrixClientPeg = require("../../MatrixClientPeg");
|
||||||
var PlatformPeg = require("../../PlatformPeg");
|
const PlatformPeg = require("../../PlatformPeg");
|
||||||
var Modal = require('../../Modal');
|
const Modal = require('../../Modal');
|
||||||
var dis = require("../../dispatcher");
|
const dis = require("../../dispatcher");
|
||||||
var q = require('q');
|
const q = require('q');
|
||||||
var package_json = require('../../../package.json');
|
const packageJson = require('../../../package.json');
|
||||||
var UserSettingsStore = require('../../UserSettingsStore');
|
const UserSettingsStore = require('../../UserSettingsStore');
|
||||||
var GeminiScrollbar = require('react-gemini-scrollbar');
|
const GeminiScrollbar = require('react-gemini-scrollbar');
|
||||||
var Email = require('../../email');
|
const Email = require('../../email');
|
||||||
var AddThreepid = require('../../AddThreepid');
|
const AddThreepid = require('../../AddThreepid');
|
||||||
var SdkConfig = require('../../SdkConfig');
|
const SdkConfig = require('../../SdkConfig');
|
||||||
import AccessibleButton from '../views/elements/AccessibleButton';
|
import AccessibleButton from '../views/elements/AccessibleButton';
|
||||||
|
|
||||||
// if this looks like a release, use the 'version' from package.json; else use
|
// if this looks like a release, use the 'version' from package.json; else use
|
||||||
// the git sha. Prepend version with v, to look like riot-web version
|
// the git sha. Prepend version with v, to look like riot-web version
|
||||||
const REACT_SDK_VERSION = 'dist' in package_json ? `v${package_json.version}` : package_json.gitHead || '<local>';
|
const REACT_SDK_VERSION = 'dist' in packageJson ? packageJson.version : packageJson.gitHead || '<local>';
|
||||||
|
|
||||||
// Simple method to help prettify GH Release Tags and Commit Hashes.
|
// Simple method to help prettify GH Release Tags and Commit Hashes.
|
||||||
const GHVersionUrl = function(repo, token) {
|
const semVerRegex = /^v?(\d+\.\d+\.\d+(?:-rc.+)?)(?:-(?:\d+-g)?([0-9a-fA-F]+))?(?:-dirty)?$/i;
|
||||||
const uriTail = (token.startsWith('v') && token.includes('.')) ? `releases/tag/${token}` : `commit/${token}`;
|
const gHVersionLabel = function(repo, token) {
|
||||||
return `https://github.com/${repo}/${uriTail}`;
|
const match = token.match(semVerRegex);
|
||||||
|
let url;
|
||||||
|
if (match && match[1]) { // basic semVer string possibly with commit hash
|
||||||
|
url = (match.length > 1 && match[2])
|
||||||
|
? `https://github.com/${repo}/commit/${match[2]}`
|
||||||
|
: `https://github.com/${repo}/releases/tag/v${match[1]}`;
|
||||||
|
} else {
|
||||||
|
url = `https://github.com/${repo}/commit/${token.split('-')[0]}`;
|
||||||
}
|
}
|
||||||
|
return <a href={url}>{token}</a>;
|
||||||
|
};
|
||||||
|
|
||||||
// Enumerate some simple 'flip a bit' UI settings (if any).
|
// Enumerate some simple 'flip a bit' UI settings (if any).
|
||||||
// 'id' gives the key name in the im.vector.web.settings account data event
|
// 'id' gives the key name in the im.vector.web.settings account data event
|
||||||
|
@ -50,7 +59,7 @@ const SETTINGS_LABELS = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'hideReadReceipts',
|
id: 'hideReadReceipts',
|
||||||
label: 'Hide read receipts'
|
label: 'Hide read receipts',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'dontSendTypingNotifications',
|
id: 'dontSendTypingNotifications',
|
||||||
|
@ -106,7 +115,7 @@ const THEMES = [
|
||||||
id: 'theme',
|
id: 'theme',
|
||||||
label: 'Dark theme',
|
label: 'Dark theme',
|
||||||
value: 'dark',
|
value: 'dark',
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,7 +189,7 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
this._refreshFromServer();
|
this._refreshFromServer();
|
||||||
|
|
||||||
var syncedSettings = UserSettingsStore.getSyncedSettings();
|
const syncedSettings = UserSettingsStore.getSyncedSettings();
|
||||||
if (!syncedSettings.theme) {
|
if (!syncedSettings.theme) {
|
||||||
syncedSettings.theme = 'light';
|
syncedSettings.theme = 'light';
|
||||||
}
|
}
|
||||||
|
@ -202,16 +211,16 @@ module.exports = React.createClass({
|
||||||
middleOpacity: 1.0,
|
middleOpacity: 1.0,
|
||||||
});
|
});
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
let cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (cli) {
|
if (cli) {
|
||||||
cli.removeListener("RoomMember.membership", this._onInviteStateChange);
|
cli.removeListener("RoomMember.membership", this._onInviteStateChange);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshFromServer: function() {
|
_refreshFromServer: function() {
|
||||||
var self = this;
|
const self = this;
|
||||||
q.all([
|
q.all([
|
||||||
UserSettingsStore.loadProfileInfo(), UserSettingsStore.loadThreePids()
|
UserSettingsStore.loadProfileInfo(), UserSettingsStore.loadThreePids(),
|
||||||
]).done(function(resps) {
|
]).done(function(resps) {
|
||||||
self.setState({
|
self.setState({
|
||||||
avatarUrl: resps[0].avatar_url,
|
avatarUrl: resps[0].avatar_url,
|
||||||
|
@ -219,7 +228,7 @@ module.exports = React.createClass({
|
||||||
phase: "UserSettings.DISPLAY",
|
phase: "UserSettings.DISPLAY",
|
||||||
});
|
});
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
console.error("Failed to load user settings: " + error);
|
console.error("Failed to load user settings: " + error);
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Can't load user settings",
|
title: "Can't load user settings",
|
||||||
|
@ -236,7 +245,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
onAvatarPickerClick: function(ev) {
|
onAvatarPickerClick: function(ev) {
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
|
const NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
|
||||||
Modal.createDialog(NeedToRegisterDialog, {
|
Modal.createDialog(NeedToRegisterDialog, {
|
||||||
title: "Please Register",
|
title: "Please Register",
|
||||||
description: "Guests can't set avatars. Please register.",
|
description: "Guests can't set avatars. Please register.",
|
||||||
|
@ -250,8 +259,8 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onAvatarSelected: function(ev) {
|
onAvatarSelected: function(ev) {
|
||||||
var self = this;
|
const self = this;
|
||||||
var changeAvatar = this.refs.changeAvatar;
|
const changeAvatar = this.refs.changeAvatar;
|
||||||
if (!changeAvatar) {
|
if (!changeAvatar) {
|
||||||
console.error("No ChangeAvatar found to upload image to!");
|
console.error("No ChangeAvatar found to upload image to!");
|
||||||
return;
|
return;
|
||||||
|
@ -260,9 +269,9 @@ module.exports = React.createClass({
|
||||||
// dunno if the avatar changed, re-check it.
|
// dunno if the avatar changed, re-check it.
|
||||||
self._refreshFromServer();
|
self._refreshFromServer();
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
var errMsg = (typeof err === "string") ? err : (err.error || "");
|
// const errMsg = (typeof err === "string") ? err : (err.error || "");
|
||||||
console.error("Failed to set avatar: " + err);
|
console.error("Failed to set avatar: " + err);
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Failed to set avatar",
|
title: "Failed to set avatar",
|
||||||
description: ((err && err.message) ? err.message : "Operation failed"),
|
description: ((err && err.message) ? err.message : "Operation failed"),
|
||||||
|
@ -271,7 +280,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogoutClicked: function(ev) {
|
onLogoutClicked: function(ev) {
|
||||||
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
Modal.createDialog(QuestionDialog, {
|
Modal.createDialog(QuestionDialog, {
|
||||||
title: "Sign out?",
|
title: "Sign out?",
|
||||||
description:
|
description:
|
||||||
|
@ -286,7 +295,7 @@ module.exports = React.createClass({
|
||||||
<button key="export" className="mx_Dialog_primary"
|
<button key="export" className="mx_Dialog_primary"
|
||||||
onClick={this._onExportE2eKeysClicked}>
|
onClick={this._onExportE2eKeysClicked}>
|
||||||
Export E2E room keys
|
Export E2E room keys
|
||||||
</button>
|
</button>,
|
||||||
],
|
],
|
||||||
onFinished: (confirmed) => {
|
onFinished: (confirmed) => {
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
|
@ -300,34 +309,33 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onPasswordChangeError: function(err) {
|
onPasswordChangeError: function(err) {
|
||||||
var errMsg = err.error || "";
|
let errMsg = err.error || "";
|
||||||
if (err.httpStatus === 403) {
|
if (err.httpStatus === 403) {
|
||||||
errMsg = "Failed to change password. Is your password correct?";
|
errMsg = "Failed to change password. Is your password correct?";
|
||||||
}
|
} else if (err.httpStatus) {
|
||||||
else if (err.httpStatus) {
|
|
||||||
errMsg += ` (HTTP status ${err.httpStatus})`;
|
errMsg += ` (HTTP status ${err.httpStatus})`;
|
||||||
}
|
}
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
console.error("Failed to change password: " + errMsg);
|
console.error("Failed to change password: " + errMsg);
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: errMsg
|
description: errMsg,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onPasswordChanged: function() {
|
onPasswordChanged: function() {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Success",
|
title: "Success",
|
||||||
description: `Your password was successfully changed. You will not
|
description: `Your password was successfully changed. You will not
|
||||||
receive push notifications on other devices until you
|
receive push notifications on other devices until you
|
||||||
log back in to them.`
|
log back in to them.`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpgradeClicked: function() {
|
onUpgradeClicked: function() {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "start_upgrade_registration"
|
action: "start_upgrade_registration",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -341,11 +349,11 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_addEmail: function() {
|
_addEmail: function() {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
|
|
||||||
var email_address = this.refs.add_email_input.value;
|
const emailAddress = this.refs.add_email_input.value;
|
||||||
if (!Email.looksValid(email_address)) {
|
if (!Email.looksValid(emailAddress)) {
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Invalid Email Address",
|
title: "Invalid Email Address",
|
||||||
description: "This doesn't appear to be a valid email address",
|
description: "This doesn't appear to be a valid email address",
|
||||||
|
@ -355,7 +363,7 @@ module.exports = React.createClass({
|
||||||
this._addThreepid = new AddThreepid();
|
this._addThreepid = new AddThreepid();
|
||||||
// we always bind emails when registering, so let's do the
|
// we always bind emails when registering, so let's do the
|
||||||
// same here.
|
// same here.
|
||||||
this._addThreepid.addEmailAddress(email_address, true).done(() => {
|
this._addThreepid.addEmailAddress(emailAddress, true).done(() => {
|
||||||
Modal.createDialog(QuestionDialog, {
|
Modal.createDialog(QuestionDialog, {
|
||||||
title: "Verification Pending",
|
title: "Verification Pending",
|
||||||
description: "Please check your email and click on the link it contains. Once this is done, click continue.",
|
description: "Please check your email and click on the link it contains. Once this is done, click continue.",
|
||||||
|
@ -364,7 +372,7 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
this.setState({email_add_pending: false});
|
this.setState({email_add_pending: false});
|
||||||
console.error("Unable to add email address " + email_address + " " + err);
|
console.error("Unable to add email address " + emailAddress + " " + err);
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Unable to add email address",
|
title: "Unable to add email address",
|
||||||
description: ((err && err.message) ? err.message : "Operation failed"),
|
description: ((err && err.message) ? err.message : "Operation failed"),
|
||||||
|
@ -418,9 +426,9 @@ module.exports = React.createClass({
|
||||||
this.setState({email_add_pending: false});
|
this.setState({email_add_pending: false});
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
this.setState({email_add_pending: false});
|
this.setState({email_add_pending: false});
|
||||||
if (err.errcode == 'M_THREEPID_AUTH_FAILED') {
|
if (err.errcode === 'M_THREEPID_AUTH_FAILED') {
|
||||||
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
var message = "Unable to verify email address. ";
|
let message = "Unable to verify email address. ";
|
||||||
message += "Please check your email and click on the link it contains. Once this is done, click continue.";
|
message += "Please check your email and click on the link it contains. Once this is done, click continue.";
|
||||||
Modal.createDialog(QuestionDialog, {
|
Modal.createDialog(QuestionDialog, {
|
||||||
title: "Verification Pending",
|
title: "Verification Pending",
|
||||||
|
@ -429,7 +437,7 @@ module.exports = React.createClass({
|
||||||
onFinished: this.onEmailDialogFinished,
|
onFinished: this.onEmailDialogFinished,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
console.error("Unable to verify email address: " + err);
|
console.error("Unable to verify email address: " + err);
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Unable to verify email address",
|
title: "Unable to verify email address",
|
||||||
|
@ -469,17 +477,17 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_onRejectAllInvitesClicked: function(rooms, ev) {
|
_onRejectAllInvitesClicked: function(rooms, ev) {
|
||||||
this.setState({
|
this.setState({
|
||||||
rejectingInvites: true
|
rejectingInvites: true,
|
||||||
});
|
});
|
||||||
// reject the invites
|
// reject the invites
|
||||||
let promises = rooms.map((room) => {
|
const promises = rooms.map((room) => {
|
||||||
return MatrixClientPeg.get().leave(room.roomId);
|
return MatrixClientPeg.get().leave(room.roomId);
|
||||||
});
|
});
|
||||||
// purposefully drop errors to the floor: we'll just have a non-zero number on the UI
|
// purposefully drop errors to the floor: we'll just have a non-zero number on the UI
|
||||||
// after trying to reject all the invites.
|
// after trying to reject all the invites.
|
||||||
q.allSettled(promises).then(() => {
|
q.allSettled(promises).then(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
rejectingInvites: false
|
rejectingInvites: false,
|
||||||
});
|
});
|
||||||
}).done();
|
}).done();
|
||||||
},
|
},
|
||||||
|
@ -492,7 +500,7 @@ module.exports = React.createClass({
|
||||||
}, "e2e-export");
|
}, "e2e-export");
|
||||||
}, {
|
}, {
|
||||||
matrixClient: MatrixClientPeg.get(),
|
matrixClient: MatrixClientPeg.get(),
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -504,7 +512,7 @@ module.exports = React.createClass({
|
||||||
}, "e2e-export");
|
}, "e2e-export");
|
||||||
}, {
|
}, {
|
||||||
matrixClient: MatrixClientPeg.get(),
|
matrixClient: MatrixClientPeg.get(),
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -530,8 +538,6 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderUserInterfaceSettings: function() {
|
_renderUserInterfaceSettings: function() {
|
||||||
var client = MatrixClientPeg.get();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3>User Interface</h3>
|
<h3>User Interface</h3>
|
||||||
|
@ -549,7 +555,7 @@ module.exports = React.createClass({
|
||||||
<input id="urlPreviewsDisabled"
|
<input id="urlPreviewsDisabled"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
defaultChecked={ UserSettingsStore.getUrlPreviewsDisabled() }
|
defaultChecked={ UserSettingsStore.getUrlPreviewsDisabled() }
|
||||||
onChange={ e => UserSettingsStore.setUrlPreviewsDisabled(e.target.checked) }
|
onChange={ (e) => UserSettingsStore.setUrlPreviewsDisabled(e.target.checked) }
|
||||||
/>
|
/>
|
||||||
<label htmlFor="urlPreviewsDisabled">
|
<label htmlFor="urlPreviewsDisabled">
|
||||||
Disable inline URL previews by default
|
Disable inline URL previews by default
|
||||||
|
@ -562,7 +568,7 @@ module.exports = React.createClass({
|
||||||
<input id={ setting.id }
|
<input id={ setting.id }
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
defaultChecked={ this._syncedSettings[setting.id] }
|
defaultChecked={ this._syncedSettings[setting.id] }
|
||||||
onChange={ e => UserSettingsStore.setSyncedSetting(setting.id, e.target.checked) }
|
onChange={ (e) => UserSettingsStore.setSyncedSetting(setting.id, e.target.checked) }
|
||||||
/>
|
/>
|
||||||
<label htmlFor={ setting.id }>
|
<label htmlFor={ setting.id }>
|
||||||
{ setting.label }
|
{ setting.label }
|
||||||
|
@ -577,7 +583,7 @@ module.exports = React.createClass({
|
||||||
name={ setting.id }
|
name={ setting.id }
|
||||||
value={ setting.value }
|
value={ setting.value }
|
||||||
defaultChecked={ this._syncedSettings[setting.id] === setting.value }
|
defaultChecked={ this._syncedSettings[setting.id] === setting.value }
|
||||||
onChange={ e => {
|
onChange={ (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
UserSettingsStore.setSyncedSetting(setting.id, setting.value);
|
UserSettingsStore.setSyncedSetting(setting.id, setting.value);
|
||||||
}
|
}
|
||||||
|
@ -639,8 +645,8 @@ module.exports = React.createClass({
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
defaultChecked={ this._localSettings[setting.id] }
|
defaultChecked={ this._localSettings[setting.id] }
|
||||||
onChange={
|
onChange={
|
||||||
e => {
|
(e) => {
|
||||||
UserSettingsStore.setLocalSetting(setting.id, e.target.checked)
|
UserSettingsStore.setLocalSetting(setting.id, e.target.checked);
|
||||||
if (setting.id === 'blacklistUnverifiedDevices') { // XXX: this is a bit ugly
|
if (setting.id === 'blacklistUnverifiedDevices') { // XXX: this is a bit ugly
|
||||||
client.setGlobalBlacklistUnverifiedDevices(e.target.checked);
|
client.setGlobalBlacklistUnverifiedDevices(e.target.checked);
|
||||||
}
|
}
|
||||||
|
@ -654,7 +660,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderDevicesPanel: function() {
|
_renderDevicesPanel: function() {
|
||||||
var DevicesPanel = sdk.getComponent('settings.DevicesPanel');
|
const DevicesPanel = sdk.getComponent('settings.DevicesPanel');
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3>Devices</h3>
|
<h3>Devices</h3>
|
||||||
|
@ -665,7 +671,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_renderBugReport: function() {
|
_renderBugReport: function() {
|
||||||
if (!SdkConfig.get().bug_report_endpoint_url) {
|
if (!SdkConfig.get().bug_report_endpoint_url) {
|
||||||
return <div />
|
return <div />;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -684,17 +690,17 @@ module.exports = React.createClass({
|
||||||
// default to enabled if undefined
|
// default to enabled if undefined
|
||||||
if (this.props.enableLabs === false) return null;
|
if (this.props.enableLabs === false) return null;
|
||||||
|
|
||||||
let features = UserSettingsStore.LABS_FEATURES.map(feature => (
|
const features = UserSettingsStore.LABS_FEATURES.map((feature) => (
|
||||||
<div key={feature.id} className="mx_UserSettings_toggle">
|
<div key={feature.id} className="mx_UserSettings_toggle">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id={feature.id}
|
id={feature.id}
|
||||||
name={feature.id}
|
name={feature.id}
|
||||||
defaultChecked={ UserSettingsStore.isFeatureEnabled(feature.id) }
|
defaultChecked={ UserSettingsStore.isFeatureEnabled(feature.id) }
|
||||||
onChange={e => {
|
onChange={(e) => {
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
e.target.checked = false;
|
e.target.checked = false;
|
||||||
var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
|
const NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
|
||||||
Modal.createDialog(NeedToRegisterDialog, {
|
Modal.createDialog(NeedToRegisterDialog, {
|
||||||
title: "Please Register",
|
title: "Please Register",
|
||||||
description: "Guests can't use labs features. Please register.",
|
description: "Guests can't use labs features. Please register.",
|
||||||
|
@ -746,14 +752,14 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderBulkOptions: function() {
|
_renderBulkOptions: function() {
|
||||||
let invitedRooms = MatrixClientPeg.get().getRooms().filter((r) => {
|
const invitedRooms = MatrixClientPeg.get().getRooms().filter((r) => {
|
||||||
return r.hasMembershipState(this._me, "invite");
|
return r.hasMembershipState(this._me, "invite");
|
||||||
});
|
});
|
||||||
if (invitedRooms.length === 0) {
|
if (invitedRooms.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Spinner = sdk.getComponent("elements.Spinner");
|
const Spinner = sdk.getComponent("elements.Spinner");
|
||||||
|
|
||||||
let reject = <Spinner />;
|
let reject = <Spinner />;
|
||||||
if (!this.state.rejectingInvites) {
|
if (!this.state.rejectingInvites) {
|
||||||
|
@ -777,9 +783,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_showSpoiler: function(event) {
|
_showSpoiler: function(event) {
|
||||||
const target = event.target;
|
const target = event.target;
|
||||||
const hidden = target.getAttribute('data-spoiler');
|
target.innerHTML = target.getAttribute('data-spoiler');
|
||||||
|
|
||||||
target.innerHTML = hidden;
|
|
||||||
|
|
||||||
const range = document.createRange();
|
const range = document.createRange();
|
||||||
range.selectNodeContents(target);
|
range.selectNodeContents(target);
|
||||||
|
@ -790,12 +794,12 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
nameForMedium: function(medium) {
|
nameForMedium: function(medium) {
|
||||||
if (medium == 'msisdn') return 'Phone';
|
if (medium === 'msisdn') return 'Phone';
|
||||||
return medium[0].toUpperCase() + medium.slice(1);
|
return medium[0].toUpperCase() + medium.slice(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
presentableTextForThreepid: function(threepid) {
|
presentableTextForThreepid: function(threepid) {
|
||||||
if (threepid.medium == 'msisdn') {
|
if (threepid.medium === 'msisdn') {
|
||||||
return '+' + threepid.address;
|
return '+' + threepid.address;
|
||||||
} else {
|
} else {
|
||||||
return threepid.address;
|
return threepid.address;
|
||||||
|
@ -803,7 +807,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var Loader = sdk.getComponent("elements.Spinner");
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
switch (this.state.phase) {
|
switch (this.state.phase) {
|
||||||
case "UserSettings.LOADING":
|
case "UserSettings.LOADING":
|
||||||
return (
|
return (
|
||||||
|
@ -815,18 +819,18 @@ module.exports = React.createClass({
|
||||||
throw new Error("Unknown state.phase => " + this.state.phase);
|
throw new Error("Unknown state.phase => " + this.state.phase);
|
||||||
}
|
}
|
||||||
// can only get here if phase is UserSettings.DISPLAY
|
// can only get here if phase is UserSettings.DISPLAY
|
||||||
var SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader');
|
const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader');
|
||||||
var ChangeDisplayName = sdk.getComponent("views.settings.ChangeDisplayName");
|
const ChangeDisplayName = sdk.getComponent("views.settings.ChangeDisplayName");
|
||||||
var ChangePassword = sdk.getComponent("views.settings.ChangePassword");
|
const ChangePassword = sdk.getComponent("views.settings.ChangePassword");
|
||||||
var ChangeAvatar = sdk.getComponent('settings.ChangeAvatar');
|
const ChangeAvatar = sdk.getComponent('settings.ChangeAvatar');
|
||||||
var Notifications = sdk.getComponent("settings.Notifications");
|
const Notifications = sdk.getComponent("settings.Notifications");
|
||||||
var EditableText = sdk.getComponent('elements.EditableText');
|
const EditableText = sdk.getComponent('elements.EditableText');
|
||||||
|
|
||||||
var avatarUrl = (
|
const avatarUrl = (
|
||||||
this.state.avatarUrl ? MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl) : null
|
this.state.avatarUrl ? MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl) : null
|
||||||
);
|
);
|
||||||
|
|
||||||
var threepidsSection = this.state.threepids.map((val, pidIndex) => {
|
const threepidsSection = this.state.threepids.map((val, pidIndex) => {
|
||||||
const id = "3pid-" + val.address;
|
const id = "3pid-" + val.address;
|
||||||
return (
|
return (
|
||||||
<div className="mx_UserSettings_profileTableRow" key={pidIndex}>
|
<div className="mx_UserSettings_profileTableRow" key={pidIndex}>
|
||||||
|
@ -874,7 +878,7 @@ module.exports = React.createClass({
|
||||||
threepidsSection.push(addEmailSection);
|
threepidsSection.push(addEmailSection);
|
||||||
threepidsSection.push(addMsisdnSection);
|
threepidsSection.push(addMsisdnSection);
|
||||||
|
|
||||||
var accountJsx;
|
let accountJsx;
|
||||||
|
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
accountJsx = (
|
accountJsx = (
|
||||||
|
@ -882,8 +886,7 @@ module.exports = React.createClass({
|
||||||
Create an account
|
Create an account
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
accountJsx = (
|
accountJsx = (
|
||||||
<ChangePassword
|
<ChangePassword
|
||||||
className="mx_UserSettings_accountTable"
|
className="mx_UserSettings_accountTable"
|
||||||
|
@ -895,9 +898,9 @@ module.exports = React.createClass({
|
||||||
onFinished={this.onPasswordChanged} />
|
onFinished={this.onPasswordChanged} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var notification_area;
|
let notificationArea;
|
||||||
if (!MatrixClientPeg.get().isGuest() && this.state.threepids !== undefined) {
|
if (!MatrixClientPeg.get().isGuest() && this.state.threepids !== undefined) {
|
||||||
notification_area = (<div>
|
notificationArea = (<div>
|
||||||
<h3>Notifications</h3>
|
<h3>Notifications</h3>
|
||||||
|
|
||||||
<div className="mx_UserSettings_section">
|
<div className="mx_UserSettings_section">
|
||||||
|
@ -911,7 +914,7 @@ module.exports = React.createClass({
|
||||||
// we are using a version old version of olm. We assume the former.
|
// we are using a version old version of olm. We assume the former.
|
||||||
let olmVersionString = "<not-enabled>";
|
let olmVersionString = "<not-enabled>";
|
||||||
if (olmVersion !== undefined) {
|
if (olmVersion !== undefined) {
|
||||||
olmVersionString = `v${olmVersion[0]}.${olmVersion[1]}.${olmVersion[2]}`;
|
olmVersionString = `${olmVersion[0]}.${olmVersion[1]}.${olmVersion[2]}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -969,7 +972,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
{this._renderReferral()}
|
{this._renderReferral()}
|
||||||
|
|
||||||
{notification_area}
|
{notificationArea}
|
||||||
|
|
||||||
{this._renderUserInterfaceSettings()}
|
{this._renderUserInterfaceSettings()}
|
||||||
{this._renderLabs()}
|
{this._renderLabs()}
|
||||||
|
@ -985,7 +988,10 @@ module.exports = React.createClass({
|
||||||
Logged in as {this._me}
|
Logged in as {this._me}
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_UserSettings_advanced">
|
<div className="mx_UserSettings_advanced">
|
||||||
Access Token: <span className="mx_UserSettings_advanced_spoiler" onClick={this._showSpoiler} data-spoiler={ MatrixClientPeg.get().getAccessToken() }><click to reveal></span>
|
Access Token: <span className="mx_UserSettings_advanced_spoiler"
|
||||||
|
onClick={this._showSpoiler}
|
||||||
|
data-spoiler={ MatrixClientPeg.get().getAccessToken() }
|
||||||
|
><click to reveal></span>
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_UserSettings_advanced">
|
<div className="mx_UserSettings_advanced">
|
||||||
Homeserver is { MatrixClientPeg.get().getHomeserverUrl() }
|
Homeserver is { MatrixClientPeg.get().getHomeserverUrl() }
|
||||||
|
@ -995,11 +1001,11 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_UserSettings_advanced">
|
<div className="mx_UserSettings_advanced">
|
||||||
matrix-react-sdk version: {(REACT_SDK_VERSION !== '<local>')
|
matrix-react-sdk version: {(REACT_SDK_VERSION !== '<local>')
|
||||||
? <a href={ GHVersionUrl('matrix-org/matrix-react-sdk', REACT_SDK_VERSION) }>{REACT_SDK_VERSION}</a>
|
? gHVersionLabel('matrix-org/matrix-react-sdk', REACT_SDK_VERSION)
|
||||||
: REACT_SDK_VERSION
|
: REACT_SDK_VERSION
|
||||||
}<br/>
|
}<br/>
|
||||||
riot-web version: {(this.state.vectorVersion !== null)
|
riot-web version: {(this.state.vectorVersion !== null)
|
||||||
? <a href={ GHVersionUrl('vector-im/riot-web', this.state.vectorVersion.split('-')[0]) }>{this.state.vectorVersion}</a>
|
? gHVersionLabel('vector-im/riot-web', this.state.vectorVersion)
|
||||||
: 'unknown'
|
: 'unknown'
|
||||||
}<br/>
|
}<br/>
|
||||||
olm version: {olmVersionString}<br/>
|
olm version: {olmVersionString}<br/>
|
||||||
|
@ -1013,5 +1019,5 @@ module.exports = React.createClass({
|
||||||
</GeminiScrollbar>
|
</GeminiScrollbar>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue