| <!-- The <perf-commit-sk> custom element declaration. |
| |
| Displays a single commit in a uniform manner. |
| |
| Attributes: |
| cid - The commit id, either the Git commit hash or trybot patch. |
| source - The Git branch or trybot issue id. |
| commit - The serialized perftracedb.CommitIDLong that corresponds to the given commit id and source. |
| |
| Events: |
| None. |
| |
| Methods: |
| asString - Returns a text description of the commit. |
| |
| Mailbox: |
| commits - Listens on the sk.Mailbox name of 'commits' to listen for the |
| data to populate the element. The mailbox data needs to be a serialized |
| slice of []*types.Commit. |
| |
| [ |
| { |
| ts: 14070203, |
| id: "123abc", |
| source: "master", |
| author: "name@example.org", |
| desc: "Adds short commits." |
| }, |
| ] |
| |
| --> |
| |
| <dom-module id="perf-commit-sk"> |
| <style type="text/css" media="screen"> |
| pre, |
| span { |
| margin: 0; |
| } |
| |
| a { |
| color: #FF7F00; |
| font-weight: bold; |
| } |
| </style> |
| <template> |
| <pre><span>[[_trimPad(commit.author)]]</span> <span>[[_humanize(commit.ts)]]</span> <span><a href$="[[_commitHref(commit)]]">[[_name(commit.id, commit.source)]]</a></span> <span>[[_trimNewline(commit.desc)]]</span></pre> |
| </template> |
| </dom-module> |
| |
| <script> |
| Polymer({ |
| is: "perf-commit-sk", |
| |
| properties: { |
| commit: { |
| type: Object, |
| value: null, |
| } |
| }, |
| |
| asString: function() { |
| if (!this.commit) { |
| return "Commit not found."; |
| } |
| return this._trimPad(this.commit.author) + " " + |
| this._humanize(this.commit.ts) + " " + |
| this.commit.id + " " + |
| this.commit.source + " " + |
| this._trimNewline(this.commit.desc); |
| }, |
| |
| _trimPad: function(s) { |
| if (!this.commit) { |
| return "Unknown commit." |
| } |
| s = s.slice(0, 30); |
| while (s.length < 30) { |
| s = s + " "; |
| } |
| return s; |
| }, |
| |
| _trimNewline: function(s) { |
| if (!s) { |
| return ""; |
| } |
| return this._trimPad(s.split("\n")[0]); |
| }, |
| |
| _humanize: function (s) { |
| if (!this.commit) { |
| return ""; |
| } |
| return sk.human.diffDate(s * 1000); |
| }, |
| |
| _commitHref: function (c) { |
| if (!c) { |
| return ""; |
| } |
| if (c.source.indexOf("https://codereview.chromium.org") == -1) { |
| return 'https://skia.googlesource.com/skia/+/' + c.id; |
| } else { |
| return c.source; |
| } |
| }, |
| |
| _trunc: function (s) { |
| if (!this.commit) { |
| return ""; |
| } |
| return s.slice(0, 7); |
| }, |
| |
| _name: function (id, source) { |
| if (!this.commit) { |
| return ""; |
| } |
| if (source.indexOf("https://codereview.chromium.org") == -1) { |
| return this._trunc(id) + " (" + source + ")"; |
| } else { |
| return source + " Patch: " + this._trunc(id); |
| } |
| }, |
| }); |
| </script> |