fix and i18n the impl

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2017-08-02 13:41:26 +01:00
parent fd454b476a
commit 4b4b730233
No known key found for this signature in database
GPG Key ID: 0435A1D4BBD34D64
3 changed files with 27 additions and 32 deletions

View File

@ -214,10 +214,6 @@ module.exports = React.createClass({
return this.props.config.default_is_url || "https://vector.im"; return this.props.config.default_is_url || "https://vector.im";
}, },
getDefaultFederate() {
return this.props.config.default_federate && true;
},
componentWillMount: function() { componentWillMount: function() {
SdkConfig.put(this.props.config); SdkConfig.put(this.props.config);
@ -790,19 +786,27 @@ module.exports = React.createClass({
dis.dispatch({action: 'view_set_mxid'}); dis.dispatch({action: 'view_set_mxid'});
return; return;
} }
// Dialog shows inverse of m.federate (noFederate) strict false check to skip undefined check (default = true)
const defaultNoFederate = this.props.config.default_federate === false;
const TextInputWithCheckboxDialog = sdk.getComponent("dialogs.TextInputWithCheckboxDialog"); const TextInputWithCheckboxDialog = sdk.getComponent("dialogs.TextInputWithCheckboxDialog");
Modal.createDialog(TextInputWithCheckboxDialog, { Modal.createDialog(TextInputWithCheckboxDialog, {
title: _t('Create Room'), title: _t('Create Room'),
description: _t('Room name (optional)'), description: _t('Room name (optional)'),
button: _t('Create Room'), button: _t('Create Room'),
// TODO i18n below. check: defaultNoFederate,
check: this.getDefaultFederate(), checkLabel: <span>
checkLabel: 'Federate room in domain ' + MatrixClientPeg.get().getDomain(), {_t('Block users on other matrix homeservers from joining this room')}
onFinished: (shouldCreate, name, federate) => { <br/>
({_t('This setting cannot be changed later!')})
</span>,
onFinished: (shouldCreate, name, noFederate) => {
if (shouldCreate) { if (shouldCreate) {
const createOpts = {}; const createOpts = {
creation_content: {
"m.federate": !noFederate,
},
};
if (name) createOpts.name = name; if (name) createOpts.name = name;
if (federate) createOpts.creation_content = {"m.federate": federate};
createRoom({createOpts}).done(); createRoom({createOpts}).done();
} }
}, },

View File

@ -16,6 +16,7 @@ limitations under the License.
import React from 'react'; import React from 'react';
import sdk from '../../../index'; import sdk from '../../../index';
import { _t } from '../../../languageHandler';
export default React.createClass({ export default React.createClass({
displayName: 'TextInputWithCheckboxDialog', displayName: 'TextInputWithCheckboxDialog',
@ -28,7 +29,10 @@ export default React.createClass({
value: React.PropTypes.string, value: React.PropTypes.string,
button: React.PropTypes.string, button: React.PropTypes.string,
focus: React.PropTypes.bool, focus: React.PropTypes.bool,
checkLabel: React.PropTypes.string, checkLabel: React.PropTypes.oneOfType([
React.PropTypes.element,
React.PropTypes.string,
]),
check: React.PropTypes.bool, check: React.PropTypes.bool,
onFinished: React.PropTypes.func.isRequired, onFinished: React.PropTypes.func.isRequired,
}, },
@ -38,16 +42,9 @@ export default React.createClass({
title: "", title: "",
value: "", value: "",
description: "", description: "",
button: "OK",
focus: true, focus: true,
checkLabel: "", checkLabel: "",
check: true, check: false,
};
},
getInitialState: function() {
return {
isChecked: this.props.check,
}; };
}, },
@ -59,20 +56,13 @@ export default React.createClass({
}, },
onOk: function() { onOk: function() {
this.props.onFinished(true, this.refs.textinput.value, this.state.isChecked); this.props.onFinished(true, this.refs.textinput.value, this.refs.checkbox.value);
}, },
onCancel: function() { onCancel: function() {
this.props.onFinished(false); this.props.onFinished(false);
}, },
_onToggle: function(keyName, checkedValue, uncheckedValue, ev) {
console.log("Checkbox toggle: %s %s", keyName, ev.target.checked);
var state = {};
state[keyName] = ev.target.checked ? checkedValue : uncheckedValue;
this.setState(state);
},
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
return ( return (
@ -87,16 +77,15 @@ export default React.createClass({
<div> <div>
<input id="textinput" ref="textinput" className="mx_TextInputWithCheckboxDialog_input" defaultValue={this.props.value} autoFocus={this.props.focus} size="64" onKeyDown={this.onKeyDown}/> <input id="textinput" ref="textinput" className="mx_TextInputWithCheckboxDialog_input" defaultValue={this.props.value} autoFocus={this.props.focus} size="64" onKeyDown={this.onKeyDown}/>
</div> </div>
<br/>
<label> <label>
<input type="checkbox" id="checkbox" ref="checkbox" <input type="checkbox" id="checkbox" ref="checkbox" defaultChecked={this.props.check}/>
onChange={ this._onToggle.bind(this, "isChecked", true, false)} {this.props.checkLabel}
checked={this.state.isChecked}/>
{this.props.checkLabel}?
</label> </label>
</div> </div>
<div className="mx_Dialog_buttons"> <div className="mx_Dialog_buttons">
<button onClick={this.onCancel}> <button onClick={this.onCancel}>
Cancel { _t("Cancel") }
</button> </button>
<button className="mx_Dialog_primary" onClick={this.onOk}> <button className="mx_Dialog_primary" onClick={this.onOk}>
{this.props.button} {this.props.button}

View File

@ -184,6 +184,8 @@
"Banned users": "Banned users", "Banned users": "Banned users",
"Bans user with given id": "Bans user with given id", "Bans user with given id": "Bans user with given id",
"Blacklisted": "Blacklisted", "Blacklisted": "Blacklisted",
"Block users on other matrix homeservers from joining this room": "Block users on other matrix homeservers from joining this room",
"This setting cannot be changed later!": "This setting cannot be changed later!",
"Bug Report": "Bug Report", "Bug Report": "Bug Report",
"Bulk Options": "Bulk Options", "Bulk Options": "Bulk Options",
"Call Timeout": "Call Timeout", "Call Timeout": "Call Timeout",