Merge pull request #1919 from matrix-org/luke/consent-dialog

Terms and Conditions dialog
This commit is contained in:
Luke Barnard 2018-05-23 10:17:14 +01:00 committed by GitHub
commit c1a42637e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 13 deletions

View file

@ -1232,6 +1232,28 @@ export default React.createClass({
action: 'logout',
});
});
cli.on('no_consent', function(message, consentUri) {
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createTrackedDialog('No Consent Dialog', '', QuestionDialog, {
title: _t('Terms and Conditions'),
description: <div>
<p> { _t(
'To continue using the %(homeserverDomain)s homeserver ' +
'you must review and agree to our terms and conditions.',
{ homeserverDomain: cli.getDomain() },
) }
</p>
</div>,
button: _t('Review terms and conditions'),
cancelButton: _t('Dismiss'),
onFinished: (confirmed) => {
if (confirmed) {
window.open(consentUri, '_blank');
}
},
}, null, true);
});
cli.on("accountData", function(ev) {
if (ev.getType() === 'im.vector.web.settings') {
if (ev.getContent() && ev.getContent().theme) {

View file

@ -67,6 +67,7 @@ export default React.createClass({
{ this.props.description }
</div>
<DialogButtons primaryButton={this.props.button || _t('OK')}
cancelButton={this.props.cancelButton}
onPrimaryButtonClick={this.onOk}
primaryButtonClass={primaryButtonClass}
focus={this.props.focus}

View file

@ -29,6 +29,9 @@ module.exports = React.createClass({
// The primary button which is styled differently and has default focus.
primaryButton: PropTypes.node.isRequired,
// A node to insert into the cancel button instead of default "Cancel"
cancelButton: PropTypes.node,
// onClick handler for the primary button.
onPrimaryButtonClick: PropTypes.func.isRequired,
@ -60,9 +63,9 @@ module.exports = React.createClass({
primaryButtonClassName += " " + this.props.primaryButtonClass;
}
let cancelButton;
if (this.props.hasCancel) {
if (this.props.cancelButton || this.props.hasCancel) {
cancelButton = <button onClick={this._onCancelClick} disabled={this.props.disabled}>
{ _t("Cancel") }
{ this.props.cancelButton || _t("Cancel") }
</button>;
}
return (