diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js
index 837d2f5349..685c4fcde3 100644
--- a/src/components/views/dialogs/AddressPickerDialog.js
+++ b/src/components/views/dialogs/AddressPickerDialog.js
@@ -20,7 +20,6 @@ import PropTypes from 'prop-types';
import { _t } from '../../../languageHandler';
import sdk from '../../../index';
import MatrixClientPeg from '../../../MatrixClientPeg';
-import AccessibleButton from '../elements/AccessibleButton';
import Promise from 'bluebird';
import { addressTypes, getAddressType } from '../../../UserAddress.js';
import GroupStoreCache from '../../../stores/GroupStoreCache';
@@ -507,7 +506,8 @@ module.exports = React.createClass({
},
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");
this.scrollElement = null;
@@ -580,14 +580,8 @@ module.exports = React.createClass({
}
return (
-
-
- { this.props.title }
-
-
-
-
+
{ this.props.description }
@@ -597,12 +591,10 @@ module.exports = React.createClass({
{ addressSelector }
{ this.props.extraNode }
-
-
- { this.props.button }
-
-
-
+
+
);
},
});
diff --git a/src/components/views/dialogs/BaseDialog.js b/src/components/views/dialogs/BaseDialog.js
index 518d29aa8c..8e6f944df3 100644
--- a/src/components/views/dialogs/BaseDialog.js
+++ b/src/components/views/dialogs/BaseDialog.js
@@ -76,7 +76,7 @@ export default React.createClass({
>
-
+
{ this.props.title }
{ this.props.children }
diff --git a/src/components/views/dialogs/ChatCreateOrReuseDialog.js b/src/components/views/dialogs/ChatCreateOrReuseDialog.js
index ef21db7ecb..dc4f3f77db 100644
--- a/src/components/views/dialogs/ChatCreateOrReuseDialog.js
+++ b/src/components/views/dialogs/ChatCreateOrReuseDialog.js
@@ -138,6 +138,7 @@ export default class ChatCreateOrReuseDialog extends React.Component {
} else {
// Show the avatar, name and a button to confirm that a new chat is requested
const BaseAvatar = sdk.getComponent('avatars.BaseAvatar');
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const Spinner = sdk.getComponent('elements.Spinner');
title = _t('Start chatting');
@@ -167,11 +168,8 @@ export default class ChatCreateOrReuseDialog extends React.Component {
{ profile }
-
-
- { _t('Start Chatting') }
-
-
+
;
}
diff --git a/src/components/views/dialogs/ConfirmUserActionDialog.js b/src/components/views/dialogs/ConfirmUserActionDialog.js
index 39e1f66f96..f347261470 100644
--- a/src/components/views/dialogs/ConfirmUserActionDialog.js
+++ b/src/components/views/dialogs/ConfirmUserActionDialog.js
@@ -19,7 +19,6 @@ import PropTypes from 'prop-types';
import { MatrixClient } from 'matrix-js-sdk';
import sdk from '../../../index';
import { _t } from '../../../languageHandler';
-import classnames from 'classnames';
import { GroupMemberType } from '../../../groups';
/*
@@ -77,13 +76,11 @@ export default React.createClass({
render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar");
const BaseAvatar = sdk.getComponent("views.avatars.BaseAvatar");
- const confirmButtonClass = classnames({
- 'mx_Dialog_primary': true,
- 'danger': this.props.danger,
- });
+ const confirmButtonClass = this.props.danger ? 'danger' : '';
let reasonBox;
if (this.props.askReason) {
@@ -128,17 +125,11 @@ export default React.createClass({
{ userId }
{ reasonBox }
-
-
- { this.props.action }
-
-
-
- { _t("Cancel") }
-
-
+
);
},
diff --git a/src/components/views/dialogs/CreateGroupDialog.js b/src/components/views/dialogs/CreateGroupDialog.js
index 168fe75947..d811dde09e 100644
--- a/src/components/views/dialogs/CreateGroupDialog.js
+++ b/src/components/views/dialogs/CreateGroupDialog.js
@@ -159,10 +159,10 @@ export default React.createClass({
{ createErrorNode }
+
{ _t("Cancel") }
-
diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js
index 366c5ac678..d9287d23da 100644
--- a/src/components/views/dialogs/CreateRoomDialog.js
+++ b/src/components/views/dialogs/CreateRoomDialog.js
@@ -42,6 +42,7 @@ export default React.createClass({
render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return (
-
-
- { _t('Cancel') }
-
-
- { _t('Create Room') }
-
-
+
);
},
diff --git a/src/components/views/dialogs/DeactivateAccountDialog.js b/src/components/views/dialogs/DeactivateAccountDialog.js
index 7d850fce2b..87228b4733 100644
--- a/src/components/views/dialogs/DeactivateAccountDialog.js
+++ b/src/components/views/dialogs/DeactivateAccountDialog.js
@@ -78,6 +78,7 @@ export default class DeactivateAccountDialog extends React.Component {
}
render() {
+ const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const Loader = sdk.getComponent("elements.Spinner");
let passwordBoxClass = '';
@@ -100,10 +101,11 @@ export default class DeactivateAccountDialog extends React.Component {
}
return (
-
-
- { _t("Deactivate Account") }
-
+
{ _t("This will make your account permanently unusable. You will not be able to re-register the same user ID.") }
@@ -131,7 +133,7 @@ export default class DeactivateAccountDialog extends React.Component {
{ cancelButton }
-
+
);
}
}
diff --git a/src/components/views/dialogs/QuestionDialog.js b/src/components/views/dialogs/QuestionDialog.js
index 719f372cfe..c783197f52 100644
--- a/src/components/views/dialogs/QuestionDialog.js
+++ b/src/components/views/dialogs/QuestionDialog.js
@@ -19,7 +19,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index';
import { _t } from '../../../languageHandler';
-import classnames from 'classnames';
export default React.createClass({
displayName: 'QuestionDialog',
@@ -54,30 +53,27 @@ export default React.createClass({
render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
- const cancelButton = this.props.hasCancelButton ? (
-
- { _t("Cancel") }
-
- ) : null;
- const buttonClasses = classnames({
- mx_Dialog_primary: true,
- danger: this.props.danger,
- });
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
+ let primaryButtonClass = "";
+ if (this.props.danger) {
+ primaryButtonClass = "danger";
+ }
return (
{ this.props.description }
-
-
-
- { this.props.button || _t('OK') }
-
+
.
+
{ this.props.extraButtons }
- { cancelButton }
-
+
);
},
diff --git a/src/components/views/dialogs/SessionRestoreErrorDialog.js b/src/components/views/dialogs/SessionRestoreErrorDialog.js
index 63b9c64530..77f31a8d80 100644
--- a/src/components/views/dialogs/SessionRestoreErrorDialog.js
+++ b/src/components/views/dialogs/SessionRestoreErrorDialog.js
@@ -41,6 +41,7 @@ export default React.createClass({
render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
let bugreport;
if (SdkConfig.get().bug_report_endpoint_url) {
@@ -69,11 +70,9 @@ export default React.createClass({
{ bugreport }
-
-
- { _t("Continue anyway") }
-
-
+
);
},
diff --git a/src/components/views/dialogs/TextInputDialog.js b/src/components/views/dialogs/TextInputDialog.js
index d45e70c043..dadf7b7beb 100644
--- a/src/components/views/dialogs/TextInputDialog.js
+++ b/src/components/views/dialogs/TextInputDialog.js
@@ -17,7 +17,6 @@ limitations under the License.
import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index';
-import { _t } from '../../../languageHandler';
export default React.createClass({
displayName: 'TextInputDialog',
@@ -59,6 +58,7 @@ export default React.createClass({
render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return (
-
-
- { _t("Cancel") }
-
-
- { this.props.button }
-
-
+
);
},
diff --git a/src/components/views/dialogs/UnknownDeviceDialog.js b/src/components/views/dialogs/UnknownDeviceDialog.js
index b1e9c390e6..eaf2537355 100644
--- a/src/components/views/dialogs/UnknownDeviceDialog.js
+++ b/src/components/views/dialogs/UnknownDeviceDialog.js
@@ -180,18 +180,11 @@ export default React.createClass({
}
});
});
- let sendButton;
- if (haveUnknownDevices) {
- sendButton =
- { this.props.sendAnywayLabel }
- ;
- } else {
- sendButton =
- { this.props.sendLabel }
- ;
- }
+ const sendButtonOnClick = haveUnknownDevices ? this._onSendAnywayClicked : this._onSendClicked;
+ const sendButtonLabel = haveUnknownDevices ? this.props.sendAnywayLabel : this.props.sendAnywayLabel;
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return (
-
- {sendButton}
-
- {_t("Dismiss")}
-
-
+
);
// XXX: do we want to give the user the option to enable blacklistUnverifiedDevices for this room (or globally) at this point?
diff --git a/src/components/views/elements/DialogButtons.js b/src/components/views/elements/DialogButtons.js
new file mode 100644
index 0000000000..c159324c1d
--- /dev/null
+++ b/src/components/views/elements/DialogButtons.js
@@ -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 (
+
+
+ { this.props.primaryButton }
+
+ { this.props.children }
+
+ { _t("Cancel") }
+
+
+ );
+ },
+});