Fix committer and author in build header

This commit is contained in:
Piotr Sarnacki 2015-12-10 09:29:30 +01:00
parent b94cc70a4e
commit b950b60c64
6 changed files with 45 additions and 16 deletions

View File

@ -10,13 +10,21 @@ BuildHeaderComponent = Ember.Component.extend
classNames: ['build-header']
classNameBindings: ['item.state']
urlCommitterGravatarImage: (->
gravatarImage(@get('commit.committerEmail'), 40)
).property('commit.committerEmail')
committerAvatarUrl: (->
if url = @get('commit.committerAvatarUrl')
url
else
email = @get('commit.committerEmail')
gravatarImage(email, 40)
).property('commit.committerEmail', 'commit.committerAvatarUrl')
urlAuthorGravatarImage: (->
gravatarImage(@get('commit.authorEmail'), 40)
).property('commit.authorEmail')
authorAvatarUrl: (->
if url = @get('commit.authorAvatarUrl')
url
else
email = @get('commit.authorEmail')
gravatarImage(email, 40)
).property('commit.authorEmail', 'commit.authorAvatarUrl')
isJob: (->
if @get('item.build') then true else false

View File

@ -3,14 +3,17 @@
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
BuildsItemComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['build.state']
classNames: ['row-li', 'pr-row']
urlAuthorGravatarImage: (->
gravatarImage(@get('build.commit.authorEmail'), 40)
).property('build.commit.authorEmail')
authorAvatarUrl: (->
if url = @get('build.commit.authorAvatarUrl')
url
else
email = @get('build.commit.authorEmail')
gravatarImage(email, 40)
).property('build.commit.authorEmail', 'build.commit.authorAvatarUrl')
urlGithubCommit: (->
githubCommitUrl(@get('build.repo.slug'), @get('build.commit.sha'))

View File

@ -12,6 +12,8 @@ Commit = Model.extend
committerName: DS.attr()
committerEmail: DS.attr()
committedAt: DS.attr()
committerAvatarUrl: DS.attr()
authorAvatarUrl: DS.attr()
build: DS.belongsTo('build')

16
app/serializers/commit.js Normal file
View File

@ -0,0 +1,16 @@
import Ember from 'ember';
import V2FallbackSerializer from 'travis/serializers/v2_fallback';
export default V2FallbackSerializer.extend({
normalize(modelClass, resourceHash) {
if(resourceHash.author && resourceHash.author.name) {
resourceHash.author_name = resourceHash.author.name;
resourceHash.author_avatar_url = resourceHash.author.avatar_url;
}
if(resourceHash.committer && resourceHash.committer.name) {
resourceHash.committer_name = resourceHash.author.name;
resourceHash.committer_avatar_url = resourceHash.author.avatar_url;
}
return this._super(...arguments);
}
});

View File

@ -6,15 +6,15 @@
{{item.pullRequestTitle}}
{{else}}
<small class="commit-branch" title={{item.branch.name}}>{{item.branch.name}}</small>
{{format-message item.commit.subject repo=item.repo}}
{{format-message commit.subject repo=item.repo}}
{{/if}}
</h2>
<div class="commit-info">
<p class="commit-description">
{{#if item.pullRequest}}
{{format-message item.commit.subject repo=item.repo}}<br>
{{format-message commit.subject repo=item.repo}}<br>
{{/if}}
<span class="monospace">{{format-message item.commit.body repo=item.repo pre=true}}</span>
<span class="monospace">{{format-message commit.body repo=item.repo pre=true}}</span>
</p>
<ul class="list-icon">
<li>
@ -34,11 +34,11 @@
</ul>
<p class="commit-author">
{{#if commit.authorName}}
<img src={{urlAuthorGravatarImage}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
<img src={{authorAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
{{/if}}
{{#unless commit.authorIsCommitter}}
{{#if commit.committerName}}
<img src={{urlCommitterGravatarImage}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
<img src={{committerAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
{{/if}}
{{/unless}}
</p>

View File

@ -20,7 +20,7 @@
{{/unless}}
</div>
<div class="row-item row-committer">
<img class="avatar" src={{urlAuthorGravatarImage}} alt="{{build.commit.committerName}} avatar">
<img class="avatar" src={{authorAvatarUrl}} alt="{{build.commit.committerName}} avatar">
<span class="label-align">{{build.commit.committerName}}</span>
</div>
</div>