From b53bd868fbd196cb3554d7344aa87eaf96fba6a2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Nov 2013 14:35:49 +0100 Subject: [PATCH] Add a "My jobs" tab to the dashboard It shows all current jobs of which the user is a maintainer. --- src/lib/Hydra/Controller/User.pm | 15 +++++++++++++++ src/root/dashboard.tt | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lib/Hydra/Controller/User.pm b/src/lib/Hydra/Controller/User.pm index 96dd3e30..ca626077 100644 --- a/src/lib/Hydra/Controller/User.pm +++ b/src/lib/Hydra/Controller/User.pm @@ -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; diff --git a/src/root/dashboard.tt b/src/root/dashboard.tt index d33eb887..2e30ea4b 100644 --- a/src/root/dashboard.tt +++ b/src/root/dashboard.tt @@ -3,6 +3,7 @@
@@ -31,12 +32,16 @@ [% ELSE %] -
You have no starred jobs. You can add them by visiting a job page and clicking on the ☆ icon.
+
You have no starred jobs. You + can add them by visiting a job page and clicking on the ☆ + icon.
[% END %]
+ [% INCLUDE makeLazyTab tabName="tabs-my-jobs" uri=c.uri_for(c.controller('User').action_for('my_jobs_tab'), [user.username]) %] + [% END %]