diff --git a/polygerrit-ui/app/elements/gr-diff-view.html b/polygerrit-ui/app/elements/gr-diff-view.html index 9d15045818..761dd7158d 100644 --- a/polygerrit-ui/app/elements/gr-diff-view.html +++ b/polygerrit-ui/app/elements/gr-diff-view.html @@ -132,7 +132,7 @@ limitations under the License. hidden$="[[!_loggedIn]]" hidden>
- [[_path]] + [[_computeFileDisplayName(_path)]] @@ -141,7 +141,9 @@ limitations under the License. [[path]] + on-tap="_handleFileTap"> + [[_computeFileDisplayName(path)]] +
@@ -152,7 +154,7 @@ limitations under the License. @@ -172,6 +174,8 @@ limitations under the License. (function() { 'use strict'; + var COMMIT_MESSAGE_PATH = '/COMMIT_MSG'; + Polymer({ is: 'gr-diff-view', @@ -238,7 +242,8 @@ limitations under the License. attached: function() { if (this._path) { - this.fire('title-change', {title: this._path}); + this.fire('title-change', + {title: this._computeFileDisplayName(this._path)}); } window.addEventListener('resize', this._boundWindowResizeHandler); }, @@ -343,7 +348,8 @@ limitations under the License. }; this._path = value.path; - this.fire('title-change', {title: this._path}); + this.fire('title-change', + {title: this._computeFileDisplayName(this._path)}); // When navigating away from the page, there is a possibility that the // patch number is no longer a part of the URL (say when navigating to @@ -402,6 +408,10 @@ limitations under the License. return base; }, + _computeFileDisplayName: function(path) { + return path == COMMIT_MESSAGE_PATH ? 'Commit message' : path; + }, + _computeChangeDetailPath: function(changeNum) { return '/changes/' + changeNum + '/detail'; }, diff --git a/polygerrit-ui/app/elements/gr-file-list.html b/polygerrit-ui/app/elements/gr-file-list.html index 6f51003d3e..bcf3e05103 100644 --- a/polygerrit-ui/app/elements/gr-file-list.html +++ b/polygerrit-ui/app/elements/gr-file-list.html @@ -76,6 +76,9 @@ limitations under the License. .stats { min-width: 7em; } + .invisible { + visibility: hidden; + } .row:not(.header) .stats { font-family: var(--monospace-font-family); } @@ -135,15 +138,17 @@ limitations under the License. -
[[file.status]]
+
+ [[_computeFileStatus(file.status)]] +
- [[file.__path]] + [[_computeFileDisplayName(file.__path)]]
[[_computeDraftsString(_drafts, file.__path)]] [[_computeCommentsString(comments, patchNum, file.__path)]]
-
+
+[[file.lines_inserted]] -[[file.lines_deleted]]
@@ -154,6 +159,8 @@ limitations under the License. (function() { 'use strict'; + var COMMIT_MESSAGE_PATH = '/COMMIT_MSG'; + Polymer({ is: 'gr-file-list', @@ -311,10 +318,26 @@ limitations under the License. return index == selectedIndex; }, + _computeFileStatus: function(status) { + return status || 'M'; + }, + _computeDiffURL: function(changeNum, patchNum, path) { return '/c/' + changeNum + '/' + patchNum + '/' + path; }, + _computeFileDisplayName: function(path) { + return path == COMMIT_MESSAGE_PATH ? 'Commit message' : path; + }, + + _computeClass: function(baseClass, path) { + var classes = [baseClass]; + if (path == COMMIT_MESSAGE_PATH) { + classes.push('invisible'); + } + return classes.join(' '); + }, + _send: function(method, url) { var xhr = document.createElement('gr-request'); this._xhrPromise = xhr.send({ diff --git a/polygerrit-ui/app/test/gr-diff-view-test.html b/polygerrit-ui/app/test/gr-diff-view-test.html index aec35c2791..da3626cddf 100644 --- a/polygerrit-ui/app/test/gr-diff-view-test.html +++ b/polygerrit-ui/app/test/gr-diff-view-test.html @@ -321,6 +321,11 @@ limitations under the License. assert.equal(linkEls[0].getAttribute('href'), '/c/42/10/chell.go'); assert.equal(linkEls[1].getAttribute('href'), '/c/42/10/glados.txt'); assert.equal(linkEls[2].getAttribute('href'), '/c/42/10/wheatley.md'); + + assert.equal(element._computeFileDisplayName('/foo/bar/baz'), + '/foo/bar/baz'); + assert.equal(element._computeFileDisplayName('/COMMIT_MSG'), + 'Commit message'); }); test('jump to file dropdown with patch range', function() { diff --git a/polygerrit-ui/app/test/gr-file-list-test.html b/polygerrit-ui/app/test/gr-file-list-test.html index e0b6458bfd..aabca509c3 100644 --- a/polygerrit-ui/app/test/gr-file-list-test.html +++ b/polygerrit-ui/app/test/gr-file-list-test.html @@ -260,6 +260,21 @@ limitations under the License. ''); }); + test('computed properties', function() { + assert.equal(element._computeFileStatus('A'), 'A'); + assert.equal(element._computeFileStatus(undefined), 'M'); + assert.equal(element._computeFileStatus(null), 'M'); + + assert.equal(element._computeFileDisplayName('/foo/bar/baz'), + '/foo/bar/baz'); + assert.equal(element._computeFileDisplayName('/COMMIT_MSG'), + 'Commit message'); + + assert.equal(element._computeClass('clazz', '/foo/bar/baz'), 'clazz'); + assert.equal(element._computeClass('clazz', '/COMMIT_MSG'), + 'clazz invisible'); + }); + test('file review status', function(done) { element.changeNum = '42'; element.patchNum = '2';