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