Add experimental "Labs" section to settings

pull/21833/head
Aviral Dasgupta 2016-06-13 22:04:12 +05:30
parent 469c415557
commit c3a9658392
2 changed files with 43 additions and 0 deletions

View File

@ -112,4 +112,14 @@ module.exports = {
append: true, // We always append for email pushers since we don't want to stop other accounts notifying to the same email address append: true, // We always append for email pushers since we don't want to stop other accounts notifying to the same email address
}); });
}, },
isFeatureEnabled: function(feature: string): boolean {
feature = feature.match(/\w+/g).join('_').toLowerCase();
return localStorage.getItem(`mx_labs_feature_${feature}`) === 'true';
},
setFeatureEnabled: function(feature: string, enabled: boolean) {
feature = feature.match(/\w+/g).join('_').toLowerCase();
localStorage.setItem(`mx_labs_feature_${feature}`, enabled);
}
}; };

View File

@ -26,6 +26,11 @@ var GeminiScrollbar = require('react-gemini-scrollbar');
var Email = require('../../email'); var Email = require('../../email');
var AddThreepid = require('../../AddThreepid'); var AddThreepid = require('../../AddThreepid');
const LABS_FEATURES = [
'Rich Text Editor',
'End-to-End Encryption'
];
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'UserSettings', displayName: 'UserSettings',
@ -357,6 +362,32 @@ module.exports = React.createClass({
</div>); </div>);
} }
this._renderLabs = function () {
let features = LABS_FEATURES.map(feature => (
<div>
<input key={feature}
type="checkbox"
id={feature}
name={feature}
defaultChecked={UserSettingsStore.isFeatureEnabled(feature)}
onChange={e => UserSettingsStore.setFeatureEnabled(feature, e.target.checked)} />
<label htmlFor={feature}>{feature}</label>
</div>
));
return (
<div>
<h3>Labs</h3>
<div className="mx_UserSettings_section">
<p>These experimental features may change, break or disappear at any time. We make absolutely no guarantees about what may happen if you turn one of these experiments on, and your client may even spontaneously combust. Jokes aside, your client may delete all your data or your security and privacy could be compromised in unexpected ways. Please proceed with caution.</p>
{features}
<br />
<div className="mx_UserSettings_button" onClick={() => window.location.reload()}>Restart Vector</div>
</div>
</div>
)
};
return ( return (
<div className="mx_UserSettings"> <div className="mx_UserSettings">
<SimpleRoomHeader title="Settings" onCancelClick={ this.props.onClose }/> <SimpleRoomHeader title="Settings" onCancelClick={ this.props.onClose }/>
@ -411,6 +442,8 @@ module.exports = React.createClass({
{this._renderDeviceInfo()} {this._renderDeviceInfo()}
{this._renderLabs()}
<h3>Advanced</h3> <h3>Advanced</h3>
<div className="mx_UserSettings_section"> <div className="mx_UserSettings_section">