Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <link rel="import" href="/bower_components/polymer/polymer.html"> | |
| 2 | |
| 3 <link rel="import" href="/bower_components/iron-collapse/iron-collapse.html"> | |
| 4 | |
| 5 <dom-module id="som-rev-range"> | |
| 6 <template> | |
| 7 <style> | |
| 8 .commit { | |
| 9 font-family: monospace; | |
| 10 font-size: 9pt; | |
| 11 margin: 1em; | |
| 12 } | |
| 13 </style> | |
| 14 <div on-tap="_toggleCollapse"> | |
| 15 [[range.repo]]: <a target="_blank" href$="[[_regressionRangeLink(range)]]" >[[_regressionRange(range)]]</a> | |
| 16 </div> | |
| 17 <iron-collapse id="collapse"> | |
| 18 <template is="dom-repeat" items="[[_revs]]" as="rev"> | |
| 19 <div class="commit"> | |
| 20 <a href$="https://chromium.googlesource.com/chromium/src/+/[[rev.commi t]]" target="_blank">[[_shortHash(rev.commit)]]</a> | |
| 21 (<a href$="mailto:[[rev.author.email]]">[[rev.author.name]]</a>): | |
| 22 [[_firstLine(rev.message)]] | |
| 23 </div> | |
| 24 </template> | |
| 25 <div id="loadingMessage" hidden>Loading revisions...</div> | |
| 26 </iron-collapse> | |
| 27 </template> | |
| 28 <script> | |
| 29 (function() { | |
| 30 'use strict'; | |
| 31 | |
| 32 Polymer({ | |
| 33 is: 'som-rev-range', | |
| 34 | |
| 35 properties: { | |
| 36 range: { | |
| 37 type: Object, | |
| 38 value: null | |
| 39 }, | |
| 40 _revs: { | |
| 41 type: Array, | |
| 42 value: null | |
| 43 }, | |
| 44 }, | |
| 45 | |
| 46 _toggleCollapse: function() { | |
| 47 if (!this._revs) { | |
| 48 let start = this._regressionStart(this.range); | |
| 49 let end = this._regressionEnd(this.range); | |
| 50 let url = `/api/v1/revrange/${start}/${end}`; | |
|
martiniss
2016/06/13 22:01:03
why ` instead of '?
seanmccullough1
2016/06/13 23:27:38
html5 template strings are contained in ``s. Note
| |
| 51 this.$.loadingMessage.hidden = false; | |
| 52 fetch(url).then( (resp) => { | |
|
martiniss
2016/06/13 22:01:03
style elsewhere is then((
seanmccullough1
2016/06/13 23:27:38
Done.
| |
| 53 resp.text().then( (bodyJson) => { | |
| 54 // remove the )]}' on the first line. | |
| 55 bodyJson = bodyJson.substr(")]}'\n".length); | |
| 56 let body = JSON.parse(bodyJson); | |
| 57 this._revs = body.log; | |
| 58 this.$.loadingMessage.hidden = true; | |
| 59 }, (reject) => { | |
| 60 debugger; | |
|
martiniss
2016/06/13 22:01:03
console.error ?
seanmccullough1
2016/06/13 23:27:38
Done.
| |
| 61 }); | |
| 62 }, (rejection) => { | |
| 63 debugger; | |
| 64 }); | |
| 65 } | |
| 66 | |
| 67 this.$.collapse.toggle(); | |
|
martiniss
2016/06/13 22:01:03
should this be inside the then()? Or is it synchro
seanmccullough1
2016/06/13 23:27:38
It should immediately toggle the collapse for the
| |
| 68 }, | |
| 69 | |
| 70 _shortHash: function(hash) { | |
| 71 return hash.substring(0, 8); | |
| 72 }, | |
| 73 | |
| 74 _firstLine: function(message) { | |
| 75 return message.split('\n')[0]; | |
| 76 }, | |
| 77 | |
| 78 _regressionStart: function(range) { | |
| 79 if (!range.positions || range.positions.length == 0) { | |
| 80 return ''; | |
| 81 } | |
| 82 | |
| 83 return this._parseCommitPosition(range.positions[0]); | |
| 84 }, | |
| 85 | |
| 86 _regressionEnd: function(range) { | |
| 87 if (!range.positions || range.positions.length == 0) { | |
| 88 return ''; | |
| 89 } | |
| 90 | |
| 91 return this._parseCommitPosition( | |
| 92 range.positions[range.positions.length - 1]); | |
| 93 }, | |
| 94 | |
| 95 _regressionRange: function(range) { | |
| 96 let start = this._regressionStart(range); | |
| 97 let end = this._regressionEnd(range); | |
| 98 | |
| 99 if (start && end) { | |
| 100 return `${start} - ${end}`; | |
| 101 } | |
| 102 | |
| 103 return start; | |
| 104 }, | |
| 105 | |
| 106 _regressionRangeLink: function(range) { | |
| 107 if (!range.positions) { | |
| 108 return ''; | |
| 109 } | |
| 110 let end = this._parseCommitPosition(range.positions[0]); | |
| 111 let start = end; | |
| 112 if (range.positions.length > 1) { | |
| 113 end = this._parseCommitPosition( | |
| 114 range.positions[range.positions.length - 1]); | |
| 115 } | |
| 116 return 'http://test-results.appspot.com/revision_range?start=' + | |
| 117 `${start}&end=${end}`; | |
| 118 }, | |
| 119 | |
| 120 _parseCommitPosition: function(pos) { | |
| 121 let groups = /refs\/heads\/master@{#([0-9]+)}/.exec(pos); | |
| 122 if (groups && groups.length == 2) { | |
| 123 return groups[1]; | |
| 124 } | |
| 125 }, | |
| 126 | |
| 127 _uberify: function(url) { | |
|
martiniss
2016/06/13 22:01:03
we really should make a global function for this :
seanmccullough1
2016/06/13 23:27:38
oops copypasta from another file. This isn't actua
| |
| 128 let u = new URL(url); | |
| 129 if (u.hostname.includes('chromium.org')) { | |
| 130 u.hostname = 'uberchromegw.corp.google.com'; | |
| 131 u.pathname = u.pathname.replace('/p/', '/i/'); | |
| 132 } | |
| 133 u.protocol = 'https:' | |
| 134 return u.toString(); | |
| 135 } | |
| 136 }); | |
| 137 })(); | |
| 138 | |
| 139 </script> | |
| 140 </dom-module> | |
| OLD | NEW |