Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: Tools/GardeningServer/ui/ct-tree-status.html

Issue 443243002: Move treestatus.js to a model class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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" attributes="treeStatus">
ojan 2014/08/07 18:30:48 Nit: how about just calling the attribute "status"
dsinclair 2014/08/08 13:43:47 Done.
8 <template> 10 <template>
9 <style> 11 <style>
10 :host { 12 :host {
11 display: flex; 13 display: flex;
14 white-space: nowrap;
15 overflow: hidden;
16 text-overflow: ellipsis;
12 } 17 }
13 18
14 :host([status=throttled]) { 19 #container {
20 display: flex;
21 width: 100%;
22 }
23 #container[status=throttled] {
15 background-color: #fffc6c; 24 background-color: #fffc6c;
25 margin: 5px;
26 padding: 3px;
16 } 27 }
17 28
18 :host([status=closed]), 29 #container[status=closed],
19 :host([status=closed]) a { 30 #container[status=closed] a {
20 color: white; 31 color: white;
21 background-color: #e98080; 32 background-color: #e98080;
33 margin: 5px;
34 padding: 3px;
22 } 35 }
23 36
24 .message { 37 .message {
25 flex: 1; 38 flex: 1;
26 overflow: hidden; 39 overflow: hidden;
27 text-overflow: ellipsis; 40 text-overflow: ellipsis;
28 white-space: nowrap; 41 white-space: nowrap;
29 } 42 }
30 </style> 43 </style>
31 <template if="{{ message }}"> 44 <template if="{{ treeStatus.message }}">
32 <div class="message">{{ project }}: {{ message }}</div> 45 <div id="container" status="{{ treeStatus.status }}">
33 <div style="padding: 0 5px;">[ <a href="{{ project | _url }}">details</a> ]</div> 46 <div class="message">{{ treeStatus.project }}: {{ treeStatus.message }}< /div>
47 <div style="padding: 0 5px;">[ <a href="{{ _url() }}">details</a> ]</div >
48 </div>
34 </template> 49 </template>
35 </template> 50 </template>
36 <script> 51 <script>
37 Polymer({ 52 Polymer({
38 publish: { 53 _url: function() {
39 project: '', 54 return this.treeStatus.url();
40 message: '', 55 }
41 status: { 56 });
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> 57 </script>
77 </polymer-element> 58 </polymer-element>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698