OLD | NEW |
---|---|
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <link rel="import" href="../model/tree-status.html"> | |
8 | |
7 <polymer-element name="ct-tree-status"> | 9 <polymer-element name="ct-tree-status"> |
8 <template> | 10 <template> |
9 <style> | 11 <style> |
10 :host { | 12 :host { |
11 display: flex; | 13 display: flex; |
12 } | 14 } |
13 | 15 |
14 :host([status=throttled]) { | 16 :host([status=throttled]) { |
15 background-color: #fffc6c; | 17 background-color: #fffc6c; |
16 } | 18 } |
(...skipping 21 matching lines...) Expand all Loading... | |
38 publish: { | 40 publish: { |
39 project: '', | 41 project: '', |
40 message: '', | 42 message: '', |
41 status: { | 43 status: { |
42 value: '', | 44 value: '', |
43 reflect: true, | 45 reflect: true, |
44 }, | 46 }, |
45 }, | 47 }, |
46 | 48 |
47 _url: function(project) { | 49 _url: function(project) { |
48 return treestatus.urlByName(this.project); | 50 var treeStatus = new TreeStatus(); |
51 return treeStatus.urlByName(this.project); | |
49 }, | 52 }, |
50 | 53 |
51 update: function() { | 54 update: function() { |
ojan
2014/08/06 22:34:17
Now that we have a proper model class, lets get th
dsinclair
2014/08/07 18:09:23
Done.
| |
52 var url = this._url(this.project) + 'current?format=json'; | 55 var url = this._url(this.project) + 'current?format=json'; |
53 return net.json(url).then(function(response) { | 56 return net.json(url).then(function(response) { |
54 this.updateStatus(response); | 57 this.updateStatus(response); |
55 }.bind(this)); | 58 }.bind(this)); |
56 }, | 59 }, |
57 | 60 |
58 updateStatus: function(status) { | 61 updateStatus: function(status) { |
ojan
2014/08/06 22:34:17
Can you move most of this logic into the model cla
dsinclair
2014/08/07 18:09:23
Done.
| |
59 if (status.can_commit_freely) { | 62 if (status.can_commit_freely) { |
60 this.message = null; | 63 this.message = null; |
61 this.status = 'open'; | 64 this.status = 'open'; |
62 return; | 65 return; |
63 } | 66 } |
64 | 67 |
65 this.message = status.message + ' by ' + status.username; | 68 this.message = status.message + ' by ' + status.username; |
66 var responseLowerCase = status.message.toLowerCase(); | 69 var responseLowerCase = status.message.toLowerCase(); |
67 if (responseLowerCase.indexOf('throttled') != -1) { | 70 if (responseLowerCase.indexOf('throttled') != -1) { |
68 this.status = 'throttled'; | 71 this.status = 'throttled'; |
69 } else if (responseLowerCase.indexOf("closed") != -1) { | 72 } else if (responseLowerCase.indexOf("closed") != -1) { |
70 this.status = 'closed'; | 73 this.status = 'closed'; |
71 } else { | 74 } else { |
72 this.status = 'unknown'; | 75 this.status = 'unknown'; |
73 } | 76 } |
74 }, | 77 }, |
75 }); | 78 }); |
76 </script> | 79 </script> |
77 </polymer-element> | 80 </polymer-element> |
OLD | NEW |