Merge remote-tracking branch 'origin/develop' into develop

pull/21833/head
Weblate 2018-01-11 10:49:44 +00:00
commit 8ccc53088f
12 changed files with 120 additions and 101 deletions

View File

@ -20,7 +20,6 @@ import PropTypes from 'prop-types';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import sdk from '../../../index'; import sdk from '../../../index';
import MatrixClientPeg from '../../../MatrixClientPeg'; import MatrixClientPeg from '../../../MatrixClientPeg';
import AccessibleButton from '../elements/AccessibleButton';
import Promise from 'bluebird'; import Promise from 'bluebird';
import { addressTypes, getAddressType } from '../../../UserAddress.js'; import { addressTypes, getAddressType } from '../../../UserAddress.js';
import GroupStoreCache from '../../../stores/GroupStoreCache'; import GroupStoreCache from '../../../stores/GroupStoreCache';
@ -507,7 +506,8 @@ module.exports = React.createClass({
}, },
render: function() { render: function() {
const TintableSvg = sdk.getComponent("elements.TintableSvg"); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const AddressSelector = sdk.getComponent("elements.AddressSelector"); const AddressSelector = sdk.getComponent("elements.AddressSelector");
this.scrollElement = null; this.scrollElement = null;
@ -580,14 +580,8 @@ module.exports = React.createClass({
} }
return ( return (
<div className="mx_ChatInviteDialog" onKeyDown={this.onKeyDown}> <BaseDialog className="mx_ChatInviteDialog" onKeyDown={this.onKeyDown}
<div className="mx_Dialog_title"> onFinished={this.props.onFinished} title={this.props.title}>
{ this.props.title }
</div>
<AccessibleButton className="mx_ChatInviteDialog_cancel"
onClick={this.onCancel} >
<TintableSvg src="img/icons-close-button.svg" width="35" height="35" />
</AccessibleButton>
<div className="mx_ChatInviteDialog_label"> <div className="mx_ChatInviteDialog_label">
<label htmlFor="textinput">{ this.props.description }</label> <label htmlFor="textinput">{ this.props.description }</label>
</div> </div>
@ -597,12 +591,10 @@ module.exports = React.createClass({
{ addressSelector } { addressSelector }
{ this.props.extraNode } { this.props.extraNode }
</div> </div>
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={this.props.button}
<button className="mx_Dialog_primary" onClick={this.onButtonClick}> onPrimaryButtonClick={this.onButtonClick}
{ this.props.button } onCancel={this.onCancel} />
</button> </BaseDialog>
</div>
</div>
); );
}, },
}); });

View File

@ -76,7 +76,7 @@ export default React.createClass({
> >
<TintableSvg src="img/icons-close-button.svg" width="35" height="35" /> <TintableSvg src="img/icons-close-button.svg" width="35" height="35" />
</AccessibleButton> </AccessibleButton>
<div className='mx_Dialog_title'> <div className={'mx_Dialog_title ' + this.props.titleClass}>
{ this.props.title } { this.props.title }
</div> </div>
{ this.props.children } { this.props.children }

View File

@ -138,6 +138,7 @@ export default class ChatCreateOrReuseDialog extends React.Component {
} else { } else {
// Show the avatar, name and a button to confirm that a new chat is requested // Show the avatar, name and a button to confirm that a new chat is requested
const BaseAvatar = sdk.getComponent('avatars.BaseAvatar'); const BaseAvatar = sdk.getComponent('avatars.BaseAvatar');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const Spinner = sdk.getComponent('elements.Spinner'); const Spinner = sdk.getComponent('elements.Spinner');
title = _t('Start chatting'); title = _t('Start chatting');
@ -167,11 +168,8 @@ export default class ChatCreateOrReuseDialog extends React.Component {
</p> </p>
{ profile } { profile }
</div> </div>
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={_t('Start Chatting')}
<button className="mx_Dialog_primary" onClick={this.props.onNewDMClick}> onPrimaryButtonClick={this.props.onNewDMClick} />
{ _t('Start Chatting') }
</button>
</div>
</div>; </div>;
} }

View File

@ -19,7 +19,6 @@ import PropTypes from 'prop-types';
import { MatrixClient } from 'matrix-js-sdk'; import { MatrixClient } from 'matrix-js-sdk';
import sdk from '../../../index'; import sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import classnames from 'classnames';
import { GroupMemberType } from '../../../groups'; import { GroupMemberType } from '../../../groups';
/* /*
@ -77,13 +76,11 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar"); const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar");
const BaseAvatar = sdk.getComponent("views.avatars.BaseAvatar"); const BaseAvatar = sdk.getComponent("views.avatars.BaseAvatar");
const confirmButtonClass = classnames({ const confirmButtonClass = this.props.danger ? 'danger' : '';
'mx_Dialog_primary': true,
'danger': this.props.danger,
});
let reasonBox; let reasonBox;
if (this.props.askReason) { if (this.props.askReason) {
@ -128,17 +125,11 @@ export default React.createClass({
<div className="mx_ConfirmUserActionDialog_userId">{ userId }</div> <div className="mx_ConfirmUserActionDialog_userId">{ userId }</div>
</div> </div>
{ reasonBox } { reasonBox }
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={this.props.action}
<button className={confirmButtonClass} onPrimaryButtonClick={this.onOk}
onClick={this.onOk} autoFocus={!this.props.askReason} primaryButtonClass={confirmButtonClass}
> focus={!this.props.askReason}
{ this.props.action } onCancel={this.onCancel} />
</button>
<button onClick={this.onCancel}>
{ _t("Cancel") }
</button>
</div>
</BaseDialog> </BaseDialog>
); );
}, },

View File

@ -159,10 +159,10 @@ export default React.createClass({
{ createErrorNode } { createErrorNode }
</div> </div>
<div className="mx_Dialog_buttons"> <div className="mx_Dialog_buttons">
<input type="submit" value={_t('Create')} className="mx_Dialog_primary" />
<button onClick={this._onCancel}> <button onClick={this._onCancel}>
{ _t("Cancel") } { _t("Cancel") }
</button> </button>
<input type="submit" value={_t('Create')} className="mx_Dialog_primary" />
</div> </div>
</form> </form>
</BaseDialog> </BaseDialog>

View File

@ -42,6 +42,7 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return ( return (
<BaseDialog className="mx_CreateRoomDialog" onFinished={this.props.onFinished} <BaseDialog className="mx_CreateRoomDialog" onFinished={this.props.onFinished}
onEnterPressed={this.onOk} onEnterPressed={this.onOk}
@ -68,14 +69,9 @@ export default React.createClass({
</div> </div>
</details> </details>
</div> </div>
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={_t('Create Room')}
<button onClick={this.onCancel}> onPrimaryButtonClick={this.onOk}
{ _t('Cancel') } onCancel={this.onCancel} />
</button>
<button className="mx_Dialog_primary" onClick={this.onOk}>
{ _t('Create Room') }
</button>
</div>
</BaseDialog> </BaseDialog>
); );
}, },

View File

@ -78,6 +78,7 @@ export default class DeactivateAccountDialog extends React.Component {
} }
render() { render() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const Loader = sdk.getComponent("elements.Spinner"); const Loader = sdk.getComponent("elements.Spinner");
let passwordBoxClass = ''; let passwordBoxClass = '';
@ -100,10 +101,11 @@ export default class DeactivateAccountDialog extends React.Component {
} }
return ( return (
<div className="mx_DeactivateAccountDialog"> <BaseDialog className="mx_DeactivateAccountDialog"
<div className="mx_Dialog_title danger"> onFinished={this.props.onFinished}
{ _t("Deactivate Account") } onEnterPressed={this.onOk}
</div> titleClass="danger"
title={_t("Deactivate Account")}>
<div className="mx_Dialog_content"> <div className="mx_Dialog_content">
<p>{ _t("This will make your account permanently unusable. You will not be able to re-register the same user ID.") }</p> <p>{ _t("This will make your account permanently unusable. You will not be able to re-register the same user ID.") }</p>
@ -131,7 +133,7 @@ export default class DeactivateAccountDialog extends React.Component {
{ cancelButton } { cancelButton }
</div> </div>
</div> </BaseDialog>
); );
} }
} }

View File

@ -19,7 +19,6 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import sdk from '../../../index'; import sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import classnames from 'classnames';
export default React.createClass({ export default React.createClass({
displayName: 'QuestionDialog', displayName: 'QuestionDialog',
@ -54,30 +53,27 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const cancelButton = this.props.hasCancelButton ? ( const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
<button onClick={this.onCancel}> let primaryButtonClass = "";
{ _t("Cancel") } if (this.props.danger) {
</button> primaryButtonClass = "danger";
) : null; }
const buttonClasses = classnames({
mx_Dialog_primary: true,
danger: this.props.danger,
});
return ( return (
<BaseDialog className="mx_QuestionDialog" onFinished={this.props.onFinished} <BaseDialog className="mx_QuestionDialog" onFinished={this.props.onFinished}
onEnterPressed={this.onOk} onEnterPressed={this.onOk}
title={this.props.title} title={this.props.title}
focus={this.props.focus}
> >
<div className="mx_Dialog_content"> <div className="mx_Dialog_content">
{ this.props.description } { this.props.description }
</div> </div>.
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={this.props.button || _t('OK')}
<button className={buttonClasses} onClick={this.onOk} autoFocus={this.props.focus}> onPrimaryButtonClick={this.onOk}
{ this.props.button || _t('OK') } primaryButtonClass={primaryButtonClass}
</button> onCancel={this.onCancel}
>
{ this.props.extraButtons } { this.props.extraButtons }
{ cancelButton } </DialogButtons>
</div>
</BaseDialog> </BaseDialog>
); );
}, },

View File

@ -41,6 +41,7 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
let bugreport; let bugreport;
if (SdkConfig.get().bug_report_endpoint_url) { if (SdkConfig.get().bug_report_endpoint_url) {
@ -69,11 +70,9 @@ export default React.createClass({
{ bugreport } { bugreport }
</div> </div>
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={_t("Continue anyway")}
<button className="mx_Dialog_primary" onClick={this._continueClicked}> onPrimaryButtonClick={this._continueClicked}
{ _t("Continue anyway") } onCancel={this.props.onFinished} />
</button>
</div>
</BaseDialog> </BaseDialog>
); );
}, },

View File

@ -17,7 +17,6 @@ limitations under the License.
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import sdk from '../../../index'; import sdk from '../../../index';
import { _t } from '../../../languageHandler';
export default React.createClass({ export default React.createClass({
displayName: 'TextInputDialog', displayName: 'TextInputDialog',
@ -59,6 +58,7 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return ( return (
<BaseDialog className="mx_TextInputDialog" onFinished={this.props.onFinished} <BaseDialog className="mx_TextInputDialog" onFinished={this.props.onFinished}
onEnterPressed={this.onOk} onEnterPressed={this.onOk}
@ -72,14 +72,9 @@ export default React.createClass({
<input id="textinput" ref="textinput" className="mx_TextInputDialog_input" defaultValue={this.props.value} autoFocus={this.props.focus} size="64" /> <input id="textinput" ref="textinput" className="mx_TextInputDialog_input" defaultValue={this.props.value} autoFocus={this.props.focus} size="64" />
</div> </div>
</div> </div>
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={this.props.button}
<button onClick={this.onCancel}> onPrimaryButtonClick={this.onOk}
{ _t("Cancel") } onCancel={this.onCancel} />
</button>
<button className="mx_Dialog_primary" onClick={this.onOk}>
{ this.props.button }
</button>
</div>
</BaseDialog> </BaseDialog>
); );
}, },

View File

@ -180,18 +180,11 @@ export default React.createClass({
} }
}); });
}); });
let sendButton; const sendButtonOnClick = haveUnknownDevices ? this._onSendAnywayClicked : this._onSendClicked;
if (haveUnknownDevices) { const sendButtonLabel = haveUnknownDevices ? this.props.sendAnywayLabel : this.props.sendAnywayLabel;
sendButton = <button onClick={this._onSendAnywayClicked}>
{ this.props.sendAnywayLabel }
</button>;
} else {
sendButton = <button onClick={this._onSendClicked}>
{ this.props.sendLabel }
</button>;
}
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return ( return (
<BaseDialog className='mx_UnknownDeviceDialog' <BaseDialog className='mx_UnknownDeviceDialog'
onFinished={this.props.onFinished} onFinished={this.props.onFinished}
@ -206,14 +199,9 @@ export default React.createClass({
<UnknownDeviceList devices={this.props.devices} /> <UnknownDeviceList devices={this.props.devices} />
</GeminiScrollbar> </GeminiScrollbar>
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={sendButtonLabel}
{sendButton} onPrimaryButtonClick={sendButtonOnClick}
<button className="mx_Dialog_primary" autoFocus={true} onCancel={this._onDismissClicked} />
onClick={this._onDismissClicked}
>
{_t("Dismiss")}
</button>
</div>
</BaseDialog> </BaseDialog>
); );
// XXX: do we want to give the user the option to enable blacklistUnverifiedDevices for this room (or globally) at this point? // XXX: do we want to give the user the option to enable blacklistUnverifiedDevices for this room (or globally) at this point?

View File

@ -0,0 +1,62 @@
/*
Copyright 2017 Aidan Gauland
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
"use strict";
import React from "react";
import PropTypes from "prop-types";
import { _t } from '../../../languageHandler';
/**
* Basic container for buttons in modal dialogs.
*/
module.exports = React.createClass({
displayName: "DialogButtons",
propTypes: {
// The primary button which is styled differently and has default focus.
primaryButton: PropTypes.node.isRequired,
// onClick handler for the primary button.
onPrimaryButtonClick: PropTypes.func.isRequired,
// onClick handler for the cancel button.
onCancel: PropTypes.func.isRequired,
focus: PropTypes.bool,
},
render: function() {
let primaryButtonClassName = "mx_Dialog_primary";
if (this.props.primaryButtonClass) {
primaryButtonClassName += " " + this.props.primaryButtonClass;
}
return (
<div className="mx_Dialog_buttons">
<button className={primaryButtonClassName}
onClick={this.props.onPrimaryButtonClick}
autoFocus={this.props.focus}
>
{ this.props.primaryButton }
</button>
{ this.props.children }
<button onClick={this.props.onCancel}>
{ _t("Cancel") }
</button>
</div>
);
},
});