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 <polymer-element name="ct-tree-status"> | 7 <polymer-element name="ct-tree-status"> |
8 <template> | 8 <template> |
9 <template if="{{ message }}"> | 9 <template if="{{ message }}"> |
10 <style> | 10 <style> |
11 :host { | 11 :host { |
12 display: block; | 12 display: flex; |
13 whitespace: nowrap; | 13 whitespace: nowrap; |
14 overflow: hidden; | 14 overflow: hidden; |
15 text-overflow: ellispis; | 15 text-overflow: ellispis; |
16 } | 16 } |
17 | 17 |
18 :host([status=throttled]) { | 18 :host([status=throttled]) { |
19 background-color: khaki; | 19 background-color: khaki; |
20 } | 20 } |
21 | 21 |
22 :host([status=closed]) { | 22 :host([status=closed]), |
| 23 :host([status=closed]) a { |
23 color: white; | 24 color: white; |
24 background-color: tomato; | 25 background-color: tomato; |
25 } | 26 } |
26 </style> | 27 </style> |
27 {{ project }}: {{ message }} | 28 <div style="flex: 1">{{ project }}: {{ message }}</div> |
| 29 <div style="padding: 0 5px;">[ <a href="{{ project | _url }}">details</a>
]</div> |
28 </template> | 30 </template> |
29 </template> | 31 </template> |
30 <script> | 32 <script> |
31 Polymer({ | 33 Polymer({ |
32 publish: { | 34 publish: { |
33 project: '', | 35 project: '', |
34 message: '', | 36 message: '', |
35 status: { | 37 status: { |
36 value: 'open', | 38 value: 'open', |
37 reflect: true, | 39 reflect: true, |
38 }, | 40 }, |
39 }, | 41 }, |
40 | 42 |
| 43 _url: function(project) { |
| 44 return treestatus.urlByName(this.project); |
| 45 }, |
| 46 |
41 update: function() { | 47 update: function() { |
42 var url = treestatus.urlByName(this.project); | 48 var url = this._url(this.project) + 'current?format=json'; |
43 return net.json(url).then(function(response) { | 49 return net.json(url).then(function(response) { |
44 this.updateStatus(response); | 50 this.updateStatus(response); |
45 }.bind(this)); | 51 }.bind(this)); |
46 }, | 52 }, |
47 | 53 |
48 updateStatus: function(status) { | 54 updateStatus: function(status) { |
49 if (status.can_commit_freely) { | 55 if (status.can_commit_freely) { |
50 this.message = null; | 56 this.message = null; |
51 this.status = 'open'; | 57 this.status = 'open'; |
52 return; | 58 return; |
53 } | 59 } |
54 | 60 |
55 this.message = status.message + ' by ' + status.username; | 61 this.message = status.message + ' by ' + status.username; |
56 var responseLowerCase = status.message.toLowerCase(); | 62 var responseLowerCase = status.message.toLowerCase(); |
57 if (responseLowerCase.indexOf('throttled') != -1) { | 63 if (responseLowerCase.indexOf('throttled') != -1) { |
58 this.status = 'throttled'; | 64 this.status = 'throttled'; |
59 } else if (responseLowerCase.indexOf("closed") != -1) { | 65 } else if (responseLowerCase.indexOf("closed") != -1) { |
60 this.status = 'closed'; | 66 this.status = 'closed'; |
61 } else { | 67 } else { |
62 this.status = 'unknown'; | 68 this.status = 'unknown'; |
63 } | 69 } |
64 }, | 70 }, |
65 }); | 71 }); |
66 </script> | 72 </script> |
67 </polymer-element> | 73 </polymer-element> |
OLD | NEW |