Extract Github URLs to controller
This commit is contained in:
parent
e84b7b81c5
commit
47e1de1d26
assets/scripts/app
|
@ -49,6 +49,7 @@ Travis.FirstSyncController = Em.Controller.extend
|
|||
isSyncing: Ember.computed.alias('user.isSyncing')
|
||||
|
||||
Travis.IndexErrorController = Em.Controller.extend()
|
||||
Travis.BuildsItemController = Em.ObjectController.extend(Travis.GithubUrlProperties)
|
||||
|
||||
require 'controllers/accounts'
|
||||
require 'controllers/auth'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Travis.BuildController = Ember.Controller.extend
|
||||
Travis.BuildController = Ember.Controller.extend Travis.GithubUrlProperties,
|
||||
needs: ['repo']
|
||||
repoBinding: 'controllers.repo.repo'
|
||||
commitBinding: 'build.commit'
|
||||
|
@ -10,7 +10,3 @@ Travis.BuildController = Ember.Controller.extend
|
|||
loading: (->
|
||||
@get('build.isLoading')
|
||||
).property('build.isLoading')
|
||||
|
||||
urlGithubCommit: (->
|
||||
Travis.Urls.githubCommit(@get('repo.slug'), @get('commit.sha'))
|
||||
).property('repo.slug', 'commit.sha')
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Travis.BuildsController = Em.ArrayController.extend
|
||||
isPullRequestsList: false
|
||||
|
||||
sortAscending: false
|
||||
sortProperties: ['number']
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@ require 'helpers/handlebars'
|
|||
require 'helpers/helpers'
|
||||
require 'helpers/urls'
|
||||
require 'helpers/status_image_formatter'
|
||||
require 'helpers/github_url_properties'
|
||||
|
|
8
assets/scripts/app/helpers/github_url_properties.coffee
Normal file
8
assets/scripts/app/helpers/github_url_properties.coffee
Normal file
|
@ -0,0 +1,8 @@
|
|||
Travis.GithubUrlProperties = Ember.Mixin.create
|
||||
urlGithubCommit: (->
|
||||
Travis.Urls.githubCommit(@get('repo.slug'), @get('commit.sha'))
|
||||
).property('repo.slug', 'commit.sha')
|
||||
|
||||
urlGithubPullRequest: (->
|
||||
Travis.Urls.githubPullRequest(@get('repo.slug'), @get('build.pullRequestNumber'))
|
||||
).property('repo.slug', 'build.pullRequestNumber')
|
|
@ -195,8 +195,19 @@ Travis.AbstractBuildsRoute = Travis.Route.extend
|
|||
).property('contentType')
|
||||
|
||||
Travis.BuildsRoute = Travis.AbstractBuildsRoute.extend(contentType: 'builds')
|
||||
Travis.PullRequestsRoute = Travis.AbstractBuildsRoute.extend(contentType: 'pull_requests')
|
||||
Travis.BranchesRoute = Travis.AbstractBuildsRoute.extend(contentType: 'branches')
|
||||
Travis.PullRequestsRoute = Travis.AbstractBuildsRoute.extend(
|
||||
contentType: 'pull_requests'
|
||||
|
||||
# TODO: it would be better to have separate controller for branches and PRs list
|
||||
setupController: (controller, model) ->
|
||||
@_super(controller, model)
|
||||
|
||||
this.controllerFor('builds').set('isPullRequestsList', true)
|
||||
|
||||
deactivate: ->
|
||||
this.controllerFor('builds').set('isPullRequestsList', false)
|
||||
)
|
||||
|
||||
Travis.BuildRoute = Travis.Route.extend
|
||||
serialize: (model, params) ->
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<th class="committer">
|
||||
Committer
|
||||
</th>
|
||||
{{#if view.isPullRequestsList}}
|
||||
{{#if isPullRequestsList}}
|
||||
<th>
|
||||
PR
|
||||
</th>
|
||||
|
@ -21,7 +21,7 @@
|
|||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{#each build in controller}}
|
||||
{{#each build in controller itemController="buildsItem"}}
|
||||
{{#view Travis.BuildsItemView contextBinding="build"}}
|
||||
<td class="number">
|
||||
<span class="status"></span>
|
||||
|
@ -35,16 +35,16 @@
|
|||
{{{formatMessage commit.message short="true" repoBinding=build.repo}}}
|
||||
</td>
|
||||
<td class="commit">
|
||||
<a {{bind-attr href="view.urlGithubCommit"}}>
|
||||
<a {{bind-attr href="urlGithubCommit"}}>
|
||||
{{formatCommit commit}}
|
||||
</a>
|
||||
</td>
|
||||
<td class="committer">
|
||||
{{commit.committerName}}
|
||||
</td>
|
||||
{{#if view.isPullRequestsList}}
|
||||
{{#if isPullRequestsList}}
|
||||
<td>
|
||||
<a {{bind-attr href="view.urlGithubPullRequest"}}>
|
||||
<a {{bind-attr href="urlGithubPullRequest"}}>
|
||||
#{{pullRequestNumber}}
|
||||
</a>
|
||||
</td>
|
||||
|
|
|
@ -3,10 +3,6 @@ Travis.reopen
|
|||
templateName: 'builds/list'
|
||||
buildsBinding: 'controller.builds'
|
||||
|
||||
isPullRequestsList: (->
|
||||
@get('controller.tab') == 'pull_requests'
|
||||
).property('controller.tab')
|
||||
|
||||
ShowMoreButton: Em.View.extend
|
||||
tagName: 'button'
|
||||
classNameBindings: ['isLoading', 'showMore']
|
||||
|
@ -37,14 +33,6 @@ Travis.reopen
|
|||
Travis.Helpers.colorForState(@get('build.state'))
|
||||
).property('build.state')
|
||||
|
||||
urlGithubCommit: (->
|
||||
Travis.Urls.githubCommit(@get('repo.slug'), @get('commit.sha'))
|
||||
).property('repo.slug', 'commit.sha')
|
||||
|
||||
urlGithubPullRequest: (->
|
||||
Travis.Urls.githubPullRequest(@get('repo.slug'), @get('build.pullRequestNumber'))
|
||||
).property('repo.slug', 'build.pullRequestNumber')
|
||||
|
||||
BuildView: Travis.View.extend
|
||||
templateName: 'builds/show'
|
||||
classNameBindings: ['color', 'loading']
|
||||
|
|
Loading…
Reference in New Issue
Block a user