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