Make dialog more specific and hide options behind advanced spoiler

This commit is contained in:
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'}); 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 CreateRoomDialog = sdk.getComponent('dialogs.CreateRoomDialog');
const defaultNoFederate = this.props.config.default_federate === false; Modal.createDialog(CreateRoomDialog, {
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>,
onFinished: (shouldCreate, name, noFederate) => { onFinished: (shouldCreate, name, noFederate) => {
if (shouldCreate) { if (shouldCreate) {
const createOpts = {}; 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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 React from 'react';
import sdk from '../../../index'; import sdk from '../../../index';
import SdkConfig from '../../../SdkConfig';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
export default React.createClass({ export default React.createClass({
displayName: 'TextInputWithCheckboxDialog', displayName: 'CreateRoomDialog',
propTypes: { 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, onFinished: React.PropTypes.func.isRequired,
}, },
getDefaultProps: function() {
return {
title: "",
value: "",
description: "",
focus: true,
checkLabel: "",
check: false,
};
},
componentDidMount: function() { componentDidMount: function() {
if (this.props.focus) { const config = SdkConfig.get();
// Set the cursor at the end of the text input // Dialog shows inverse of m.federate (noFederate) strict false check to skip undefined check (default = true)
this.refs.textinput.value = this.props.value; this.defaultNoFederate = config.default_federate === false;
}
}, },
onOk: function() { onOk: function() {
@ -66,29 +42,37 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
return ( return (
<BaseDialog className="mx_TextInputWithCheckboxDialog" onFinished={this.props.onFinished} <BaseDialog className="mx_CreateRoomDialog" onFinished={this.props.onFinished}
onEnterPressed={this.onOk} onEnterPressed={this.onOk}
title={this.props.title} title={_t('Create Room')}
> >
<div className="mx_Dialog_content"> <div className="mx_Dialog_content">
<div className="mx_TextInputWithCheckboxDialog_label"> <div className="mx_CreateRoomDialog_label">
<label htmlFor="textinput"> {this.props.description} </label> <label htmlFor="textinput"> {_t('Room name (optional)')} </label>
</div> </div>
<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> </div>
<br/> <br/>
<label>
<input type="checkbox" id="checkbox" ref="checkbox" defaultChecked={this.props.check}/> <details className="mx_CreateRoomDialog_details">
{this.props.checkLabel} <summary className="mx_CreateRoomDialog_details_summary">{ _t('Advanced options') }</summary>
</label> <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>
<div className="mx_Dialog_buttons"> <div className="mx_Dialog_buttons">
<button onClick={this.onCancel}> <button onClick={this.onCancel}>
{ _t("Cancel") } { _t('Cancel') }
</button> </button>
<button className="mx_Dialog_primary" onClick={this.onOk}> <button className="mx_Dialog_primary" onClick={this.onOk}>
{this.props.button} { _t('Create Room') }
</button> </button>
</div> </div>
</BaseDialog> </BaseDialog>

View file

@ -146,6 +146,7 @@
"Microphone": "Microphone", "Microphone": "Microphone",
"Camera": "Camera", "Camera": "Camera",
"Advanced": "Advanced", "Advanced": "Advanced",
"Advanced options": "Advanced options",
"Algorithm": "Algorithm", "Algorithm": "Algorithm",
"Hide removed messages": "Hide removed messages", "Hide removed messages": "Hide removed messages",
"Always show message timestamps": "Always show message timestamps", "Always show message timestamps": "Always show message timestamps",