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