Make dialog more specific and hide options behind advanced spoiler

pull/21833/head
Michael Telatynski 2017-08-17 13:33:07 +01:00
parent 6e39e72849
commit ca5e26744f
No known key found for this signature in database
GPG Key ID: 3F879DA5AD802A5E
3 changed files with 28 additions and 54 deletions

View File

@ -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: <span>
{_t('Block users on other matrix homeservers from joining this room')}
<br/>
({_t('This setting cannot be changed later!')})
</span>,
const CreateRoomDialog = sdk.getComponent('dialogs.CreateRoomDialog');
Modal.createDialog(CreateRoomDialog, {
onFinished: (shouldCreate, name, noFederate) => {
if (shouldCreate) {
const createOpts = {};

View File

@ -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 (
<BaseDialog className="mx_TextInputWithCheckboxDialog" onFinished={this.props.onFinished}
<BaseDialog className="mx_CreateRoomDialog" onFinished={this.props.onFinished}
onEnterPressed={this.onOk}
title={this.props.title}
title={_t('Create Room')}
>
<div className="mx_Dialog_content">
<div className="mx_TextInputWithCheckboxDialog_label">
<label htmlFor="textinput"> {this.props.description} </label>
<div className="mx_CreateRoomDialog_label">
<label htmlFor="textinput"> {_t('Room name (optional)')} </label>
</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_CreateRoomDialog_input" autoFocus={true} size="64" onKeyDown={this.onKeyDown}/>
</div>
<br/>
<label>
<input type="checkbox" id="checkbox" ref="checkbox" defaultChecked={this.props.check}/>
{this.props.checkLabel}
</label>
<details className="mx_CreateRoomDialog_details">
<summary className="mx_CreateRoomDialog_details_summary">{ _t('Advanced options') }</summary>
<div>
<input type="checkbox" id="checkbox" ref="checkbox" defaultChecked={this.defaultNoFederate}/>
<label htmlFor="checkbox">
{_t('Block users on other matrix homeservers from joining this room')}
<br/>
({_t('This setting cannot be changed later!')})
</label>
</div>
</details>
</div>
<div className="mx_Dialog_buttons">
<button onClick={this.onCancel}>
{ _t("Cancel") }
{ _t('Cancel') }
</button>
<button className="mx_Dialog_primary" onClick={this.onOk}>
{this.props.button}
{ _t('Create Room') }
</button>
</div>
</BaseDialog>

View File

@ -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",