Merge "Display real author if differs from author"

This commit is contained in:
Wyatt Allen 2017-03-24 05:05:07 +00:00 committed by Gerrit Code Review
commit 41b2c1d9bc
3 changed files with 40 additions and 6 deletions

View File

@ -82,7 +82,7 @@ limitations under the License.
overflow: hidden;
text-overflow: ellipsis;
}
.collapsed .name,
.collapsed .author,
.collapsed .content,
.collapsed .message,
.collapsed .updateCategory,
@ -108,11 +108,11 @@ limitations under the License.
.collapsed .date {
position: static;
}
.collapsed .name {
.collapsed .author {
color: var(--default-text-color);
margin-right: .4em;
}
.expanded .name {
.expanded .author {
cursor: pointer;
}
.date {
@ -128,7 +128,13 @@ limitations under the License.
<div class$="[[_computeClass(_expanded, showAvatar)]]">
<gr-avatar account="[[author]]" image-size="100"></gr-avatar>
<div class="contentContainer">
<div class="name" on-tap="_handleNameTap">[[author.name]]</div>
<div class="author" on-tap="_handleAuthorTap">
<span hidden$="[[!showOnBehalfOf]]">
<span class="name">[[message.real_author.name]]</span>
on behalf of
</span>
<span class="name">[[author.name]]</span>
</div>
<template is="dom-if" if="[[message.message]]">
<div class="content">
<div class="message hideOnOpen">[[message.message]]</div>

View File

@ -62,6 +62,10 @@
type: Boolean,
computed: '_computeShowAvatar(author, config)',
},
showOnBehalfOf: {
type: Boolean,
computed: '_computeShowOnBehalfOf(message)',
},
showReplyButton: {
type: Boolean,
computed: '_computeShowReplyButton(message, _loggedIn)',
@ -107,6 +111,12 @@
return !!(author && config && config.plugin && config.plugin.has_avatars);
},
_computeShowOnBehalfOf: function(message) {
var author = message.author || message.updated_by;
return !!(author && message.real_author &&
author._account_id != message.real_author._account_id);
},
_computeShowReplyButton: function(message, loggedIn) {
return !!message.message && loggedIn;
},
@ -132,7 +142,7 @@
this.set('message.expanded', true);
},
_handleNameTap: function(e) {
_handleAuthorTap: function(e) {
if (!this.message.expanded) { return; }
e.stopPropagation();
this.set('message.expanded', false);

View File

@ -90,7 +90,7 @@ limitations under the License.
var content = element.$$('.contentContainer');
assert.isOk(content);
assert.strictEqual(element.$$('gr-account-chip').account, reviewer);
assert.equal(author.name, element.$$('.name').textContent);
assert.equal(author.name, element.$$('.author > .name').textContent);
});
test('autogenerated prefix hiding', function() {
@ -143,5 +143,23 @@ limitations under the License.
assert.isFalse(element._computeShowReplyButton(message, false));
assert.isTrue(element._computeShowReplyButton(message, true));
});
test('_computeShowOnBehalfOf', function() {
var message = {
message: '...',
};
assert.isNotOk(element._computeShowOnBehalfOf(message));
message.author = {_account_id: 1115495};
assert.isNotOk(element._computeShowOnBehalfOf(message));
message.real_author = {_account_id: 1115495};
assert.isNotOk(element._computeShowOnBehalfOf(message));
message.real_author._account_id = 123456;
assert.isOk(element._computeShowOnBehalfOf(message));
message.updated_by = message.author;
delete message.author;
assert.isOk(element._computeShowOnBehalfOf(message));
delete message.updated_by;
assert.isNotOk(element._computeShowOnBehalfOf(message));
});
});
</script>