Revert "Revert "Show author and committer when relevant""
This reverts commit 4ed22af4fd.
Reason for revert: Acceptable intermediate solution for Issue 7919 while
awaiting resolution of Issue 10026.
Change-Id: I746dd11219652aa7348e1ba2dbbab0c0445cb66d
This commit is contained in:
@@ -139,11 +139,28 @@ limitations under the License.
|
|||||||
<gr-account-link account="[[change.owner]]"></gr-account-link>
|
<gr-account-link account="[[change.owner]]"></gr-account-link>
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
<section class$="[[_computeShowUploaderHide(change)]]">
|
<section class$="[[_computeShowRoleClass(change, _CHANGE_ROLE.UPLOADER)]]">
|
||||||
<span class="title">Uploader</span>
|
<span class="title">Uploader</span>
|
||||||
<span class="value">
|
<span class="value">
|
||||||
<gr-account-link
|
<gr-account-link
|
||||||
account="[[_computeShowUploader(change)]]"></gr-account-link>
|
account="[[_getNonOwnerRole(change, _CHANGE_ROLE.UPLOADER)]]"
|
||||||
|
></gr-account-link>
|
||||||
|
</span>
|
||||||
|
</section>
|
||||||
|
<section class$="[[_computeShowRoleClass(change, _CHANGE_ROLE.AUTHOR)]]">
|
||||||
|
<span class="title">Author</span>
|
||||||
|
<span class="value">
|
||||||
|
<gr-account-link
|
||||||
|
account="[[_getNonOwnerRole(change, _CHANGE_ROLE.AUTHOR)]]"
|
||||||
|
></gr-account-link>
|
||||||
|
</span>
|
||||||
|
</section>
|
||||||
|
<section class$="[[_computeShowRoleClass(change, _CHANGE_ROLE.COMMITTER)]]">
|
||||||
|
<span class="title">Committer</span>
|
||||||
|
<span class="value">
|
||||||
|
<gr-account-link
|
||||||
|
account="[[_getNonOwnerRole(change, _CHANGE_ROLE.COMMITTER)]]"
|
||||||
|
></gr-account-link>
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
<section class="assignee">
|
<section class="assignee">
|
||||||
|
|||||||
@@ -97,6 +97,18 @@
|
|||||||
type: Array,
|
type: Array,
|
||||||
computed: '_computeParents(change)',
|
computed: '_computeParents(change)',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** @type {?} */
|
||||||
|
_CHANGE_ROLE: {
|
||||||
|
type: Object,
|
||||||
|
readOnly: true,
|
||||||
|
value: {
|
||||||
|
OWNER: 'owner',
|
||||||
|
UPLOADER: 'uploader',
|
||||||
|
AUTHOR: 'author',
|
||||||
|
COMMITTER: 'committer',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
behaviors: [
|
behaviors: [
|
||||||
@@ -299,24 +311,45 @@
|
|||||||
return !!change.work_in_progress;
|
return !!change.work_in_progress;
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeShowUploaderHide(change) {
|
_computeShowRoleClass(change, role) {
|
||||||
return this._computeShowUploader(change) ? '' : 'hideDisplay';
|
return this._getNonOwnerRole(change, role) ? '' : 'hideDisplay';
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeShowUploader(change) {
|
/**
|
||||||
|
* Get the user with the specified role on the change. Returns null if the
|
||||||
|
* user with that role is the same as the owner.
|
||||||
|
* @param {!Object} change
|
||||||
|
* @param {string} role One of the values from _CHANGE_ROLE
|
||||||
|
* @return {Object|null} either an accound or null.
|
||||||
|
*/
|
||||||
|
_getNonOwnerRole(change, role) {
|
||||||
if (!change.current_revision ||
|
if (!change.current_revision ||
|
||||||
!change.revisions[change.current_revision]) {
|
!change.revisions[change.current_revision]) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rev = change.revisions[change.current_revision];
|
const rev = change.revisions[change.current_revision];
|
||||||
|
if (!rev) { return null; }
|
||||||
|
|
||||||
if (!rev || !rev.uploader ||
|
if (role === this._CHANGE_ROLE.UPLOADER &&
|
||||||
change.owner._account_id === rev.uploader._account_id) {
|
rev.uploader &&
|
||||||
return null;
|
change.owner._account_id !== rev.uploader._account_id) {
|
||||||
|
return rev.uploader;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rev.uploader;
|
if (role === this._CHANGE_ROLE.AUTHOR &&
|
||||||
|
rev.commit && rev.commit.author &&
|
||||||
|
change.owner.email !== rev.commit.author.email) {
|
||||||
|
return rev.commit.author;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (role === this._CHANGE_ROLE.COMMITTER &&
|
||||||
|
rev.commit && rev.commit.committer &&
|
||||||
|
change.owner.email !== rev.commit.committer.email) {
|
||||||
|
return rev.commit.committer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeParents(change) {
|
_computeParents(change) {
|
||||||
|
|||||||
@@ -185,115 +185,130 @@ limitations under the License.
|
|||||||
assert.equal(element._computeWebLinks(element.commitInfo).length, 1);
|
assert.equal(element._computeWebLinks(element.commitInfo).length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_computeShowUploader test for uploader', () => {
|
suite('_getNonOwnerRole', () => {
|
||||||
const change = {
|
let change;
|
||||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
|
||||||
owner: {
|
|
||||||
_account_id: 1019328,
|
|
||||||
},
|
|
||||||
revisions: {
|
|
||||||
rev1: {
|
|
||||||
_number: 1,
|
|
||||||
uploader: {
|
|
||||||
_account_id: 1011123,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
current_revision: 'rev1',
|
|
||||||
status: 'NEW',
|
|
||||||
labels: {},
|
|
||||||
mergeable: true,
|
|
||||||
};
|
|
||||||
assert.deepEqual(element._computeShowUploader(change),
|
|
||||||
{_account_id: 1011123});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('_computeShowUploader test that it does not return uploader', () => {
|
setup(() => {
|
||||||
const change = {
|
change = {
|
||||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
owner: {
|
||||||
owner: {
|
email: 'abc@def',
|
||||||
_account_id: 1011123,
|
_account_id: 1019328,
|
||||||
},
|
},
|
||||||
revisions: {
|
revisions: {
|
||||||
rev1: {
|
rev1: {
|
||||||
_number: 1,
|
_number: 1,
|
||||||
uploader: {
|
uploader: {
|
||||||
_account_id: 1011123,
|
email: 'ghi@def',
|
||||||
|
_account_id: 1011123,
|
||||||
|
},
|
||||||
|
commit: {
|
||||||
|
author: {email: 'jkl@def'},
|
||||||
|
committer: {email: 'ghi@def'},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
current_revision: 'rev1',
|
||||||
current_revision: 'rev1',
|
};
|
||||||
status: 'NEW',
|
});
|
||||||
labels: {},
|
|
||||||
mergeable: true,
|
|
||||||
};
|
|
||||||
assert.isNotOk(element._computeShowUploader(change));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('no current_revision makes _computeShowUploader return null', () => {
|
suite('role=uploader', () => {
|
||||||
const change = {
|
test('_getNonOwnerRole for uploader', () => {
|
||||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
assert.deepEqual(
|
||||||
owner: {
|
element._getNonOwnerRole(change, element._CHANGE_ROLE.UPLOADER),
|
||||||
_account_id: 1011123,
|
{email: 'ghi@def', _account_id: 1011123});
|
||||||
},
|
});
|
||||||
revisions: {
|
|
||||||
rev1: {
|
|
||||||
_number: 1,
|
|
||||||
uploader: {
|
|
||||||
_account_id: 1011123,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
status: 'NEW',
|
|
||||||
labels: {},
|
|
||||||
mergeable: true,
|
|
||||||
};
|
|
||||||
assert.isNotOk(element._computeShowUploader(change));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('_computeShowUploaderHide test for string which equals true', () => {
|
test('_getNonOwnerRole that it does not return uploader', () => {
|
||||||
const change = {
|
// Set the uploader email to be the same as the owner.
|
||||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
change.revisions.rev1.uploader._account_id = 1019328;
|
||||||
owner: {
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
_account_id: 1019328,
|
element._CHANGE_ROLE.UPLOADER));
|
||||||
},
|
});
|
||||||
revisions: {
|
|
||||||
rev1: {
|
|
||||||
_number: 1,
|
|
||||||
uploader: {
|
|
||||||
_account_id: 1011123,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
current_revision: 'rev1',
|
|
||||||
status: 'NEW',
|
|
||||||
labels: {},
|
|
||||||
mergeable: true,
|
|
||||||
};
|
|
||||||
assert.equal(element._computeShowUploaderHide(change), '');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('_computeShowUploaderHide test for hideDisplay', () => {
|
test('_getNonOwnerRole null for uploader with no current rev', () => {
|
||||||
const change = {
|
delete change.current_revision;
|
||||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
owner: {
|
element._CHANGE_ROLE.UPLOADER));
|
||||||
_account_id: 1011123,
|
});
|
||||||
},
|
|
||||||
revisions: {
|
test('_computeShowRoleClass show uploader', () => {
|
||||||
rev1: {
|
assert.equal(element._computeShowRoleClass(
|
||||||
_number: 1,
|
change, element._CHANGE_ROLE.UPLOADER), '');
|
||||||
uploader: {
|
});
|
||||||
_account_id: 1011123,
|
|
||||||
},
|
test('_computeShowRoleClass hide uploader', () => {
|
||||||
},
|
// Set the uploader email to be the same as the owner.
|
||||||
},
|
change.revisions.rev1.uploader._account_id = 1019328;
|
||||||
current_revision: 'rev1',
|
assert.equal(element._computeShowRoleClass(change,
|
||||||
status: 'NEW',
|
element._CHANGE_ROLE.UPLOADER), 'hideDisplay');
|
||||||
labels: {},
|
});
|
||||||
mergeable: true,
|
});
|
||||||
};
|
|
||||||
assert.equal(
|
suite('role=committer', () => {
|
||||||
element._computeShowUploaderHide(change), 'hideDisplay');
|
test('_getNonOwnerRole for committer', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
element._getNonOwnerRole(change, element._CHANGE_ROLE.COMMITTER),
|
||||||
|
{email: 'ghi@def'});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole that it does not return committer', () => {
|
||||||
|
// Set the committer email to be the same as the owner.
|
||||||
|
change.revisions.rev1.commit.committer.email = 'abc@def';
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.COMMITTER));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole null for committer with no current rev', () => {
|
||||||
|
delete change.current_revision;
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.COMMITTER));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole null for committer with no commit', () => {
|
||||||
|
delete change.revisions.rev1.commit;
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.COMMITTER));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole null for committer with no committer', () => {
|
||||||
|
delete change.revisions.rev1.commit.committer;
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.COMMITTER));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
suite('role=author', () => {
|
||||||
|
test('_getNonOwnerRole for author', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
element._getNonOwnerRole(change, element._CHANGE_ROLE.AUTHOR),
|
||||||
|
{email: 'jkl@def'});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole that it does not return author', () => {
|
||||||
|
// Set the author email to be the same as the owner.
|
||||||
|
change.revisions.rev1.commit.author.email = 'abc@def';
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.AUTHOR));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole null for author with no current rev', () => {
|
||||||
|
delete change.current_revision;
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.AUTHOR));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole null for author with no commit', () => {
|
||||||
|
delete change.revisions.rev1.commit;
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.AUTHOR));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_getNonOwnerRole null for author with no author', () => {
|
||||||
|
delete change.revisions.rev1.commit.author;
|
||||||
|
assert.isNull(element._getNonOwnerRole(change,
|
||||||
|
element._CHANGE_ROLE.AUTHOR));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_computeParents', () => {
|
test('_computeParents', () => {
|
||||||
|
|||||||
@@ -599,6 +599,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
element._change = {
|
element._change = {
|
||||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
||||||
|
owner: {email: 'abc@def'},
|
||||||
revisions: {
|
revisions: {
|
||||||
rev2: {_number: 2, commit: {parents: []}},
|
rev2: {_number: 2, commit: {parents: []}},
|
||||||
rev1: {_number: 1, commit: {parents: []}},
|
rev1: {_number: 1, commit: {parents: []}},
|
||||||
|
|||||||
Reference in New Issue
Block a user