Merge changes Iac62434c,Ia779e7d5
* changes: Don't display diff size or file status for commit message Don't bold outgoing reviews in the dashboard
This commit is contained in:
@@ -126,6 +126,7 @@ limitations under the License.
|
|||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="{{_showDashboardView}}" restamp="true">
|
<template is="dom-if" if="{{_showDashboardView}}" restamp="true">
|
||||||
<gr-dashboard-view
|
<gr-dashboard-view
|
||||||
|
account="[[account]]"
|
||||||
params="[[params]]"
|
params="[[params]]"
|
||||||
view-state="{{_viewState.dashboardView}}"></gr-dashboard-view>
|
view-state="{{_viewState.dashboardView}}"></gr-dashboard-view>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -31,7 +31,7 @@ limitations under the License.
|
|||||||
:host([selected]) {
|
:host([selected]) {
|
||||||
background-color: #ebf5fb;
|
background-color: #ebf5fb;
|
||||||
}
|
}
|
||||||
:host([unreviewed]) {
|
:host([needs-review]) {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.cell {
|
.cell {
|
||||||
@@ -98,7 +98,7 @@ limitations under the License.
|
|||||||
value: false,
|
value: false,
|
||||||
reflectToAttribute: true,
|
reflectToAttribute: true,
|
||||||
},
|
},
|
||||||
unreviewed: {
|
needsReview: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
reflectToAttribute: true,
|
reflectToAttribute: true,
|
||||||
|
@@ -55,7 +55,7 @@ limitations under the License.
|
|||||||
<template is="dom-repeat" items="[[changeGroup]]" as="change">
|
<template is="dom-repeat" items="[[changeGroup]]" as="change">
|
||||||
<gr-change-list-item
|
<gr-change-list-item
|
||||||
selected$="[[_computeItemSelected(index, groupIndex, selectedIndex)]]"
|
selected$="[[_computeItemSelected(index, groupIndex, selectedIndex)]]"
|
||||||
unreviewed="[[_computeItemUnreviewed(change, showReviewedState)]]"
|
needs-review="[[_computeItemNeedsReview(account, change, showReviewedState)]]"
|
||||||
change="[[change]]"
|
change="[[change]]"
|
||||||
show-star="[[showStar]]"
|
show-star="[[showStar]]"
|
||||||
label-names="[[labelNames]]"></gr-change-list-item>
|
label-names="[[labelNames]]"></gr-change-list-item>
|
||||||
@@ -75,6 +75,14 @@ limitations under the License.
|
|||||||
},
|
},
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
|
/**
|
||||||
|
* The logged-in user's account, or an empty object if no user is logged
|
||||||
|
* in.
|
||||||
|
*/
|
||||||
|
account: {
|
||||||
|
type: Object,
|
||||||
|
value: function() { return {}; },
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* An array of ChangeInfo objects to render.
|
* An array of ChangeInfo objects to render.
|
||||||
* https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info
|
* https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info
|
||||||
@@ -162,9 +170,10 @@ limitations under the License.
|
|||||||
return idx == selectedIndex;
|
return idx == selectedIndex;
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeItemUnreviewed: function(change, showReviewedState) {
|
_computeItemNeedsReview: function(account, change, showReviewedState) {
|
||||||
return showReviewedState && !change.reviewed &&
|
return showReviewedState && !change.reviewed &&
|
||||||
change.status != this.ChangeStatus.MERGED;
|
change.status != this.ChangeStatus.MERGED &&
|
||||||
|
account._account_id != change.owner._account_id;
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleKey: function(e) {
|
_handleKey: function(e) {
|
||||||
|
@@ -54,6 +54,7 @@ limitations under the License.
|
|||||||
<gr-change-list
|
<gr-change-list
|
||||||
show-star
|
show-star
|
||||||
show-reviewed-state
|
show-reviewed-state
|
||||||
|
account="[[account]]"
|
||||||
selected-index="{{viewState.selectedChangeIndex}}"
|
selected-index="{{viewState.selectedChangeIndex}}"
|
||||||
groups="{{_results}}"
|
groups="{{_results}}"
|
||||||
group-titles="[[_groupTitles]]"></gr-change-list>
|
group-titles="[[_groupTitles]]"></gr-change-list>
|
||||||
@@ -73,6 +74,10 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
|
account: {
|
||||||
|
type: Object,
|
||||||
|
value: function() { return {}; },
|
||||||
|
},
|
||||||
viewState: Object,
|
viewState: Object,
|
||||||
|
|
||||||
_results: Array,
|
_results: Array,
|
||||||
|
@@ -132,7 +132,7 @@ limitations under the License.
|
|||||||
hidden$="[[!_loggedIn]]" hidden>
|
hidden$="[[!_loggedIn]]" hidden>
|
||||||
<div class="jumpToFileContainer">
|
<div class="jumpToFileContainer">
|
||||||
<gr-button link class="dropdown-trigger" id="trigger" on-tap="_showDropdownTapHandler">
|
<gr-button link class="dropdown-trigger" id="trigger" on-tap="_showDropdownTapHandler">
|
||||||
<span>[[_path]]</span>
|
<span>[[_computeFileDisplayName(_path)]]</span>
|
||||||
<span class="downArrow">▼</span>
|
<span class="downArrow">▼</span>
|
||||||
</gr-button>
|
</gr-button>
|
||||||
<iron-dropdown id="dropdown" vertical-align="top" vertical-offset="25">
|
<iron-dropdown id="dropdown" vertical-align="top" vertical-offset="25">
|
||||||
@@ -141,7 +141,9 @@ limitations under the License.
|
|||||||
<a href$="[[_computeDiffURL(_changeNum, _patchRange, path)]]"
|
<a href$="[[_computeDiffURL(_changeNum, _patchRange, path)]]"
|
||||||
selected$="[[_computeFileSelected(path, _path)]]"
|
selected$="[[_computeFileSelected(path, _path)]]"
|
||||||
data-key-nav$="[[_computeKeyNav(path, _path, _fileList)]]"
|
data-key-nav$="[[_computeKeyNav(path, _path, _fileList)]]"
|
||||||
on-tap="_handleFileTap">[[path]]</a>
|
on-tap="_handleFileTap">
|
||||||
|
[[_computeFileDisplayName(path)]]
|
||||||
|
</a>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</iron-dropdown>
|
</iron-dropdown>
|
||||||
@@ -152,7 +154,7 @@ limitations under the License.
|
|||||||
<option
|
<option
|
||||||
value$="[[path]]"
|
value$="[[path]]"
|
||||||
selected$="[[_computeFileSelected(path, _path)]]">
|
selected$="[[_computeFileSelected(path, _path)]]">
|
||||||
[[path]]
|
[[_computeFileDisplayName(path)]]
|
||||||
</option>
|
</option>
|
||||||
</template>
|
</template>
|
||||||
</select>
|
</select>
|
||||||
@@ -172,6 +174,8 @@ limitations under the License.
|
|||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var COMMIT_MESSAGE_PATH = '/COMMIT_MSG';
|
||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
is: 'gr-diff-view',
|
is: 'gr-diff-view',
|
||||||
|
|
||||||
@@ -238,7 +242,8 @@ limitations under the License.
|
|||||||
|
|
||||||
attached: function() {
|
attached: function() {
|
||||||
if (this._path) {
|
if (this._path) {
|
||||||
this.fire('title-change', {title: this._path});
|
this.fire('title-change',
|
||||||
|
{title: this._computeFileDisplayName(this._path)});
|
||||||
}
|
}
|
||||||
window.addEventListener('resize', this._boundWindowResizeHandler);
|
window.addEventListener('resize', this._boundWindowResizeHandler);
|
||||||
},
|
},
|
||||||
@@ -343,7 +348,8 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
this._path = value.path;
|
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
|
// 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
|
// patch number is no longer a part of the URL (say when navigating to
|
||||||
@@ -402,6 +408,10 @@ limitations under the License.
|
|||||||
return base;
|
return base;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_computeFileDisplayName: function(path) {
|
||||||
|
return path == COMMIT_MESSAGE_PATH ? 'Commit message' : path;
|
||||||
|
},
|
||||||
|
|
||||||
_computeChangeDetailPath: function(changeNum) {
|
_computeChangeDetailPath: function(changeNum) {
|
||||||
return '/changes/' + changeNum + '/detail';
|
return '/changes/' + changeNum + '/detail';
|
||||||
},
|
},
|
||||||
|
@@ -76,6 +76,9 @@ limitations under the License.
|
|||||||
.stats {
|
.stats {
|
||||||
min-width: 7em;
|
min-width: 7em;
|
||||||
}
|
}
|
||||||
|
.invisible {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
.row:not(.header) .stats {
|
.row:not(.header) .stats {
|
||||||
font-family: var(--monospace-font-family);
|
font-family: var(--monospace-font-family);
|
||||||
}
|
}
|
||||||
@@ -135,15 +138,17 @@ limitations under the License.
|
|||||||
<input type="checkbox" checked$="[[_computeReviewed(file, _reviewed)]]"
|
<input type="checkbox" checked$="[[_computeReviewed(file, _reviewed)]]"
|
||||||
data-path$="[[file.__path]]" on-change="_handleReviewedChange">
|
data-path$="[[file.__path]]" on-change="_handleReviewedChange">
|
||||||
</div>
|
</div>
|
||||||
<div class="status">[[file.status]]</div>
|
<div class$="[[_computeClass('status', file.__path)]]">
|
||||||
|
[[_computeFileStatus(file.status)]]
|
||||||
|
</div>
|
||||||
<a class="path" href$="[[_computeDiffURL(changeNum, patchNum, file.__path)]]">
|
<a class="path" href$="[[_computeDiffURL(changeNum, patchNum, file.__path)]]">
|
||||||
[[file.__path]]
|
[[_computeFileDisplayName(file.__path)]]
|
||||||
</a>
|
</a>
|
||||||
<div class="comments">
|
<div class="comments">
|
||||||
<span class="drafts">[[_computeDraftsString(_drafts, file.__path)]]</span>
|
<span class="drafts">[[_computeDraftsString(_drafts, file.__path)]]</span>
|
||||||
[[_computeCommentsString(comments, patchNum, file.__path)]]
|
[[_computeCommentsString(comments, patchNum, file.__path)]]
|
||||||
</div>
|
</div>
|
||||||
<div class="stats">
|
<div class$="[[_computeClass('stats', file.__path)]]">
|
||||||
<span class="added">+[[file.lines_inserted]]</span>
|
<span class="added">+[[file.lines_inserted]]</span>
|
||||||
<span class="removed">-[[file.lines_deleted]]</span>
|
<span class="removed">-[[file.lines_deleted]]</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,6 +159,8 @@ limitations under the License.
|
|||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var COMMIT_MESSAGE_PATH = '/COMMIT_MSG';
|
||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
is: 'gr-file-list',
|
is: 'gr-file-list',
|
||||||
|
|
||||||
@@ -311,10 +318,26 @@ limitations under the License.
|
|||||||
return index == selectedIndex;
|
return index == selectedIndex;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_computeFileStatus: function(status) {
|
||||||
|
return status || 'M';
|
||||||
|
},
|
||||||
|
|
||||||
_computeDiffURL: function(changeNum, patchNum, path) {
|
_computeDiffURL: function(changeNum, patchNum, path) {
|
||||||
return '/c/' + 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) {
|
_send: function(method, url) {
|
||||||
var xhr = document.createElement('gr-request');
|
var xhr = document.createElement('gr-request');
|
||||||
this._xhrPromise = xhr.send({
|
this._xhrPromise = xhr.send({
|
||||||
|
@@ -105,35 +105,52 @@ limitations under the License.
|
|||||||
}, 1);
|
}, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('unreviewed changes', function() {
|
test('changes needing review', function() {
|
||||||
element.changes = [
|
element.changes = [
|
||||||
{
|
{
|
||||||
_number: 0,
|
_number: 0,
|
||||||
reviewed: true,
|
reviewed: true,
|
||||||
|
owner: { _account_id: 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_number: 1,
|
_number: 1,
|
||||||
|
owner: { _account_id: 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_number: 2,
|
_number: 2,
|
||||||
status: 'MERGED',
|
status: 'MERGED',
|
||||||
|
owner: { _account_id: 0 },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
_number: 3,
|
||||||
|
owner: { _account_id: 42 },
|
||||||
|
}
|
||||||
];
|
];
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
var elementItems = Polymer.dom(element.root).querySelectorAll(
|
var elementItems = Polymer.dom(element.root).querySelectorAll(
|
||||||
'gr-change-list-item');
|
'gr-change-list-item');
|
||||||
assert.equal(elementItems.length, 3);
|
assert.equal(elementItems.length, 4);
|
||||||
for (var i = 0; i < elementItems.length; i++) {
|
for (var i = 0; i < elementItems.length; i++) {
|
||||||
assert.isFalse(elementItems[i].hasAttribute('unreviewed'));
|
assert.isFalse(elementItems[i].hasAttribute('needs-review'));
|
||||||
}
|
}
|
||||||
|
|
||||||
element.showReviewedState = true;
|
element.showReviewedState = true;
|
||||||
var elementItems = Polymer.dom(element.root).querySelectorAll(
|
var elementItems = Polymer.dom(element.root).querySelectorAll(
|
||||||
'gr-change-list-item');
|
'gr-change-list-item');
|
||||||
assert.equal(elementItems.length, 3);
|
assert.equal(elementItems.length, 4);
|
||||||
assert.isFalse(elementItems[0].hasAttribute('unreviewed'));
|
assert.isFalse(elementItems[0].hasAttribute('needs-review'));
|
||||||
assert.isTrue(elementItems[1].hasAttribute('unreviewed'));
|
assert.isTrue(elementItems[1].hasAttribute('needs-review'));
|
||||||
assert.isFalse(elementItems[2].hasAttribute('unreviewed'));
|
assert.isFalse(elementItems[2].hasAttribute('needs-review'));
|
||||||
|
assert.isTrue(elementItems[3].hasAttribute('needs-review'));
|
||||||
|
|
||||||
|
element.account = { _account_id: 42 };
|
||||||
|
var elementItems = Polymer.dom(element.root).querySelectorAll(
|
||||||
|
'gr-change-list-item');
|
||||||
|
assert.equal(elementItems.length, 4);
|
||||||
|
assert.isFalse(elementItems[0].hasAttribute('needs-review'));
|
||||||
|
assert.isTrue(elementItems[1].hasAttribute('needs-review'));
|
||||||
|
assert.isFalse(elementItems[2].hasAttribute('needs-review'));
|
||||||
|
assert.isFalse(elementItems[3].hasAttribute('needs-review'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('no changes', function() {
|
test('no changes', function() {
|
||||||
|
@@ -321,6 +321,11 @@ limitations under the License.
|
|||||||
assert.equal(linkEls[0].getAttribute('href'), '/c/42/10/chell.go');
|
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[1].getAttribute('href'), '/c/42/10/glados.txt');
|
||||||
assert.equal(linkEls[2].getAttribute('href'), '/c/42/10/wheatley.md');
|
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() {
|
test('jump to file dropdown with patch range', function() {
|
||||||
|
@@ -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) {
|
test('file review status', function(done) {
|
||||||
element.changeNum = '42';
|
element.changeNum = '42';
|
||||||
element.patchNum = '2';
|
element.patchNum = '2';
|
||||||
|
Reference in New Issue
Block a user