Merge lp:~stephen-stewart/snapweb/handle-missing-response-in-parse into lp:~snappy-dev/snapweb/trunk

Proposed by Stephen Stewart
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 125
Merged at revision: 130
Proposed branch: lp:~stephen-stewart/snapweb/handle-missing-response-in-parse
Merge into: lp:~snappy-dev/snapweb/trunk
Diff against target: 84 lines (+18/-11)
4 files modified
www/src/css/alert.css (+6/-8)
www/src/css/layout.css (+1/-1)
www/src/js/behaviors/install.js (+1/-1)
www/src/js/models/snap.js (+10/-1)
To merge this branch: bzr merge lp:~stephen-stewart/snapweb/handle-missing-response-in-parse
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Review via email: mp+258518@code.launchpad.net

Commit message

the api doesn't always return what we expect, so fail by returning to last known state

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'www/src/css/alert.css'
2--- www/src/css/alert.css 2015-05-05 11:20:39 +0000
3+++ www/src/css/alert.css 2015-05-07 15:42:32 +0000
4@@ -2,27 +2,25 @@
5 position: relative;
6 width: 600px;
7 margin: 0 auto;
8- background-color: rgb(255, 255, 255);
9- border-radius: 0px;
10+ background-color: #fff;
11 border: 4px solid #DADADA;
12 padding: 1em 2em;
13- border-top: none;
14- color: #dd4814;
15- border-bottom-left-radius: 6px;
16- border-bottom-right-radius: 6px;
17+ color: #333;
18+ font-weight:400;
19+ border-radius:6px;
20 }
21
22 .b-alert__close {
23 position: absolute;
24 top: 0;
25- right: 0;
26+ right: -3px;
27 font-size: 14px;
28 line-height: 1;
29 }
30
31 .b-alert__close a {
32 text-decoration:none;
33- color: #ccc;
34+ color: #333;
35 display:block;
36 width:40px;
37 height:40px;
38
39=== modified file 'www/src/css/layout.css'
40--- www/src/css/layout.css 2015-05-05 11:20:39 +0000
41+++ www/src/css/layout.css 2015-05-07 15:42:32 +0000
42@@ -30,7 +30,7 @@
43
44 .b-layout__alerts {
45 position: absolute;
46- top: 60px;
47+ top: 30px;
48 width: 100%;
49 z-index: 10000;
50 }
51
52=== modified file 'www/src/js/behaviors/install.js'
53--- www/src/js/behaviors/install.js 2015-05-06 18:57:26 +0000
54+++ www/src/js/behaviors/install.js 2015-05-07 15:42:32 +0000
55@@ -36,7 +36,7 @@
56 var installer = this.ui.installer;
57 var installerButton = this.ui.installerButton;
58
59- // reset progress
60+ // reset progress
61 this.ui.installerProgress.css('right', '100%');
62
63 if (_.contains(CONF.INSTALL_STATE, state)) {
64
65=== modified file 'www/src/js/models/snap.js'
66--- www/src/js/models/snap.js 2015-05-06 18:57:26 +0000
67+++ www/src/js/models/snap.js 2015-05-07 15:42:32 +0000
68@@ -46,7 +46,16 @@
69 });
70
71 this.on('error', function(model, response, opts) {
72- this.set(this.parse(response.responseJSON));
73+ var json = JSON.parse(response.responseText);
74+ var previous = model.previousAttributes();
75+ var message;
76+ if (json && json.message) {
77+ message = json.message;
78+ } else {
79+ message = 'Sorry, something went wrong :(';
80+ }
81+ previous.message = message;
82+ model.set(previous);
83 chan.command('alert:error', model);
84 });
85

Subscribers

People subscribed via source and target branches