Merge lp:~diegosarmentero/pay-ui/error-page into lp:pay-ui

Proposed by Diego Sarmentero
Status: Merged
Approved by: Diego Sarmentero
Approved revision: 12
Merged at revision: 8
Proposed branch: lp:~diegosarmentero/pay-ui/error-page
Merge into: lp:pay-ui
Diff against target: 308 lines (+139/-83)
4 files modified
app/payui.qml (+73/-49)
app/ui/ErrorDialog.qml (+65/-0)
app/ui/SuccessPage.qml (+0/-33)
manifest.json (+1/-1)
To merge this branch: bzr merge lp:~diegosarmentero/pay-ui/error-page
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Review via email: mp+226364@code.launchpad.net

Commit message

- Show an error dialog if the server fails to reply on loading

To post a comment you must log in.
9. By Diego Sarmentero

improves in button alignment

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
10. By Diego Sarmentero

show error dialog instead of page

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
11. By Diego Sarmentero

using currentPage instead of baseLoaded

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

I think that hideLoading() needs to get pulled out of the if statement.

I think it would perhaps be better if we could instantiate the three(?) error dialogs as different objects instead of having the function. That way their strings end up in the same object together and we don't end up duplicating them in the different functions. I was thinking something like "PopupUtils.open(AuthErrorDialog)"

review: Needs Fixing
12. By Diego Sarmentero

Using different components popups for errors as requested

Revision history for this message
Ted Gould (ted) wrote :

Cool, love the Open property!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/payui.qml'
--- app/payui.qml 2014-07-02 20:36:40 +0000
+++ app/payui.qml 2014-07-14 19:55:00 +0000
@@ -1,3 +1,19 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
1import QtQuick 2.017import QtQuick 2.0
2import Ubuntu.Components 0.118import Ubuntu.Components 0.1
3import Ubuntu.Components.Popups 0.119import Ubuntu.Components.Popups 0.1
@@ -35,8 +51,6 @@
3551
36 property bool loading: true52 property bool loading: true
37 property bool purchasing: false53 property bool purchasing: false
38 property string errorTitle: ""
39 property string errorMessage: ""
4054
4155
42 AccountServiceModel {56 AccountServiceModel {
@@ -72,9 +86,7 @@
72 onBuyItemFailed: {86 onBuyItemFailed: {
73 mainView.purchasing = false;87 mainView.purchasing = false;
74 hideLoading();88 hideLoading();
75 var title = i18n.tr("Purchase failed");89 purchaseErrorDialog.open = true;
76 var message = i18n.tr("The purchase couldn't be completed.");
77 mainView.showErrorDialog(title, message);
78 }90 }
7991
80 onBuyItemSucceeded: {92 onBuyItemSucceeded: {
@@ -91,20 +103,24 @@
91103
92 onError: {104 onError: {
93 hideLoading();105 hideLoading();
94 var title = i18n.tr("Error contacting the server");106 serverErrorDialog.open = true;
95 var message = i18n.tr("Do you want to try again?");
96 mainView.showErrorDialog(title, message);
97 }107 }
98108
99 onAuthenticationError: {109 onAuthenticationError: {
100 hideLoading();110 if (pageStack.currentPage) {
101 pageStack.currentPage.showWrongPassword();111 mainView.hideLoading();
112 pageStack.currentPage.showWrongPassword();
113 } else {
114 mainView.state = "no-credentials";
115 pageStack.push(noCredentials);
116 mainView.hideLoading();
117 }
102 }118 }
103119
104 onCredentialsNotFound: {120 onCredentialsNotFound: {
105 mainView.state = "no-credentials";121 mainView.state = "no-credentials";
106 pageStack.push(noCredentials);122 pageStack.push(noCredentials);
107 hideLoading();123 mainView.hideLoading();
108 }124 }
109 }125 }
110126
@@ -117,10 +133,49 @@
117 mainView.loading = false;133 mainView.loading = false;
118 }134 }
119135
120 function showErrorDialog(title, message) {136 ErrorDialog {
121 mainView.errorTitle = title;137 id: purchaseErrorDialog
122 mainView.errorMessage = message;138 title: i18n.tr("Purchase failed")
123 PopupUtils.open(errorDialogContainer);139 message: i18n.tr("The purchase couldn't be completed.")
140
141 onRetry: {
142 mainView.showLoading();
143 purchase.checkCredentials();
144 }
145
146 onClose: {
147 purchase.quitCancel();
148 }
149 }
150
151 ErrorDialog {
152 id: serverErrorDialog
153 title: i18n.tr("Error contacting the server")
154 message: i18n.tr("Do you want to try again?")
155
156 onRetry: {
157 mainView.showLoading();
158 purchase.checkCredentials();
159 }
160
161 onClose: {
162 purchase.quitCancel();
163 }
164 }
165
166 ErrorDialog {
167 id: creditCardErrorDialog
168 title: i18n.tr("Adding Credit Card failed")
169 message: i18n.tr("Do you want to try again?")
170
171 onRetry: {
172 mainView.showLoading();
173 purchase.checkCredentials();
174 }
175
176 onClose: {
177 purchase.quitCancel();
178 }
124 }179 }
125180
126 Component {181 Component {
@@ -135,7 +190,7 @@
135190
136 onRunningChanged: {191 onRunningChanged: {
137 if(!running) {192 if(!running) {
138 PopupUtils.close(loadingDialog); 193 PopupUtils.close(loadingDialog);
139 }194 }
140 }195 }
141 }196 }
@@ -151,33 +206,6 @@
151 }206 }
152 }207 }
153208
154 Component {
155 id: errorDialogContainer
156 Dialog {
157 id: errorDialog
158 title: mainView.errorTitle
159 text: mainView.errorMessage
160
161 Button {
162 text: i18n.tr("Retry")
163 color: UbuntuColors.orange
164 onClicked: {
165 showLoading();
166 purchase.checkCredentials();
167 PopupUtils.close(errorDialog);
168 }
169 }
170 Button {
171 text: i18n.tr("Exit")
172 color: UbuntuColors.coolGrey
173 onClicked: {
174 PopupUtils.close(errorDialog);
175 purchase.quitCancel();
176 }
177 }
178 }
179 }
180
181 PageStack {209 PageStack {
182 id: pageStack210 id: pageStack
183 Component.onCompleted: {211 Component.onCompleted: {
@@ -236,13 +264,9 @@
236 onPurchaseCanceled: {264 onPurchaseCanceled: {
237 hideLoading();265 hideLoading();
238 if (mainView.state == "add-payment") {266 if (mainView.state == "add-payment") {
239 var title = i18n.tr("Adding Credit Card failed");267 creditCardErrorDialog.open = true;
240 var message = i18n.tr("Do you want to try again?");
241 mainView.showErrorDialog(title, message);
242 } else {268 } else {
243 var title = i18n.tr("Purchase failed");269 purchaseErrorDialog.open = true;
244 var message = i18n.tr("The purchase couldn't be completed.");
245 mainView.showErrorDialog(title, message);
246 }270 }
247 }271 }
248 onPurchaseSucceeded: {272 onPurchaseSucceeded: {
249273
=== added file 'app/ui/ErrorDialog.qml'
--- app/ui/ErrorDialog.qml 1970-01-01 00:00:00 +0000
+++ app/ui/ErrorDialog.qml 2014-07-14 19:55:00 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Ubuntu.Components.Popups 0.1
20
21Item {
22 id: dialogErrorItem
23 property string title: ""
24 property string message: ""
25 property bool open: false
26
27 signal retry
28 signal close
29
30 onOpenChanged: {
31 if (dialogErrorItem.open) {
32 PopupUtils.open(errorDialogContainer);
33 }
34 }
35
36 Component {
37 id: errorDialogContainer
38
39 Dialog {
40 id: errorDialog
41 title: dialogErrorItem.title
42 text: dialogErrorItem.message
43
44 Button {
45 text: i18n.tr("Retry")
46 color: UbuntuColors.orange
47 onClicked: {
48 dialogErrorItem.retry();
49 dialogErrorItem.open = false;
50 PopupUtils.close(errorDialog);
51 }
52 }
53 Button {
54 text: i18n.tr("Close")
55 color: UbuntuColors.coolGrey
56 onClicked: {
57 dialogErrorItem.close();
58 dialogErrorItem.open = false;
59 PopupUtils.close(errorDialog);
60 }
61 }
62 }
63 }
64
65}
066
=== removed file 'app/ui/SuccessPage.qml'
--- app/ui/SuccessPage.qml 2014-04-16 18:29:09 +0000
+++ app/ui/SuccessPage.qml 1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
1/*
2 * Copyright 2013-2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19
20
21Page {
22 id: pageSuccess
23 objectName: "pageSuccess"
24
25 property alias successMessage: successLabel
26
27 Label {
28 id: successLabel
29 text: "Success"
30 fontSize: "x-large"
31 anchors.centerIn: parent
32 }
33}
340
=== modified file 'manifest.json'
--- manifest.json 2014-07-04 14:24:22 +0000
+++ manifest.json 2014-07-14 19:55:00 +0000
@@ -10,6 +10,6 @@
10 "desktop": "payui.desktop"10 "desktop": "payui.desktop"
11 }11 }
12 },12 },
13 "version": "0.2.7",13 "version": "0.2.8",
14 "maintainer": "Sarmentero Diego <diego.sarmentero@canonical.com>"14 "maintainer": "Sarmentero Diego <diego.sarmentero@canonical.com>"
15}15}
16\ No newline at end of file16\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: