Chromium Code Reviews| Index: go/src/infra/appengine/sheriff-o-matic/elements/som-rev-range.html |
| diff --git a/go/src/infra/appengine/sheriff-o-matic/elements/som-rev-range.html b/go/src/infra/appengine/sheriff-o-matic/elements/som-rev-range.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1f98cf6c35bc0a2347a9fc277be5135b0cf1d21c |
| --- /dev/null |
| +++ b/go/src/infra/appengine/sheriff-o-matic/elements/som-rev-range.html |
| @@ -0,0 +1,140 @@ |
| +<link rel="import" href="/bower_components/polymer/polymer.html"> |
| + |
| +<link rel="import" href="/bower_components/iron-collapse/iron-collapse.html"> |
| + |
| +<dom-module id="som-rev-range"> |
| + <template> |
| + <style> |
| + .commit { |
| + font-family: monospace; |
| + font-size: 9pt; |
| + margin: 1em; |
| + } |
| + </style> |
| + <div on-tap="_toggleCollapse"> |
| + [[range.repo]]: <a target="_blank" href$="[[_regressionRangeLink(range)]]">[[_regressionRange(range)]]</a> |
| + </div> |
| + <iron-collapse id="collapse"> |
| + <template is="dom-repeat" items="[[_revs]]" as="rev"> |
| + <div class="commit"> |
| + <a href$="https://chromium.googlesource.com/chromium/src/+/[[rev.commit]]" target="_blank">[[_shortHash(rev.commit)]]</a> |
| + (<a href$="mailto:[[rev.author.email]]">[[rev.author.name]]</a>): |
| + [[_firstLine(rev.message)]] |
| + </div> |
| + </template> |
| + <div id="loadingMessage" hidden>Loading revisions...</div> |
| + </iron-collapse> |
| + </template> |
| + <script> |
| + (function() { |
| + 'use strict'; |
| + |
| + Polymer({ |
| + is: 'som-rev-range', |
| + |
| + properties: { |
| + range: { |
| + type: Object, |
| + value: null |
| + }, |
| + _revs: { |
| + type: Array, |
| + value: null |
| + }, |
| + }, |
| + |
| + _toggleCollapse: function() { |
| + if (!this._revs) { |
| + let start = this._regressionStart(this.range); |
| + let end = this._regressionEnd(this.range); |
| + 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
|
| + this.$.loadingMessage.hidden = false; |
| + fetch(url).then( (resp) => { |
|
martiniss
2016/06/13 22:01:03
style elsewhere is then((
seanmccullough1
2016/06/13 23:27:38
Done.
|
| + resp.text().then( (bodyJson) => { |
| + // remove the )]}' on the first line. |
| + bodyJson = bodyJson.substr(")]}'\n".length); |
| + let body = JSON.parse(bodyJson); |
| + this._revs = body.log; |
| + this.$.loadingMessage.hidden = true; |
| + }, (reject) => { |
| + debugger; |
|
martiniss
2016/06/13 22:01:03
console.error ?
seanmccullough1
2016/06/13 23:27:38
Done.
|
| + }); |
| + }, (rejection) => { |
| + debugger; |
| + }); |
| + } |
| + |
| + 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
|
| + }, |
| + |
| + _shortHash: function(hash) { |
| + return hash.substring(0, 8); |
| + }, |
| + |
| + _firstLine: function(message) { |
| + return message.split('\n')[0]; |
| + }, |
| + |
| + _regressionStart: function(range) { |
| + if (!range.positions || range.positions.length == 0) { |
| + return ''; |
| + } |
| + |
| + return this._parseCommitPosition(range.positions[0]); |
| + }, |
| + |
| + _regressionEnd: function(range) { |
| + if (!range.positions || range.positions.length == 0) { |
| + return ''; |
| + } |
| + |
| + return this._parseCommitPosition( |
| + range.positions[range.positions.length - 1]); |
| + }, |
| + |
| + _regressionRange: function(range) { |
| + let start = this._regressionStart(range); |
| + let end = this._regressionEnd(range); |
| + |
| + if (start && end) { |
| + return `${start} - ${end}`; |
| + } |
| + |
| + return start; |
| + }, |
| + |
| + _regressionRangeLink: function(range) { |
| + if (!range.positions) { |
| + return ''; |
| + } |
| + let end = this._parseCommitPosition(range.positions[0]); |
| + let start = end; |
| + if (range.positions.length > 1) { |
| + end = this._parseCommitPosition( |
| + range.positions[range.positions.length - 1]); |
| + } |
| + return 'http://test-results.appspot.com/revision_range?start=' + |
| + `${start}&end=${end}`; |
| + }, |
| + |
| + _parseCommitPosition: function(pos) { |
| + let groups = /refs\/heads\/master@{#([0-9]+)}/.exec(pos); |
| + if (groups && groups.length == 2) { |
| + return groups[1]; |
| + } |
| + }, |
| + |
| + _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
|
| + let u = new URL(url); |
| + if (u.hostname.includes('chromium.org')) { |
| + u.hostname = 'uberchromegw.corp.google.com'; |
| + u.pathname = u.pathname.replace('/p/', '/i/'); |
| + } |
| + u.protocol = 'https:' |
| + return u.toString(); |
| + } |
| + }); |
| + })(); |
| + |
| + </script> |
| +</dom-module> |