Calculate actual avatar URL in model
repeated logic for Gravatar fallback
This commit is contained in:
parent
573ebfd406
commit
8abc24f04b
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { gravatarImage } from 'travis/utils/urls'`
|
|
||||||
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
||||||
`import { durationFrom, safe } from 'travis/utils/helpers'`
|
`import { durationFrom, safe } from 'travis/utils/helpers'`
|
||||||
`import { githubCommit } from 'travis/utils/urls'`
|
`import { githubCommit } from 'travis/utils/urls'`
|
||||||
|
@ -10,22 +9,6 @@ BuildHeaderComponent = Ember.Component.extend
|
||||||
classNames: ['build-header']
|
classNames: ['build-header']
|
||||||
classNameBindings: ['item.state']
|
classNameBindings: ['item.state']
|
||||||
|
|
||||||
committerAvatarUrl: (->
|
|
||||||
if url = @get('commit.committerAvatarUrl')
|
|
||||||
url
|
|
||||||
else
|
|
||||||
email = @get('commit.committerEmail')
|
|
||||||
gravatarImage(email, 40)
|
|
||||||
).property('commit.committerEmail', 'commit.committerAvatarUrl')
|
|
||||||
|
|
||||||
authorAvatarUrl: (->
|
|
||||||
if url = @get('commit.authorAvatarUrl')
|
|
||||||
url
|
|
||||||
else
|
|
||||||
email = @get('commit.authorEmail')
|
|
||||||
gravatarImage(email, 40)
|
|
||||||
).property('commit.authorEmail', 'commit.authorAvatarUrl')
|
|
||||||
|
|
||||||
isJob: (->
|
isJob: (->
|
||||||
if @get('item.build') then true else false
|
if @get('item.build') then true else false
|
||||||
).property('item')
|
).property('item')
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { gravatarImage } from 'travis/utils/urls'`
|
|
||||||
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
|
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
|
||||||
|
|
||||||
BuildsItemComponent = Ember.Component.extend
|
BuildsItemComponent = Ember.Component.extend
|
||||||
|
@ -7,14 +6,6 @@ BuildsItemComponent = Ember.Component.extend
|
||||||
classNameBindings: ['build.state']
|
classNameBindings: ['build.state']
|
||||||
classNames: ['row-li', 'pr-row']
|
classNames: ['row-li', 'pr-row']
|
||||||
|
|
||||||
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: (->
|
urlGithubCommit: (->
|
||||||
githubCommitUrl(@get('build.repo.slug'), @get('build.commit.sha'))
|
githubCommitUrl(@get('build.repo.slug'), @get('build.commit.sha'))
|
||||||
).property('build.commit.sha')
|
).property('build.commit.sha')
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import Model from 'travis/models/model'`
|
`import Model from 'travis/models/model'`
|
||||||
`import Build from 'travis/models/build'`
|
`import Build from 'travis/models/build'`
|
||||||
|
`import { gravatarImage } from 'travis/utils/urls'`
|
||||||
|
|
||||||
Commit = Model.extend
|
Commit = Model.extend
|
||||||
sha: DS.attr()
|
sha: DS.attr()
|
||||||
|
@ -34,4 +35,20 @@ Commit = Model.extend
|
||||||
@get('authorEmail') == @get('committerEmail')
|
@get('authorEmail') == @get('committerEmail')
|
||||||
).property('authorName', 'authorEmail', 'committerName', 'committerEmail')
|
).property('authorName', 'authorEmail', 'committerName', 'committerEmail')
|
||||||
|
|
||||||
|
authorAvatarUrl: (->
|
||||||
|
if url = @get('authorAvatarUrl')
|
||||||
|
url
|
||||||
|
else
|
||||||
|
email = @get('authorEmail')
|
||||||
|
gravatarImage(email, 40)
|
||||||
|
).property('authorEmail', 'authorAvatarUrl')
|
||||||
|
|
||||||
|
committerAvatarUrl: (->
|
||||||
|
if url = @get('committerAvatarUrl')
|
||||||
|
url
|
||||||
|
else
|
||||||
|
email = @get('committerEmail')
|
||||||
|
gravatarImage(email, 40)
|
||||||
|
).property('committerEmail', 'committerAvatarUrl')
|
||||||
|
|
||||||
`export default Commit`
|
`export default Commit`
|
||||||
|
|
|
@ -38,11 +38,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
<p class="commit-author">
|
<p class="commit-author">
|
||||||
{{#if commit.authorName}}
|
{{#if commit.authorName}}
|
||||||
<img src={{authorAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
|
<img src={{commit.authorAvatarUrl}} alt="author avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#unless commit.authorIsCommitter}}
|
{{#unless commit.authorIsCommitter}}
|
||||||
{{#if commit.committerName}}
|
{{#if commit.committerName}}
|
||||||
<img src={{committerAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
|
<img src={{commit.committerAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
<div class="row-item row-committer">
|
<div class="row-item row-committer">
|
||||||
<img class="avatar" src={{authorAvatarUrl}} alt="{{build.commit.committerName}} avatar">
|
<img class="avatar" src={{build.commit.authorAvatarUrl}} alt="{{build.commit.authorName}} avatar">
|
||||||
<span class="label-align">{{build.commit.committerName}}</span>
|
<span class="label-align">{{build.commit.committerName}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user