forked from yuki-kimoto/gitprep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpulls.html.ep
105 lines (90 loc) · 3.54 KB
/
pulls.html.ep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<%
# API
my $api = gitprep_api;
# Parameters
my $user_id = param('user');
my $project_id = param('project');
my $is = param('is');
my $open = $is eq 'closed' ? 0 : 1;
# Git
my $git = $self->app->git;
my $project_row_id = $api->get_project_row_id($user_id, $project_id);
# Issues which have pull request
my $issue_where = [
['and', ':issue.open{=}', ':pull_request{<>}', ':project{=}'],
{'issue.open' => $open, pull_request => 0, project => $project_row_id}
];
my $issues = app->dbi->model('issue')->select(
[
{__MY__ => '*'},
{open_user => ['id']},
{pull_request => ['target_branch']}
],
where => $issue_where
)->all;
# Open count
my $open_count = $api->get_open_pull_request_count($user_id, $project_id);
# Close count
my $close_count = $api->get_close_pull_request_count($user_id, $project_id);
my $default_branch = app->manager->default_branch($user_id, $project_id);
# Original projcet
my $original_project = app->manager->original_project($user_id, $project_id);
%>
% layout 'common', title => "Pull Requests Tags \x{30fb} $user_id/$project_id";
%= include '/include/header';
<div class="container">
% if ($api->logined) {
<div class="pulls-button-container">
% if ($original_project) {
<a href="<%= url_for("/$original_project->{'user.id'}/$original_project->{id}/compare/$original_project->{default_branch}...$user_id:$default_branch") %>" class="btn btn-success">New pull request</a>
% } else {
<a href="<%= url_for("/$user_id/$project_id/compare") %>" class="btn btn-success">New pull request</a>
% }
</div>
% }
<div class="pulls">
<div class="pulls-header">
% if ($open) {
<b><%= $open_count %> Open</b>
<a href="<%= url_with->query([is => 'closed']) %>" style="margin-left:5px;color:#767676"><%= "\x{2714}" %><%= $close_count %> Closed</a>
% } else {
<a style="margin-left:5px;color:#767676" href="<%= url_with->query([is => undef]) %>"><%= $open_count %> Open</a>
<b>
<span style="margin-left:5px;color:#767676"><%= "\x{2714}" %><%= $close_count %> Closed</span>
</b>
% }
</div>
<div class="pulls-body">
% if (@$issues) {
<ul>
% for my $issue (@$issues) {
<%
my $target_branch = $issue->{'pull_request.target_branch'};
my $commit = app->git->get_commit(app->rep_info($user_id, $project_id), $target_branch);
my $open_time = $issue->{open_time};
my $open_time_age = Time::Moment->now->epoch - $open_time;
my $open_time_age_string = $self->app->git->_age_string($open_time_age);
%>
<li>
<div class="pulls-title">
<a href="<%= "/$user_id/$project_id/pull/$issue->{number}" %>">
<b><%= $issue->{title} %></b>
</a>
</div>
<div class="pulls-description">
#<%= $issue->{number} %> <%= $issue->{open} ? 'opened' : 'closed' %>
<%= $open_time_age_string %>
by <%= $issue->{'open_user.id'} %>
</div>
</li>
% }
</ul>
% } else {
<div class="pulls-no-request">
<div style="font-size:18px"><b>There aren’t any open pull requests.</b></div>
</div>
% }
</div>
</div>
</div>
%= include '/include/footer';