From ca5e26744fceda6c0fc9dfe6f9b48fdf131c47f8 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 17 Aug 2017 13:33:07 +0100 Subject: [PATCH] Make dialog more specific and hide options behind advanced spoiler --- src/components/structures/MatrixChat.js | 15 +---- ...hCheckboxDialog.js => CreateRoomDialog.js} | 66 +++++++------------ src/i18n/strings/en_EN.json | 1 + 3 files changed, 28 insertions(+), 54 deletions(-) rename src/components/views/dialogs/{TextInputWithCheckboxDialog.js => CreateRoomDialog.js} (50%) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 5f01b72c2b..6d95c99948 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -786,19 +786,8 @@ 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'), - check: defaultNoFederate, - checkLabel: - {_t('Block users on other matrix homeservers from joining this room')} -
- ({_t('This setting cannot be changed later!')}) -
, + const CreateRoomDialog = sdk.getComponent('dialogs.CreateRoomDialog'); + Modal.createDialog(CreateRoomDialog, { onFinished: (shouldCreate, name, noFederate) => { if (shouldCreate) { const createOpts = {}; diff --git a/src/components/views/dialogs/TextInputWithCheckboxDialog.js b/src/components/views/dialogs/CreateRoomDialog.js similarity index 50% rename from src/components/views/dialogs/TextInputWithCheckboxDialog.js rename to src/components/views/dialogs/CreateRoomDialog.js index 6fd46ec209..20eeb5b591 100644 --- a/src/components/views/dialogs/TextInputWithCheckboxDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -1,5 +1,5 @@ /* -Copyright 2015, 2016 OpenMarket Ltd +Copyright 2017 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,43 +16,19 @@ limitations under the License. import React from 'react'; import sdk from '../../../index'; +import SdkConfig from '../../../SdkConfig'; import { _t } from '../../../languageHandler'; export default React.createClass({ - displayName: 'TextInputWithCheckboxDialog', + displayName: 'CreateRoomDialog', propTypes: { - title: React.PropTypes.string, - description: React.PropTypes.oneOfType([ - React.PropTypes.element, - React.PropTypes.string, - ]), - value: React.PropTypes.string, - button: React.PropTypes.string, - focus: React.PropTypes.bool, - checkLabel: React.PropTypes.oneOfType([ - React.PropTypes.element, - React.PropTypes.string, - ]), - check: React.PropTypes.bool, onFinished: React.PropTypes.func.isRequired, }, - getDefaultProps: function() { - return { - title: "", - value: "", - description: "", - focus: true, - checkLabel: "", - check: false, - }; - }, - componentDidMount: function() { - if (this.props.focus) { - // Set the cursor at the end of the text input - this.refs.textinput.value = this.props.value; - } + const config = SdkConfig.get(); + // Dialog shows inverse of m.federate (noFederate) strict false check to skip undefined check (default = true) + this.defaultNoFederate = config.default_federate === false; }, onOk: function() { @@ -66,29 +42,37 @@ export default React.createClass({ render: function() { const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); return ( -
-
- +
+
- +

- + +
+ { _t('Advanced options') } +
+ + +
+
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 87eb189ad0..f7fb221072 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -146,6 +146,7 @@ "Microphone": "Microphone", "Camera": "Camera", "Advanced": "Advanced", + "Advanced options": "Advanced options", "Algorithm": "Algorithm", "Hide removed messages": "Hide removed messages", "Always show message timestamps": "Always show message timestamps",