--- a/lib/CrashTest/Helper/BugLinks.pm Sun Nov 27 17:17:43 2016 +0100
+++ b/lib/CrashTest/Helper/BugLinks.pm Sun Dec 04 01:16:39 2016 +0100
@@ -23,6 +23,7 @@
$self->app($app);
$app->helper(bug_links => sub { $self->_bug_links(@_) } );
+ $app->helper(bug_status => sub { $self->_bug_status(@_) } );
}
sub _link_template {
@@ -74,4 +75,34 @@
return Mojo::ByteStream->new(join ", ", @links);
}
+sub _bug_status {
+ my ($self, $c, $bug, $bugs_status) = @_;
+
+ my $bug_status = $bugs_status->{$bug->{bugtracker_key}}->{$bug->{bug_key}};
+ my $link;
+ my $template = $self->_link_template($bug->{bugtracker_key});
+ if(defined($template)) {
+ # build url using the configured template
+ my $url = $template->process({ bug_key => $bug->{bug_key} });
+ # and create a link to it
+ $link = $self->app->t(tr => sub { join "", (
+ $self->app->t(td => sub { $self->app->link_to($bug->{bug_key} => $url) }),
+ $self->app->t(td => sub { $bug_status->{status} }),
+ $self->app->t(td => sub { $bug_status->{resolution} }),
+ $self->app->t(td => sub { $bug_status->{summary} }),
+ )}
+ );
+ } else {
+ $link = $self->app->t(tr => sub { join "", (
+ $self->app->t(td => $bug->{bug_key}),
+ $self->app->t(td => ""),
+ $self->app->t(td => ""),
+ $self->app->t(td => ""),
+ )}
+ );
+ }
+
+ return Mojo::ByteStream->new($link);
+}
+
1;