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
1=== modified file 'app/payui.qml'
2--- app/payui.qml 2014-07-02 20:36:40 +0000
3+++ app/payui.qml 2014-07-14 19:55:00 +0000
4@@ -1,3 +1,19 @@
5+/*
6+ * Copyright 2014 Canonical Ltd.
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21 import QtQuick 2.0
22 import Ubuntu.Components 0.1
23 import Ubuntu.Components.Popups 0.1
24@@ -35,8 +51,6 @@
25
26 property bool loading: true
27 property bool purchasing: false
28- property string errorTitle: ""
29- property string errorMessage: ""
30
31
32 AccountServiceModel {
33@@ -72,9 +86,7 @@
34 onBuyItemFailed: {
35 mainView.purchasing = false;
36 hideLoading();
37- var title = i18n.tr("Purchase failed");
38- var message = i18n.tr("The purchase couldn't be completed.");
39- mainView.showErrorDialog(title, message);
40+ purchaseErrorDialog.open = true;
41 }
42
43 onBuyItemSucceeded: {
44@@ -91,20 +103,24 @@
45
46 onError: {
47 hideLoading();
48- var title = i18n.tr("Error contacting the server");
49- var message = i18n.tr("Do you want to try again?");
50- mainView.showErrorDialog(title, message);
51+ serverErrorDialog.open = true;
52 }
53
54 onAuthenticationError: {
55- hideLoading();
56- pageStack.currentPage.showWrongPassword();
57+ if (pageStack.currentPage) {
58+ mainView.hideLoading();
59+ pageStack.currentPage.showWrongPassword();
60+ } else {
61+ mainView.state = "no-credentials";
62+ pageStack.push(noCredentials);
63+ mainView.hideLoading();
64+ }
65 }
66
67 onCredentialsNotFound: {
68 mainView.state = "no-credentials";
69 pageStack.push(noCredentials);
70- hideLoading();
71+ mainView.hideLoading();
72 }
73 }
74
75@@ -117,10 +133,49 @@
76 mainView.loading = false;
77 }
78
79- function showErrorDialog(title, message) {
80- mainView.errorTitle = title;
81- mainView.errorMessage = message;
82- PopupUtils.open(errorDialogContainer);
83+ ErrorDialog {
84+ id: purchaseErrorDialog
85+ title: i18n.tr("Purchase failed")
86+ message: i18n.tr("The purchase couldn't be completed.")
87+
88+ onRetry: {
89+ mainView.showLoading();
90+ purchase.checkCredentials();
91+ }
92+
93+ onClose: {
94+ purchase.quitCancel();
95+ }
96+ }
97+
98+ ErrorDialog {
99+ id: serverErrorDialog
100+ title: i18n.tr("Error contacting the server")
101+ message: i18n.tr("Do you want to try again?")
102+
103+ onRetry: {
104+ mainView.showLoading();
105+ purchase.checkCredentials();
106+ }
107+
108+ onClose: {
109+ purchase.quitCancel();
110+ }
111+ }
112+
113+ ErrorDialog {
114+ id: creditCardErrorDialog
115+ title: i18n.tr("Adding Credit Card failed")
116+ message: i18n.tr("Do you want to try again?")
117+
118+ onRetry: {
119+ mainView.showLoading();
120+ purchase.checkCredentials();
121+ }
122+
123+ onClose: {
124+ purchase.quitCancel();
125+ }
126 }
127
128 Component {
129@@ -135,7 +190,7 @@
130
131 onRunningChanged: {
132 if(!running) {
133- PopupUtils.close(loadingDialog);
134+ PopupUtils.close(loadingDialog);
135 }
136 }
137 }
138@@ -151,33 +206,6 @@
139 }
140 }
141
142- Component {
143- id: errorDialogContainer
144- Dialog {
145- id: errorDialog
146- title: mainView.errorTitle
147- text: mainView.errorMessage
148-
149- Button {
150- text: i18n.tr("Retry")
151- color: UbuntuColors.orange
152- onClicked: {
153- showLoading();
154- purchase.checkCredentials();
155- PopupUtils.close(errorDialog);
156- }
157- }
158- Button {
159- text: i18n.tr("Exit")
160- color: UbuntuColors.coolGrey
161- onClicked: {
162- PopupUtils.close(errorDialog);
163- purchase.quitCancel();
164- }
165- }
166- }
167- }
168-
169 PageStack {
170 id: pageStack
171 Component.onCompleted: {
172@@ -236,13 +264,9 @@
173 onPurchaseCanceled: {
174 hideLoading();
175 if (mainView.state == "add-payment") {
176- var title = i18n.tr("Adding Credit Card failed");
177- var message = i18n.tr("Do you want to try again?");
178- mainView.showErrorDialog(title, message);
179+ creditCardErrorDialog.open = true;
180 } else {
181- var title = i18n.tr("Purchase failed");
182- var message = i18n.tr("The purchase couldn't be completed.");
183- mainView.showErrorDialog(title, message);
184+ purchaseErrorDialog.open = true;
185 }
186 }
187 onPurchaseSucceeded: {
188
189=== added file 'app/ui/ErrorDialog.qml'
190--- app/ui/ErrorDialog.qml 1970-01-01 00:00:00 +0000
191+++ app/ui/ErrorDialog.qml 2014-07-14 19:55:00 +0000
192@@ -0,0 +1,65 @@
193+/*
194+ * Copyright 2014 Canonical Ltd.
195+ *
196+ * This program is free software; you can redistribute it and/or modify
197+ * it under the terms of the GNU General Public License as published by
198+ * the Free Software Foundation; version 3.
199+ *
200+ * This program is distributed in the hope that it will be useful,
201+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
202+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
203+ * GNU General Public License for more details.
204+ *
205+ * You should have received a copy of the GNU General Public License
206+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
207+ */
208+
209+import QtQuick 2.0
210+import Ubuntu.Components 0.1
211+import Ubuntu.Components.Popups 0.1
212+
213+Item {
214+ id: dialogErrorItem
215+ property string title: ""
216+ property string message: ""
217+ property bool open: false
218+
219+ signal retry
220+ signal close
221+
222+ onOpenChanged: {
223+ if (dialogErrorItem.open) {
224+ PopupUtils.open(errorDialogContainer);
225+ }
226+ }
227+
228+ Component {
229+ id: errorDialogContainer
230+
231+ Dialog {
232+ id: errorDialog
233+ title: dialogErrorItem.title
234+ text: dialogErrorItem.message
235+
236+ Button {
237+ text: i18n.tr("Retry")
238+ color: UbuntuColors.orange
239+ onClicked: {
240+ dialogErrorItem.retry();
241+ dialogErrorItem.open = false;
242+ PopupUtils.close(errorDialog);
243+ }
244+ }
245+ Button {
246+ text: i18n.tr("Close")
247+ color: UbuntuColors.coolGrey
248+ onClicked: {
249+ dialogErrorItem.close();
250+ dialogErrorItem.open = false;
251+ PopupUtils.close(errorDialog);
252+ }
253+ }
254+ }
255+ }
256+
257+}
258
259=== removed file 'app/ui/SuccessPage.qml'
260--- app/ui/SuccessPage.qml 2014-04-16 18:29:09 +0000
261+++ app/ui/SuccessPage.qml 1970-01-01 00:00:00 +0000
262@@ -1,33 +0,0 @@
263-/*
264- * Copyright 2013-2014 Canonical Ltd.
265- *
266- * This program is free software; you can redistribute it and/or modify
267- * it under the terms of the GNU General Public License as published by
268- * the Free Software Foundation; version 3.
269- *
270- * This program is distributed in the hope that it will be useful,
271- * but WITHOUT ANY WARRANTY; without even the implied warranty of
272- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
273- * GNU General Public License for more details.
274- *
275- * You should have received a copy of the GNU General Public License
276- * along with this program. If not, see <http://www.gnu.org/licenses/>.
277- */
278-
279-import QtQuick 2.0
280-import Ubuntu.Components 0.1
281-
282-
283-Page {
284- id: pageSuccess
285- objectName: "pageSuccess"
286-
287- property alias successMessage: successLabel
288-
289- Label {
290- id: successLabel
291- text: "Success"
292- fontSize: "x-large"
293- anchors.centerIn: parent
294- }
295-}
296
297=== modified file 'manifest.json'
298--- manifest.json 2014-07-04 14:24:22 +0000
299+++ manifest.json 2014-07-14 19:55:00 +0000
300@@ -10,6 +10,6 @@
301 "desktop": "payui.desktop"
302 }
303 },
304- "version": "0.2.7",
305+ "version": "0.2.8",
306 "maintainer": "Sarmentero Diego <diego.sarmentero@canonical.com>"
307 }
308\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: