Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit fc13660

Browse files
dbkrlukebarnard1
authored andcommitted
UI fixes in SessionRestoreErrorDialog
* Make the 'delete my data' button not the default * Make it red * Give it a confirmation dialog * Remove the 'cancel' button: what does it mean to cancel an error? In this case, it tried again and almost certainly got the same error. * Remove the top-right 'x' and don't cancel on esc for the same reason. * Move 'send bug report' to a button rather than a 'click here' link * Add a 'refresh' button which, even if it's no more likely to work, will at least look like it's doing something (it's mostly so if you don't have a bug report endpoint, there's still a button other than the one that deletes all your data).
1 parent fba8a7d commit fc13660

File tree

5 files changed

+79
-43
lines changed

5 files changed

+79
-43
lines changed

res/css/_common.scss

+1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ textarea {
250250
.mx_Dialog button.danger, .mx_Dialog input[type="submit"].danger {
251251
background-color: $warning-color;
252252
border: solid 1px $warning-color;
253+
color: $accent-fg-color;
253254
}
254255

255256
.mx_Dialog button:disabled, .mx_Dialog input[type="submit"]:disabled {

src/components/views/dialogs/BaseDialog.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2017 Vector Creations Ltd
3+
Copyright 2018 New Vector Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -41,6 +42,13 @@ export default React.createClass({
4142
// cancelled (BaseDialog itself only calls this with false).
4243
onFinished: PropTypes.func.isRequired,
4344

45+
// Whether the dialog should have a 'close' button that will
46+
// cause the dialog to be cancelled. This should only be set
47+
// to true if there is nothing the app can sensibly do if the
48+
// dialog is cancelled, eg. "We can't restore your session and
49+
// the app cannot work".
50+
hasCancel: PropTypes.bool,
51+
4452
// called when a key is pressed
4553
onKeyDown: PropTypes.func,
4654

@@ -59,6 +67,12 @@ export default React.createClass({
5967
contentId: React.PropTypes.string,
6068
},
6169

70+
getDefaultProps: function() {
71+
return {
72+
hasCancel: true,
73+
};
74+
},
75+
6276
childContextTypes: {
6377
matrixClient: PropTypes.instanceOf(MatrixClient),
6478
},
@@ -77,7 +91,7 @@ export default React.createClass({
7791
if (this.props.onKeyDown) {
7892
this.props.onKeyDown(e);
7993
}
80-
if (e.keyCode === KeyCode.ESCAPE) {
94+
if (this.props.hasCancel && e.keyCode === KeyCode.ESCAPE) {
8195
e.stopPropagation();
8296
e.preventDefault();
8397
this.props.onFinished(false);
@@ -104,11 +118,11 @@ export default React.createClass({
104118
// AT users can skip its presentation.
105119
aria-describedby={this.props.contentId}
106120
>
107-
<AccessibleButton onClick={this._onCancelClick}
121+
{ this.props.hasCancel ? <AccessibleButton onClick={this._onCancelClick}
108122
className="mx_Dialog_cancelButton"
109123
>
110124
<TintableSvg src="img/icons-close-button.svg" width="35" height="35" />
111-
</AccessibleButton>
125+
</AccessibleButton> : null }
112126
<div className={'mx_Dialog_title ' + this.props.titleClass} id='mx_BaseDialog_title'>
113127
{ this.props.title }
114128
</div>

src/components/views/dialogs/SessionRestoreErrorDialog.js

+40-30
Original file line numberDiff line numberDiff line change
@@ -31,63 +31,73 @@ export default React.createClass({
3131
onFinished: PropTypes.func.isRequired,
3232
},
3333

34-
componentDidMount: function() {
35-
if (this.refs.bugreportLink) {
36-
this.refs.bugreportLink.focus();
37-
}
38-
},
39-
4034
_sendBugReport: function() {
4135
const BugReportDialog = sdk.getComponent("dialogs.BugReportDialog");
4236
Modal.createTrackedDialog('Session Restore Error', 'Send Bug Report Dialog', BugReportDialog, {});
4337
},
4438

45-
_onContinueClick: function() {
46-
this.props.onFinished(true);
39+
_onClearStorageClick: function() {
40+
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
41+
Modal.createTrackedDialog('Session Restore Confirm Logout', '', QuestionDialog, {
42+
title: _t("Sign out"),
43+
description:
44+
<div>{ _t("Log out and remove encryption keys?") }</div>,
45+
button: _t("Sign out"),
46+
danger: true,
47+
onFinished: this.props.onFinished,
48+
});
4749
},
4850

49-
_onCancelClick: function() {
50-
this.props.onFinished(false);
51+
_onRefreshClick: function() {
52+
// Is this likely to help? Probably not, but giving only one button
53+
// that clears your storage seems awful.
54+
window.location.reload(true);
5155
},
5256

5357
render: function() {
5458
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
5559
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
56-
let bugreport;
5760

61+
let dialogButtons;
5862
if (SdkConfig.get().bug_report_endpoint_url) {
59-
bugreport = (
60-
<p>
61-
{ _t(
62-
"Otherwise, <a>click here</a> to send a bug report.",
63-
{},
64-
{ 'a': (sub) => <a ref="bugreportLink" onClick={this._sendBugReport}
65-
key="bugreport" href='#'>{ sub }</a> },
66-
) }
67-
</p>
68-
);
63+
dialogButtons = <DialogButtons primaryButton={_t("Send Logs")}
64+
onPrimaryButtonClick={this._sendBugReport}
65+
focus={true}
66+
hasCancel={false}
67+
>
68+
<button onClick={this._onClearStorageClick} className="danger">
69+
{ _t("Clear Storage and Sign Out") }
70+
</button>
71+
</DialogButtons>
72+
} else {
73+
dialogButtons = <DialogButtons primaryButton={_t("Refresh")}
74+
onPrimaryButtonClick={this._onRefreshClick}
75+
focus={true}
76+
hasCancel={false}
77+
>
78+
<button onClick={this._onClearStorageClick} className="danger">
79+
{ _t("Clear Storage and Sign Out") }
80+
</button>
81+
</DialogButtons>
6982
}
70-
const shouldFocusContinueButton =!(bugreport==true);
7183

7284
return (
7385
<BaseDialog className="mx_ErrorDialog" onFinished={this.props.onFinished}
74-
title={_t('Unable to restore session')}
86+
title={_t('Unable to restore session')}
7587
contentId='mx_Dialog_content'
88+
hasCancel={false}
7689
>
7790
<div className="mx_Dialog_content" id='mx_Dialog_content'>
78-
<p>{ _t("We encountered an error trying to restore your previous session. If " +
79-
"you continue, you will need to log in again, and encrypted chat " +
80-
"history will be unreadable.") }</p>
91+
<p>{ _t("We encountered an error trying to restore your previous session.") }</p>
8192

8293
<p>{ _t("If you have previously used a more recent version of Riot, your session " +
8394
"may be incompatible with this version. Close this window and return " +
8495
"to the more recent version.") }</p>
8596

86-
{ bugreport }
97+
<p>{ _t("Clearing your browser's storage may fix the problem, but will sign you " +
98+
"out and cause any encrypted chat history to become unreadable.") }</p>
8799
</div>
88-
<DialogButtons primaryButton={_t("Continue anyway")}
89-
onPrimaryButtonClick={this._onContinueClick} focus={shouldFocusContinueButton}
90-
onCancel={this._onCancelClick} />
100+
{ dialogButtons }
91101
</BaseDialog>
92102
);
93103
},

src/components/views/elements/DialogButtons.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2017 Aidan Gauland
3+
Copyright 2018 New Vector Ltd.
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -14,8 +15,6 @@ See the License for the specific language governing permissions and
1415
limitations under the License.
1516
*/
1617

17-
"use strict";
18-
1918
import React from "react";
2019
import PropTypes from "prop-types";
2120
import { _t } from '../../../languageHandler';
@@ -33,12 +32,21 @@ module.exports = React.createClass({
3332
// onClick handler for the primary button.
3433
onPrimaryButtonClick: PropTypes.func.isRequired,
3534

35+
// should there be a cancel button? default: true
36+
hasCancel: PropTypes.bool,
37+
3638
// onClick handler for the cancel button.
37-
onCancel: PropTypes.func.isRequired,
39+
onCancel: PropTypes.func,
3840

3941
focus: PropTypes.bool,
4042
},
4143

44+
getDefaultProps: function() {
45+
return {
46+
hasCancel: true,
47+
}
48+
},
49+
4250
_onCancelClick: function() {
4351
this.props.onCancel();
4452
},
@@ -57,9 +65,9 @@ module.exports = React.createClass({
5765
{ this.props.primaryButton }
5866
</button>
5967
{ this.props.children }
60-
<button onClick={this._onCancelClick}>
68+
{ this.props.hasCancel ? <button onClick={this._onCancelClick}>
6169
{ _t("Cancel") }
62-
</button>
70+
</button> : null }
6371
</div>
6472
);
6573
},

src/i18n/strings/en_EN.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
"You need to be logged in.": "You need to be logged in.",
104104
"You need to be able to invite users to do that.": "You need to be able to invite users to do that.",
105105
"Unable to create widget.": "Unable to create widget.",
106-
"Popout widget": "Popout widget",
107106
"Missing roomId.": "Missing roomId.",
108107
"Failed to send request.": "Failed to send request.",
109108
"This room is not recognised.": "This room is not recognised.",
@@ -655,6 +654,7 @@
655654
"Delete widget": "Delete widget",
656655
"Revoke widget access": "Revoke widget access",
657656
"Minimize apps": "Minimize apps",
657+
"Popout widget": "Popout widget",
658658
"Picture": "Picture",
659659
"Edit": "Edit",
660660
"Create new room": "Create new room",
@@ -807,11 +807,15 @@
807807
"Ignore request": "Ignore request",
808808
"Loading device info...": "Loading device info...",
809809
"Encryption key request": "Encryption key request",
810-
"Otherwise, <a>click here</a> to send a bug report.": "Otherwise, <a>click here</a> to send a bug report.",
810+
"Sign out": "Sign out",
811+
"Log out and remove encryption keys?": "Log out and remove encryption keys?",
812+
"Send Logs": "Send Logs",
813+
"Clear Storage and Sign Out": "Clear Storage and Sign Out",
814+
"Refresh": "Refresh",
811815
"Unable to restore session": "Unable to restore session",
812-
"We encountered an error trying to restore your previous session. If you continue, you will need to log in again, and encrypted chat history will be unreadable.": "We encountered an error trying to restore your previous session. If you continue, you will need to log in again, and encrypted chat history will be unreadable.",
816+
"We encountered an error trying to restore your previous session.": "We encountered an error trying to restore your previous session.",
813817
"If you have previously used a more recent version of Riot, your session may be incompatible with this version. Close this window and return to the more recent version.": "If you have previously used a more recent version of Riot, your session may be incompatible with this version. Close this window and return to the more recent version.",
814-
"Continue anyway": "Continue anyway",
818+
"Clearing your browser's storage may fix the problem, but will sign you out and cause any encrypted chat history to become unreadable.": "Clearing your browser's storage may fix the problem, but will sign you out and cause any encrypted chat history to become unreadable.",
815819
"Invalid Email Address": "Invalid Email Address",
816820
"This doesn't appear to be a valid email address": "This doesn't appear to be a valid email address",
817821
"Verification Pending": "Verification Pending",
@@ -1015,7 +1019,6 @@
10151019
"Status.im theme": "Status.im theme",
10161020
"Can't load user settings": "Can't load user settings",
10171021
"Server may be unavailable or overloaded": "Server may be unavailable or overloaded",
1018-
"Sign out": "Sign out",
10191022
"For security, logging out will delete any end-to-end encryption keys from this browser. If you want to be able to decrypt your conversation history from future Riot sessions, please export your room keys for safe-keeping.": "For security, logging out will delete any end-to-end encryption keys from this browser. If you want to be able to decrypt your conversation history from future Riot sessions, please export your room keys for safe-keeping.",
10201023
"Success": "Success",
10211024
"Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them": "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them",

0 commit comments

Comments
 (0)