| 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 --><html><head><link rel="import" href="ct-commit.html"> |
| 6 | |
| 7 <link rel="import" href="ct-commit.html"> | |
| 8 <link rel="import" href="ct-detailed-commit.html"> | 6 <link rel="import" href="ct-detailed-commit.html"> |
| 9 <link rel="import" href="../bower_components/paper-button/paper-button.html"> | 7 <link rel="import" href="../bower_components/paper-button/paper-button.html"> |
| 10 <link rel="import" href="ct-user-prefs.html"> | 8 <link rel="import" href="ct-user-prefs.html"> |
| 11 | 9 |
| 12 <polymer-element name="ct-commit-list" attributes="flex commitList detailed susp
ectedCLsByRepo"> | 10 <dom-module id="ct-commit-list"> |
| 13 <template> | 11 <style> |
| 14 <style> | |
| 15 :host { | 12 :host { |
| 16 display: block; | 13 display: block; |
| 17 } | 14 } |
| 18 paper-icon-button { | 15 paper-icon-button { |
| 19 vertical-align: middle; | 16 vertical-align: middle; |
| 20 } | 17 } |
| 21 paper-icon-button::shadow #icon { | 18 paper-icon-button::shadow #icon { |
| 22 margin: 0px; | 19 margin: 0px; |
| 23 } | 20 } |
| 24 .repository-info { | 21 .repository-info { |
| 25 display: block; | 22 display: block; |
| 26 margin-bottom: 10px; | 23 margin-bottom: 10px; |
| 27 } | 24 } |
| 28 ct-commit { | 25 ct-commit { |
| 29 margin-left: 10px; | 26 margin-left: 10px; |
| 30 } | 27 } |
| 31 .first { | 28 .first { |
| 32 margin-top: -4px; | 29 margin-top: -4px; |
| 33 } | 30 } |
| 34 .notfirst { | 31 .notfirst { |
| 35 border-top: 1px solid lightgrey; | 32 border-top: 1px solid lightgrey; |
| 36 margin-top: 3px; | 33 margin-top: 3px; |
| 37 } | 34 } |
| 38 </style> | 35 </style> |
| 36 <template> |
| 39 <ct-user-prefs id="userPrefs"></ct-user-prefs> | 37 <ct-user-prefs id="userPrefs"></ct-user-prefs> |
| 40 <template if="{{ totalSuspectedCommits_ > 0 }}"> | 38 <template is="dom-if" if="{{computeIf(totalSuspectedCommits_)}}"> |
| 41 <a target="{{ $.userPrefs.values.linkTarget }}" href="https://findit-for-m
e.appspot.com/build-failure?url={{ representiveBuildUrl_ }}">Findit found {{ tot
alSuspectedCommits_ }} suspected CL(s).</a> | 39 <a target="{{ $.userPrefs.values.linkTarget }}" href$="{{computeHref(repre
sentiveBuildUrl_)}}">Findit found <span>{{ totalSuspectedCommits_ }}</span> susp
ected CL(s).</a> |
| 42 </template> | 40 </template> |
| 43 <template repeat="{{ repository in commitList.repositories }}"> | 41 <template is="dom-repeat" items="{{commitList.repositories}}" as="repository
"> |
| 44 <div class="repository-info"> | 42 <div class="repository-info"> |
| 45 <span style="font-weight: bold">{{ repository.name }}</span> | 43 <span style="font-weight: bold">{{ repository.name }}</span> |
| 46 <template if="{{ repository.name == 'chromium' }}"> | 44 <template is="dom-if" if="{{computeIf2(repository)}}"> |
| 47 <a target="{{ $.userPrefs.values.linkTarget }}" href="http://test-resu
lts.appspot.com/revision_range?start={{ repository.firstRevision }}&end={{ repos
itory.lastRevision }}">{{ repository.range }}</a> | 45 <a target="{{ $.userPrefs.values.linkTarget }}" href$="{{computeHref2(
repository)}}">{{ repository.range }}</a> |
| 48 </template> | 46 </template> |
| 49 <template if="{{ repository.name == 'blink' }}"> | 47 <template is="dom-if" if="{{computeIf3(repository)}}"> |
| 50 <a target="{{ $.userPrefs.values.linkTarget }}" href="http://build.chr
omium.org/f/chromium/perf/dashboard/ui/changelog_blink.html?url=/trunk&range={{
repository.firstRevision }}:{{ repository.lastRevision }}&mode=html">{{ reposito
ry.range }}</a> | 48 <a target="{{ $.userPrefs.values.linkTarget }}" href$="{{computeHref3(
repository)}}">{{ repository.range }}</a> |
| 51 </template> | 49 </template> |
| 52 <template if="{{ repository.name != 'blink' && repository.name != 'chrom
ium'}}">{{ repository.range }}</template> | 50 <template is="dom-if" if="{{computeIf4(repository)}}">{{ repository.rang
e }}</template> |
| 53 <paper-icon-button icon="unfold-more" | 51 <paper-icon-button icon="unfold-more" on-click=" _toggle " repository="{
{ repository.name }}"></paper-icon-button> |
| 54 on-click="{{ _toggle }}" repository="{{ repository.name }}"></paper-
icon-button> | 52 <template is="dom-if" if="{{computeIf5(repository, suspectedCommitsByRep
o_)}}"> |
| 55 <template if="{{ suspectedCommitsByRepo_[repository.name] && _numberOfSu
spectedCL(repository.name) > 0 }}"> | 53 <span style="color: red"><span>{{ _numberOfSuspectedCL(repository.name
) }}</span> suspected CL(s)</span> |
| 56 <span style="color: red">{{ _numberOfSuspectedCL(repository.name) }} s
uspected CL(s)</span> | |
| 57 </template> | 54 </template> |
| 58 <template if="{{ repository.expanded }}"> | 55 <template is="dom-if" if="{{ repository.expanded }}"> |
| 59 <template repeat="{{ commit, commit_index in repository.commits }}"> | 56 <template is="dom-repeat" items="{{repository.commits }}" as="commit"
index-as="commit_index"> |
| 60 <template if="{{ !detailed }}"> | 57 <template is="dom-if" if="{{ !detailed }}"> |
| 61 <ct-commit class="{{ commit_index == 0 ? 'first' : 'notfirst' }}"
data="{{ commit }}" suspected="{{ commit.revision | _isSuspected(repository.name
) }}"></ct-commit> | 58 <ct-commit data="{{ commit }}" suspected="{{computeClass(commit_in
dex)}}" class$="{{computeClass(commit_index)}}"></ct-commit> |
| 62 </template> | 59 </template> |
| 63 <template if="{{ detailed }}"> | 60 <template is="dom-if" if="{{ detailed }}"> |
| 64 <ct-detailed-commit class="{{ commit_index == 0 ? 'first' : 'notfi
rst' }}" data="{{ commit }}" suspected="{{ commit.revision | _isSuspected(reposi
tory.name) }}"></ct-detailed-commit> | 61 <ct-detailed-commit data="{{ commit }}" suspected="{{_isSuspected(
commit.revision, repository.name)}}" class$="{{computeClass(commit_index)}}"></c
t-detailed-commit> |
| 65 </template> | 62 </template> |
| 66 </template> | 63 </template> |
| 67 </template> | 64 </template> |
| 68 </div> | 65 </div> |
| 69 </template> | 66 </template> |
| 70 </template> | 67 </template> |
| 71 <script> | 68 <script> |
| 72 Polymer({ | 69 Polymer({ |
| 73 detailed: false, | 70 is: 'ct-commit-list', |
| 74 suspectedCommitsByRepo_: {}, | 71 properties: { |
| 75 totalSuspectedCommits_: 0, | 72 commitList: { |
| 76 representiveBuildUrl_: null, | 73 notify: true, |
| 77 | 74 observer: '_updateSuspectedCommitInfo' |
| 78 observe: { | 75 }, |
| 79 commitList: '_updateSuspectedCommitInfo', | 76 detailed: { |
| 80 suspectedCLsByRepo: '_updateSuspectedCommitInfo', | 77 type: Boolean, |
| 81 }, | 78 value: false, |
| 82 | 79 notify: true |
| 83 _toggle: function(event, detail, sender, target) { | 80 }, |
| 84 var repo = sender.getAttribute('repository'); | 81 flex: { notify: true }, |
| 85 var r = this.commitList.repositories.find(function(item) { | 82 representiveBuildUrl_: { value: null }, |
| 86 return item.name === repo; | 83 suspectedCLsByRepo: { |
| 87 }); | 84 notify: true, |
| 88 r.expanded = !r.expanded; | 85 observer: '_updateSuspectedCommitInfo' |
| 89 | 86 }, |
| 90 var anyExpanded = this.commitList.repositories.some(function(item) { | 87 suspectedCommitsByRepo_: { |
| 91 return item.expanded; | 88 type: Object, |
| 92 }); | 89 value: function () { |
| 93 | 90 return {}; |
| 94 if (anyExpanded) { | 91 } |
| 95 this.setAttribute('flex', r.expanded); | 92 }, |
| 96 } else { | 93 totalSuspectedCommits_: { |
| 97 this.removeAttribute('flex'); | 94 type: Number, |
| 95 value: 0 |
| 96 } |
| 97 }, |
| 98 _toggle: function (event, detail, sender, target) { |
| 99 var repo = sender.getAttribute('repository'); |
| 100 var r = this.commitList.repositories.find(function (item) { |
| 101 return item.name === repo; |
| 102 }); |
| 103 r.expanded = !r.expanded; |
| 104 var anyExpanded = this.commitList.repositories.some(function (item) { |
| 105 return item.expanded; |
| 106 }); |
| 107 if (anyExpanded) { |
| 108 this.setAttribute('flex', r.expanded); |
| 109 } else { |
| 110 this.removeAttribute('flex'); |
| 111 } |
| 112 }, |
| 113 _updateSuspectedCommitInfo: function () { |
| 114 this.suspectedCommitsByRepo_ = {}; |
| 115 this.totalSuspectedCommits_ = 0; |
| 116 this.representiveBuildUrl_ = null; |
| 117 if (Object.isEmpty(this.suspectedCLsByRepo)) |
| 118 return; |
| 119 var builds = {}; |
| 120 this.commitList.repositories.forEach(function (repository) { |
| 121 if (!this.suspectedCLsByRepo[repository.name]) |
| 122 return; |
| 123 if (!this.suspectedCommitsByRepo_[repository.name]) |
| 124 this.suspectedCommitsByRepo_[repository.name] = {}; |
| 125 repository.commits.forEach(function (commit) { |
| 126 var suspectedCL = null; |
| 127 // If a suspected CL is not in the regression range, don't show it o
n UI. |
| 128 this.suspectedCLsByRepo[repository.name].some(function (cl) { |
| 129 // In builder_alerts and sheriff-o-matic, git commit position is r
eferred as revision. |
| 130 if (cl.commitPosition == commit.revision) { |
| 131 suspectedCL = cl; |
| 132 return true; |
| 133 } |
| 134 return false; |
| 135 }); |
| 136 if (suspectedCL) { |
| 137 this.suspectedCommitsByRepo_[repository.name][commit.revision] = s
uspectedCL; |
| 138 suspectedCL.builds.forEach(function (buildUrl) { |
| 139 if (!builds[buildUrl]) |
| 140 builds[buildUrl] = 0; |
| 141 builds[buildUrl] += 1; |
| 142 }); |
| 143 this.totalSuspectedCommits_ += 1; |
| 144 } |
| 145 }.bind(this)); |
| 146 }.bind(this)); |
| 147 // Use a build out of the same step failure group as a representative on
e to link back to Findit. |
| 148 // It could be the one that has the most failures tagged with some suspe
cted CLs. |
| 149 if (!Object.isEmpty(builds)) { |
| 150 var maxCount = 0; |
| 151 Object.keys(builds, function (buildUrl, count) { |
| 152 if (count > maxCount) { |
| 153 this.representiveBuildUrl_ = buildUrl; |
| 154 maxCount = count; |
| 155 } |
| 156 }.bind(this)); |
| 157 } |
| 158 }, |
| 159 _isSuspected: function (revision, repoName) { |
| 160 return this.suspectedCommitsByRepo_[repoName] && this.suspectedCommitsBy
Repo_[repoName][revision] !== undefined; |
| 161 }, |
| 162 _numberOfSuspectedCL: function (repoName) { |
| 163 return Object.size(this.suspectedCommitsByRepo_[repoName]); |
| 164 }, |
| 165 computeIf: function (totalSuspectedCommits_) { |
| 166 return totalSuspectedCommits_ > 0; |
| 167 }, |
| 168 computeHref: function (representiveBuildUrl_) { |
| 169 return 'https://findit-for-me.appspot.com/build-failure?url=' + represen
tiveBuildUrl_; |
| 170 }, |
| 171 computeIf2: function (repository) { |
| 172 return repository.name == 'chromium'; |
| 173 }, |
| 174 computeIf3: function (repository) { |
| 175 return repository.name == 'blink'; |
| 176 }, |
| 177 computeIf4: function (repository) { |
| 178 return repository.name != 'blink' && repository.name != 'chromium'; |
| 179 }, |
| 180 computeIf5: function (repository, suspectedCommitsByRepo_) { |
| 181 return suspectedCommitsByRepo_[repository.name] && this._numberOfSuspect
edCL(repository.name) > 0; |
| 182 }, |
| 183 computeHref2: function (repository) { |
| 184 return 'http://test-results.appspot.com/revision_range?start=' + reposit
ory.firstRevision + '&end=' + repository.lastRevision; |
| 185 }, |
| 186 computeHref3: function (repository) { |
| 187 return 'http://build.chromium.org/f/chromium/perf/dashboard/ui/changelog
_blink.html?url=/trunk&range=' + repository.firstRevision + ':' + repository.las
tRevision + '&mode=html'; |
| 188 }, |
| 189 computeClass: function (commit_index) { |
| 190 return commit_index == 0 ? 'first' : 'notfirst'; |
| 98 } | 191 } |
| 99 }, | 192 }); |
| 100 | |
| 101 _updateSuspectedCommitInfo: function() { | |
| 102 this.suspectedCommitsByRepo_ = {}; | |
| 103 this.totalSuspectedCommits_ = 0; | |
| 104 this.representiveBuildUrl_ = null; | |
| 105 | |
| 106 if (Object.isEmpty(this.suspectedCLsByRepo)) | |
| 107 return; | |
| 108 | |
| 109 var builds = {}; | |
| 110 | |
| 111 this.commitList.repositories.forEach(function(repository) { | |
| 112 if (!this.suspectedCLsByRepo[repository.name]) | |
| 113 return; | |
| 114 | |
| 115 if (!this.suspectedCommitsByRepo_[repository.name]) | |
| 116 this.suspectedCommitsByRepo_[repository.name] = {}; | |
| 117 | |
| 118 repository.commits.forEach(function(commit) { | |
| 119 var suspectedCL = null; | |
| 120 | |
| 121 // If a suspected CL is not in the regression range, don't show it on
UI. | |
| 122 this.suspectedCLsByRepo[repository.name].some(function(cl) { | |
| 123 // In builder_alerts and sheriff-o-matic, git commit position is ref
erred as revision. | |
| 124 if (cl.commitPosition == commit.revision) { | |
| 125 suspectedCL = cl; | |
| 126 return true; | |
| 127 } | |
| 128 return false; | |
| 129 }); | |
| 130 | |
| 131 if (suspectedCL) { | |
| 132 this.suspectedCommitsByRepo_[repository.name][commit.revision] = sus
pectedCL; | |
| 133 suspectedCL.builds.forEach(function(buildUrl) { | |
| 134 if (!builds[buildUrl]) | |
| 135 builds[buildUrl] = 0; | |
| 136 builds[buildUrl] += 1; | |
| 137 }); | |
| 138 this.totalSuspectedCommits_ += 1; | |
| 139 } | |
| 140 }.bind(this)); | |
| 141 }.bind(this)); | |
| 142 | |
| 143 // Use a build out of the same step failure group as a representative one
to link back to Findit. | |
| 144 // It could be the one that has the most failures tagged with some suspect
ed CLs. | |
| 145 if (!Object.isEmpty(builds)) { | |
| 146 var maxCount = 0; | |
| 147 Object.keys(builds, function(buildUrl, count) { | |
| 148 if (count > maxCount) { | |
| 149 this.representiveBuildUrl_ = buildUrl; | |
| 150 maxCount = count; | |
| 151 } | |
| 152 }.bind(this)); | |
| 153 } | |
| 154 }, | |
| 155 | |
| 156 _isSuspected: function(revision, repoName) { | |
| 157 return this.suspectedCommitsByRepo_[repoName] && this.suspectedCommitsByRe
po_[repoName][revision] !== undefined; | |
| 158 }, | |
| 159 | |
| 160 _numberOfSuspectedCL: function(repoName) { | |
| 161 return Object.size(this.suspectedCommitsByRepo_[repoName]); | |
| 162 }, | |
| 163 }); | |
| 164 </script> | 193 </script> |
| 165 </polymer-element> | 194 </dom-module> |
| OLD | NEW |