Add requests page
This commit is contained in:
parent
d6336a8b36
commit
57edf811b7
|
@ -22,10 +22,12 @@ unless window.TravisApplication
|
||||||
workers: Travis.Worker
|
workers: Travis.Worker
|
||||||
annotation: Travis.Annotation
|
annotation: Travis.Annotation
|
||||||
annotations: Travis.Annotation
|
annotations: Travis.Annotation
|
||||||
|
request: Travis.Request
|
||||||
|
requests: Travis.Request
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
modelClasses: (->
|
modelClasses: (->
|
||||||
[Travis.User, Travis.Build, Travis.Job, Travis.Repo, Travis.Commit, Travis.Worker, Travis.Account, Travis.Broadcast, Travis.Hook, Travis.Annotation]
|
[Travis.User, Travis.Build, Travis.Job, Travis.Repo, Travis.Commit, Travis.Worker, Travis.Account, Travis.Broadcast, Travis.Hook, Travis.Annotation, Travis.Request]
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
setup: ->
|
setup: ->
|
||||||
|
|
|
@ -72,4 +72,5 @@ require 'controllers/repo'
|
||||||
require 'controllers/stats'
|
require 'controllers/stats'
|
||||||
require 'controllers/current_user'
|
require 'controllers/current_user'
|
||||||
require 'controllers/account_index'
|
require 'controllers/account_index'
|
||||||
|
require 'controllers/request'
|
||||||
|
require 'controllers/requests'
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
Travis.RepoController = Travis.Controller.extend
|
Travis.RepoController = Travis.Controller.extend
|
||||||
needs: ['repos', 'currentUser', 'build']
|
needs: ['repos', 'currentUser', 'build', 'request']
|
||||||
currentUserBinding: 'controllers.currentUser'
|
currentUserBinding: 'controllers.currentUser'
|
||||||
|
|
||||||
build: Ember.computed.alias('controllers.build.build')
|
build: Ember.computed.alias('controllers.build.build')
|
||||||
|
request: Ember.computed.alias('controllers.request.model')
|
||||||
|
|
||||||
slug: (-> @get('repo.slug') ).property('repo.slug')
|
slug: (-> @get('repo.slug') ).property('repo.slug')
|
||||||
isLoading: (-> @get('repo.isLoading') ).property('repo.isLoading')
|
isLoading: (-> @get('repo.isLoading') ).property('repo.isLoading')
|
||||||
|
@ -49,6 +50,12 @@ Travis.RepoController = Travis.Controller.extend
|
||||||
viewJob: ->
|
viewJob: ->
|
||||||
@connectTab('job')
|
@connectTab('job')
|
||||||
|
|
||||||
|
viewRequests: ->
|
||||||
|
@connectTab('requests')
|
||||||
|
|
||||||
|
viewRequest: ->
|
||||||
|
@connectTab('request')
|
||||||
|
|
||||||
lastBuildDidChange: ->
|
lastBuildDidChange: ->
|
||||||
Ember.run.scheduleOnce('data', this, @_lastBuildDidChange);
|
Ember.run.scheduleOnce('data', this, @_lastBuildDidChange);
|
||||||
|
|
||||||
|
|
21
assets/scripts/app/controllers/request.coffee
Normal file
21
assets/scripts/app/controllers/request.coffee
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Travis.RequestController = Ember.ObjectController.extend
|
||||||
|
requestClass: (->
|
||||||
|
if @get('content.isAccepted')
|
||||||
|
'accepted'
|
||||||
|
else
|
||||||
|
'rejected'
|
||||||
|
).property('content.isAccepted')
|
||||||
|
|
||||||
|
type: (->
|
||||||
|
if @get('isPullRequest')
|
||||||
|
'Pull request'
|
||||||
|
else
|
||||||
|
'Push'
|
||||||
|
).property('isPullRequest')
|
||||||
|
|
||||||
|
status: (->
|
||||||
|
if @get('isAccepted')
|
||||||
|
'Accepted'
|
||||||
|
else
|
||||||
|
'Rejected'
|
||||||
|
).property('isAccepted')
|
1
assets/scripts/app/controllers/requests.coffee
Normal file
1
assets/scripts/app/controllers/requests.coffee
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Travis.RequestsController = Ember.ArrayController.extend()
|
|
@ -319,7 +319,7 @@ Ember.Handlebars.helper('formatCommit', (commit) ->
|
||||||
safe Travis.Helpers.formatCommit(commit.get('sha'), commit.get('branch')) if commit
|
safe Travis.Helpers.formatCommit(commit.get('sha'), commit.get('branch')) if commit
|
||||||
, 'sha', 'branch')
|
, 'sha', 'branch')
|
||||||
|
|
||||||
Ember.registerBoundHelper 'formatSha', (sha, options) ->
|
Ember.Handlebars.helper 'formatSha', (sha) ->
|
||||||
safe Travis.Helpers.formatSha(sha)
|
safe Travis.Helpers.formatSha(sha)
|
||||||
|
|
||||||
Ember.registerBoundHelper 'pathFrom', (url, options) ->
|
Ember.registerBoundHelper 'pathFrom', (url, options) ->
|
||||||
|
|
|
@ -10,6 +10,7 @@ require 'models/job'
|
||||||
require 'models/log'
|
require 'models/log'
|
||||||
require 'models/annotation'
|
require 'models/annotation'
|
||||||
require 'models/repo'
|
require 'models/repo'
|
||||||
|
require 'models/request'
|
||||||
require 'models/user'
|
require 'models/user'
|
||||||
require 'models/worker'
|
require 'models/worker'
|
||||||
|
|
||||||
|
|
30
assets/scripts/app/models/request.coffee
Normal file
30
assets/scripts/app/models/request.coffee
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
require 'travis/model'
|
||||||
|
|
||||||
|
@Travis.Request = Travis.Model.extend
|
||||||
|
id: Ember.attr('string')
|
||||||
|
created_at: Ember.attr('string')
|
||||||
|
event_type: Ember.attr('string')
|
||||||
|
result: Ember.attr('string')
|
||||||
|
message: Ember.attr('string')
|
||||||
|
headCommit: Ember.attr('string')
|
||||||
|
baseCommit: Ember.attr('string')
|
||||||
|
branchName: Ember.attr('string', key: 'branch')
|
||||||
|
tagName: Ember.attr('string', key: 'tag')
|
||||||
|
pullRequest: Ember.attr('boolean')
|
||||||
|
pullRequestTitle: Ember.attr('string')
|
||||||
|
pullRequestNumber: Ember.attr(Number)
|
||||||
|
|
||||||
|
repo: Ember.belongsTo('Travis.Request', key: 'repository_id')
|
||||||
|
commit: Ember.belongsTo('Travis.Commit', key: 'commit_id')
|
||||||
|
build: Ember.belongsTo('Travis.Build', key: 'build_id')
|
||||||
|
|
||||||
|
isAccepted: (->
|
||||||
|
# For some reason some of the requests have a null result beside the fact that
|
||||||
|
# the build was created. We need to look into it, but for now we can just assume
|
||||||
|
# that if build was created, the request was accepted
|
||||||
|
@get('result') == 'accepted' || @get('build')
|
||||||
|
).property('result')
|
||||||
|
|
||||||
|
isPullRequest: (->
|
||||||
|
@get('event_type') == 'pull_request'
|
||||||
|
).property('event_type')
|
|
@ -80,6 +80,8 @@ Travis.Router.map ->
|
||||||
@resource 'builds', path: '/builds'
|
@resource 'builds', path: '/builds'
|
||||||
@resource 'pullRequests', path: '/pull_requests'
|
@resource 'pullRequests', path: '/pull_requests'
|
||||||
@resource 'branches', path: '/branches'
|
@resource 'branches', path: '/branches'
|
||||||
|
@resource 'requests', path: '/requests'
|
||||||
|
@resource 'request', path: '/requests/:request_id'
|
||||||
|
|
||||||
# this can't be nested in repo, because we want a set of different
|
# this can't be nested in repo, because we want a set of different
|
||||||
# templates rendered for settings (for example no "current", "builds", ... tabs)
|
# templates rendered for settings (for example no "current", "builds", ... tabs)
|
||||||
|
@ -111,6 +113,38 @@ Travis.SetupLastBuild = Ember.Mixin.create
|
||||||
Ember.run.next =>
|
Ember.run.next =>
|
||||||
@render('builds/not_found', into: 'repo', outlet: 'pane')
|
@render('builds/not_found', into: 'repo', outlet: 'pane')
|
||||||
|
|
||||||
|
Travis.RepoLoadingRoute = Travis.Route.extend
|
||||||
|
renderTemplate: ->
|
||||||
|
# TODO: the main outlet used on repo level is called 'pane'
|
||||||
|
# which makes a few things quite hard with current Ember.js
|
||||||
|
# conventions. Here, we need to specify render behaviour
|
||||||
|
# of a loading route explicitly, because otherwise it will
|
||||||
|
# render into 'main' outlet. It would be nice to change
|
||||||
|
# pane outlet into main outlet at some point
|
||||||
|
@render 'repo/loading', into: 'repo', outlet: 'pane'
|
||||||
|
|
||||||
|
Travis.RequestsRoute = Travis.Route.extend
|
||||||
|
renderTemplate: ->
|
||||||
|
@render 'requests', into: 'repo', outlet: 'pane'
|
||||||
|
|
||||||
|
setupController: ->
|
||||||
|
@_super.apply this, arguments
|
||||||
|
@controllerFor('repo').activate('requests')
|
||||||
|
|
||||||
|
model: ->
|
||||||
|
Travis.Request.fetch repository_id: @modelFor('repo').get('id')
|
||||||
|
|
||||||
|
Travis.RequestRoute = Travis.Route.extend
|
||||||
|
renderTemplate: ->
|
||||||
|
@render 'request', into: 'repo', outlet: 'pane'
|
||||||
|
|
||||||
|
setupController: ->
|
||||||
|
@_super.apply this, arguments
|
||||||
|
@controllerFor('repo').activate('request')
|
||||||
|
|
||||||
|
model: (params) ->
|
||||||
|
Travis.Request.fetch params.request_id
|
||||||
|
|
||||||
Travis.GettingStartedRoute = Travis.Route.extend
|
Travis.GettingStartedRoute = Travis.Route.extend
|
||||||
renderTemplate: ->
|
renderTemplate: ->
|
||||||
@render('no_owned_repos')
|
@render('no_owned_repos')
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
{{#if slug}}
|
||||||
<div id="repo">
|
<div id="repo">
|
||||||
<span class="not-found">The repository at {{slug}} was not found.</span>
|
<span class="not-found">The repository at {{slug}} was not found.</span>
|
||||||
</div>
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<p>There was an error while loading data, please try again</p>
|
||||||
|
{{/if}}
|
||||||
|
|
1
assets/scripts/app/templates/repo/loading.hbs
Normal file
1
assets/scripts/app/templates/repo/loading.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<div class="loading"><span>Loading</span></div>
|
|
@ -57,4 +57,24 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</h5>
|
</h5>
|
||||||
</li>
|
</li>
|
||||||
|
<li id="tab_requests" {{bind-attr class="view.classRequests"}}>
|
||||||
|
<h5>
|
||||||
|
{{#if repo.slug}}
|
||||||
|
{{#link-to "requests" repo}}
|
||||||
|
Requests
|
||||||
|
{{/link-to}}
|
||||||
|
{{/if}}
|
||||||
|
</h5>
|
||||||
|
</li>
|
||||||
|
<li id="tab_request" {{bind-attr class="view.classRequest"}}>
|
||||||
|
<h5>
|
||||||
|
{{#if request.id}}
|
||||||
|
{{#if repo.slug}}
|
||||||
|
{{#link-to "request" repo request}}
|
||||||
|
Request #{{request.id}}
|
||||||
|
{{/link-to}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
</h5>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
{{#link-to "repo.settings" view.repo}}Settings{{/link-to}}
|
{{#link-to "repo.settings" view.repo}}Settings{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
<li>
|
||||||
|
{{#link-to "requests" view.repo}}Requests{{/link-to}}
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<a href="#" id="status-image-popup" name="status-images" class="open-popup" {{action "statusImages" target="view"}}>
|
<a href="#" id="status-image-popup" name="status-images" class="open-popup" {{action "statusImages" target="view"}}>
|
||||||
|
|
22
assets/scripts/app/templates/request.hbs
Normal file
22
assets/scripts/app/templates/request.hbs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<div id="request" {{bind-attr class="isAccepted:accepted:rejected"}}>
|
||||||
|
<h3>{{status}}{{#unless isAccepted}}: {{message}}{{/unless}}</h3>
|
||||||
|
|
||||||
|
<p class="request-details">
|
||||||
|
{{#if isPullRequest}}
|
||||||
|
This request is based on the
|
||||||
|
<span class="pr-number" {{bind-attr title="pullRequestTitle"}}>#{{pullRequestNumber}}</span>
|
||||||
|
pull request.
|
||||||
|
{{else}}
|
||||||
|
This request is based on a commit {{formatCommit commit}} by {{commit.authorName}}
|
||||||
|
pushed to
|
||||||
|
{{#if branchName}}
|
||||||
|
to <code>{{branchName}}</code>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
</p>
|
||||||
|
{{#if build}}
|
||||||
|
<p class="request-details">
|
||||||
|
A build created based on this request: {{#link-to "build" build}}#{{build.number}}{{/link-to}}
|
||||||
|
</p>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
34
assets/scripts/app/templates/requests.hbs
Normal file
34
assets/scripts/app/templates/requests.hbs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<table id="requests" class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Commit</th>
|
||||||
|
<th>Build</th>
|
||||||
|
<th>Commit message</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Message</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{{#each request in controller itemController="request"}}
|
||||||
|
<tr {{bind-attr class="requestClass"}}>
|
||||||
|
<td class="request-id">
|
||||||
|
<span class="status"></span>
|
||||||
|
{{request.id}}
|
||||||
|
</td>
|
||||||
|
<td>{{formatSha request.commit.sha}}</td>
|
||||||
|
<td>
|
||||||
|
{{#if build}}
|
||||||
|
{{#link-to "build" build}}#{{build.number}}{{/link-to}}
|
||||||
|
{{else}}
|
||||||
|
-
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
<td>{{{formatMessage request.commit.message short="true" repoBinding=build.repo}}}</td>
|
||||||
|
<td>{{request.type}}</td>
|
||||||
|
<td>{{request.message}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
|
@ -66,10 +66,19 @@ Travis.reopen
|
||||||
classes.join(' ')
|
classes.join(' ')
|
||||||
).property('tab')
|
).property('tab')
|
||||||
|
|
||||||
|
# TODO: refactor tabs, most of the things here are not really DRY
|
||||||
classJob: (->
|
classJob: (->
|
||||||
'active display-inline' if @get('tab') == 'job'
|
'active display-inline' if @get('tab') == 'job'
|
||||||
).property('tab')
|
).property('tab')
|
||||||
|
|
||||||
|
classRequests: (->
|
||||||
|
'active display-inline' if @get('tab') == 'requests'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
|
classRequest: (->
|
||||||
|
'active display-inline' if @get('tab') == 'request'
|
||||||
|
).property('tab')
|
||||||
|
|
||||||
RepoShowToolsView: Travis.View.extend
|
RepoShowToolsView: Travis.View.extend
|
||||||
templateName: 'repos/show/tools'
|
templateName: 'repos/show/tools'
|
||||||
|
|
||||||
|
@ -80,6 +89,15 @@ Travis.reopen
|
||||||
currentUserBinding: 'controller.currentUser'
|
currentUserBinding: 'controller.currentUser'
|
||||||
slugBinding: 'controller.repo.slug'
|
slugBinding: 'controller.repo.slug'
|
||||||
|
|
||||||
|
|
||||||
|
didInsertElement: ->
|
||||||
|
self = this
|
||||||
|
$('.menu a').on 'click', ->
|
||||||
|
self.closeMenu()
|
||||||
|
|
||||||
|
willRemoveElement: ->
|
||||||
|
$('.menu a').off 'click'
|
||||||
|
|
||||||
closeMenu: ->
|
closeMenu: ->
|
||||||
$('.menu').removeClass('display')
|
$('.menu').removeClass('display')
|
||||||
|
|
||||||
|
|
17
assets/styles/requests.sass
Normal file
17
assets/styles/requests.sass
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
@import "_mixins/all"
|
||||||
|
|
||||||
|
#request
|
||||||
|
h3
|
||||||
|
font-size: 120%
|
||||||
|
padding-left: 15px
|
||||||
|
background-position: 0px 6px
|
||||||
|
&.accepted
|
||||||
|
h3
|
||||||
|
background-image: inline-image('icons/state-passed.svg')
|
||||||
|
color: $color-text-status-passed
|
||||||
|
&.rejected
|
||||||
|
h3
|
||||||
|
background-image: inline-image('icons/state-failed.svg')
|
||||||
|
color: $color-text-status-failed
|
||||||
|
.pr-number
|
||||||
|
border-bottom: dotted black 1px
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#repos .yellow,
|
#repos .yellow,
|
||||||
.yellow #summary .number,
|
.yellow #summary .number,
|
||||||
.list .yellow .number,
|
.list .yellow .number
|
||||||
.status
|
.status
|
||||||
background-image: inline-image('icons/state-pending.svg')
|
background-image: inline-image('icons/state-pending.svg')
|
||||||
a
|
a
|
||||||
|
@ -21,7 +21,8 @@
|
||||||
|
|
||||||
#repos .green,
|
#repos .green,
|
||||||
.green #summary .number,
|
.green #summary .number,
|
||||||
.list .green .number
|
.list .green .number,
|
||||||
|
#requests .accepted .request-id
|
||||||
.status
|
.status
|
||||||
background-image: inline-image('icons/state-passed.svg')
|
background-image: inline-image('icons/state-passed.svg')
|
||||||
a
|
a
|
||||||
|
@ -29,7 +30,8 @@
|
||||||
|
|
||||||
#repos .red,
|
#repos .red,
|
||||||
.red #summary .number,
|
.red #summary .number,
|
||||||
.list .red .number
|
.list .red .number,
|
||||||
|
#requests .rejected .request-id
|
||||||
.status
|
.status
|
||||||
background-image: inline-image('icons/state-failed.svg')
|
background-image: inline-image('icons/state-failed.svg')
|
||||||
a
|
a
|
||||||
|
@ -50,20 +52,20 @@ table.list
|
||||||
tr:hover td
|
tr:hover td
|
||||||
background-color: $color-bg-job-highlight
|
background-color: $color-bg-job-highlight
|
||||||
|
|
||||||
.green
|
.green, .accepted
|
||||||
td
|
td
|
||||||
background-color: $color-bg-job-passed
|
background-color: $color-bg-job-passed
|
||||||
&:hover td
|
&:hover td
|
||||||
background-color: $color-bg-job-passed-highlight
|
background-color: $color-bg-job-passed-highlight
|
||||||
.number a
|
.number a, .request-id a
|
||||||
color: $color-text-status-passed
|
color: $color-text-status-passed
|
||||||
|
|
||||||
.red
|
.red, .rejected
|
||||||
td
|
td
|
||||||
background-color: $color-bg-job-failed
|
background-color: $color-bg-job-failed
|
||||||
&:hover td
|
&:hover td
|
||||||
background-color: $color-bg-job-failed-highlight
|
background-color: $color-bg-job-failed-highlight
|
||||||
.number a
|
.number a, .request-id a
|
||||||
color: $color-text-status-failed
|
color: $color-text-status-failed
|
||||||
|
|
||||||
.gray
|
.gray
|
||||||
|
|
|
@ -68,7 +68,9 @@
|
||||||
margin-top: 20px
|
margin-top: 20px
|
||||||
|
|
||||||
#tab_build,
|
#tab_build,
|
||||||
#tab_job
|
#tab_job,
|
||||||
|
#tab_request,
|
||||||
|
#tab_requests
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
#profile
|
#profile
|
||||||
|
|
Loading…
Reference in New Issue
Block a user