From 4b4b7302331b195e199e44bd2abddbf1a2c68b29 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Wed, 2 Aug 2017 13:41:26 +0100
Subject: [PATCH] fix and i18n the impl
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/structures/MatrixChat.js | 24 ++++++++------
.../dialogs/TextInputWithCheckboxDialog.js | 33 +++++++------------
src/i18n/strings/en_EN.json | 2 ++
3 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index 50ee9963a6..22119585d9 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -214,10 +214,6 @@ module.exports = React.createClass({
return this.props.config.default_is_url || "https://vector.im";
},
- getDefaultFederate() {
- return this.props.config.default_federate && true;
- },
-
componentWillMount: function() {
SdkConfig.put(this.props.config);
@@ -790,19 +786,27 @@ module.exports = React.createClass({
dis.dispatch({action: 'view_set_mxid'});
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");
Modal.createDialog(TextInputWithCheckboxDialog, {
title: _t('Create Room'),
description: _t('Room name (optional)'),
button: _t('Create Room'),
- // TODO i18n below.
- check: this.getDefaultFederate(),
- checkLabel: 'Federate room in domain ' + MatrixClientPeg.get().getDomain(),
- onFinished: (shouldCreate, name, federate) => {
+ check: defaultNoFederate,
+ checkLabel:
+ {_t('Block users on other matrix homeservers from joining this room')}
+
+ ({_t('This setting cannot be changed later!')})
+ ,
+ onFinished: (shouldCreate, name, noFederate) => {
if (shouldCreate) {
- const createOpts = {};
+ const createOpts = {
+ creation_content: {
+ "m.federate": !noFederate,
+ },
+ };
if (name) createOpts.name = name;
- if (federate) createOpts.creation_content = {"m.federate": federate};
createRoom({createOpts}).done();
}
},
diff --git a/src/components/views/dialogs/TextInputWithCheckboxDialog.js b/src/components/views/dialogs/TextInputWithCheckboxDialog.js
index 916de16af5..613fab4cdb 100644
--- a/src/components/views/dialogs/TextInputWithCheckboxDialog.js
+++ b/src/components/views/dialogs/TextInputWithCheckboxDialog.js
@@ -16,6 +16,7 @@ limitations under the License.
import React from 'react';
import sdk from '../../../index';
+import { _t } from '../../../languageHandler';
export default React.createClass({
displayName: 'TextInputWithCheckboxDialog',
@@ -28,7 +29,10 @@ export default React.createClass({
value: React.PropTypes.string,
button: React.PropTypes.string,
focus: React.PropTypes.bool,
- checkLabel: React.PropTypes.string,
+ checkLabel: React.PropTypes.oneOfType([
+ React.PropTypes.element,
+ React.PropTypes.string,
+ ]),
check: React.PropTypes.bool,
onFinished: React.PropTypes.func.isRequired,
},
@@ -38,16 +42,9 @@ export default React.createClass({
title: "",
value: "",
description: "",
- button: "OK",
focus: true,
checkLabel: "",
- check: true,
- };
- },
-
- getInitialState: function() {
- return {
- isChecked: this.props.check,
+ check: false,
};
},
@@ -59,20 +56,13 @@ export default React.createClass({
},
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() {
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() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
return (
@@ -87,16 +77,15 @@ export default React.createClass({