Add a "My jobs" tab to the dashboard

It shows all current jobs of which the user is a maintainer.
This commit is contained in:
Eelco Dolstra 2013-11-05 14:35:49 +01:00
parent 3c981bed02
commit b53bd868fb
2 changed files with 21 additions and 1 deletions

View file

@ -288,4 +288,19 @@ sub dashboard :Chained('user') :Args(0) {
}
sub my_jobs_tab :Chained('user') :PathPart('my-jobs-tab') :Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'dashboard-my-jobs-tab.tt';
die unless $c->stash->{user}->emailaddress;
# Get all current builds of which this user is a maintainer.
$c->stash->{builds} = [$c->model('DB::Builds')->search(
{ iscurrent => 1
, maintainers => { ilike => "%" . $c->stash->{user}->emailaddress . "%" }
},
{ order_by => ["project", "jobset", "job"] })];
}
1;

View file

@ -3,6 +3,7 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#tabs-starred-jobs" data-toggle="tab">Starred jobs</a></li>
<li><a href="#tabs-my-jobs" data-toggle="tab">My jobs</a></li>
</ul>
<div id="generic-tabs" class="tab-content">
@ -31,12 +32,16 @@
[% ELSE %]
<div class="alert alert-warning">You have no starred jobs. You can add them by visiting a job page and clicking on the ☆ icon.</div>
<div class="alert alert-warning">You have no starred jobs. You
can add them by visiting a job page and clicking on the ☆
icon.</div>
[% END %]
</div>
[% INCLUDE makeLazyTab tabName="tabs-my-jobs" uri=c.uri_for(c.controller('User').action_for('my_jobs_tab'), [user.username]) %]
</div>
[% END %]