... | ... |
@@ -205,7 +205,9 @@ sub startup { |
205 | 205 |
table => 'pull_request', |
206 | 206 |
primary_key => 'row_id', |
207 | 207 |
join => [ |
208 |
- 'left join user on pull_request.open_user = user.row_id' |
|
208 |
+ 'left join user on pull_request.open_user = user.row_id', |
|
209 |
+ 'left join project on pull_request.project = project.row_id', |
|
210 |
+ 'left join user as project_user on project.user = project_user.row_id' |
|
209 | 211 |
] |
210 | 212 |
}, |
211 | 213 |
{ |
... | ... |
@@ -35,6 +35,20 @@ |
35 | 35 |
box-sizing: border-box; |
36 | 36 |
} |
37 | 37 |
|
38 |
+.branches-open { |
|
39 |
+ color:white; |
|
40 |
+ background:#6cc644; |
|
41 |
+ padding:5px 8px; |
|
42 |
+ border-radius:3px; |
|
43 |
+ margin-right:4px; |
|
44 |
+ border-radius:3px; |
|
45 |
+ text-align:center; |
|
46 |
+} |
|
47 |
+.branches-open:hover { |
|
48 |
+ color:white; |
|
49 |
+ text-decoration:none; |
|
50 |
+} |
|
51 |
+ |
|
38 | 52 |
.pull-comment { |
39 | 53 |
border:1px solid #eee; |
40 | 54 |
margin-top:15px; |
... | ... |
@@ -4,8 +4,8 @@ |
4 | 4 |
my $api = gitprep_api; |
5 | 5 |
|
6 | 6 |
# Parameters |
7 |
- my $user = param('user'); |
|
8 |
- my $project = param('project'); |
|
7 |
+ my $user_id = param('user'); |
|
8 |
+ my $project_id = param('project'); |
|
9 | 9 |
my $op = param('op') || ''; |
10 | 10 |
my $display = param('display') || 'overview'; |
11 | 11 |
my $page = param('page') || 1; |
... | ... |
@@ -18,7 +18,7 @@ |
18 | 18 |
if ($op eq 'delete' && lc $self->req->method eq 'post') { |
19 | 19 |
|
20 | 20 |
# Forbbiden |
21 |
- unless ($api->logined($user)) { |
|
21 |
+ unless ($api->logined($user_id)) { |
|
22 | 22 |
$self->redirect_to('/'); |
23 | 23 |
return; |
24 | 24 |
} |
... | ... |
@@ -39,7 +39,7 @@ |
39 | 39 |
|
40 | 40 |
if ($validation->is_valid) { |
41 | 41 |
# Delete branch |
42 |
- eval { $git->delete_branch(app->rep_info($user, $project), $branch) }; |
|
42 |
+ eval { $git->delete_branch(app->rep_info($user_id, $project_id), $branch) }; |
|
43 | 43 |
if (my $e = $@) { |
44 | 44 |
app->log->error(url_with . ": $e"); |
45 | 45 |
$errors = ['Internal Error']; |
... | ... |
@@ -54,8 +54,8 @@ |
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
# Default branch |
57 |
- my $default_branch_name = app->manager->default_branch($user, $project); |
|
58 |
- my $default_branch = $git->branch($self->app->rep_info($user, $project), $default_branch_name); |
|
57 |
+ my $default_branch_name = app->manager->default_branch($user_id, $project_id); |
|
58 |
+ my $default_branch = $git->branch($self->app->rep_info($user_id, $project_id), $default_branch_name); |
|
59 | 59 |
|
60 | 60 |
# Branches |
61 | 61 |
my $branch_types; |
... | ... |
@@ -70,14 +70,14 @@ |
70 | 70 |
my $page_count = 20; |
71 | 71 |
my $skip = $page_count * ($page - 1); |
72 | 72 |
|
73 |
- my $branches = $git->branches($self->app->rep_info($user, $project)); |
|
73 |
+ my $branches = $git->branches($self->app->rep_info($user_id, $project_id)); |
|
74 | 74 |
my $max = 0; |
75 | 75 |
my $active_count = 0; |
76 | 76 |
my $stale_count = 0; |
77 | 77 |
my $all_count = 0; |
78 | 78 |
for my $branch (@$branches) { |
79 | 79 |
$branch->{status} = $git->branch_status( |
80 |
- $self->app->rep_info($user, $project), |
|
80 |
+ $self->app->rep_info($user_id, $project_id), |
|
81 | 81 |
$default_branch->{name}, |
82 | 82 |
$branch->{name} |
83 | 83 |
); |
... | ... |
@@ -147,7 +147,7 @@ |
147 | 147 |
|
148 | 148 |
%> |
149 | 149 |
|
150 |
-% layout 'common', title => "branches \x{30fb} $user/$project"; |
|
150 |
+% layout 'common', title => "branches \x{30fb} $user_id/$project_id"; |
|
151 | 151 |
|
152 | 152 |
%= include '/include/header'; |
153 | 153 |
|
... | ... |
@@ -159,16 +159,16 @@ |
159 | 159 |
|
160 | 160 |
<ul class="branches-select"> |
161 | 161 |
<li class="<%= $display eq 'overview' ? 'active' : '' %>"> |
162 |
- <a href="<%= url_for("/$user/$project/branches") %>">Overview</a> |
|
162 |
+ <a href="<%= url_for("/$user_id/$project_id/branches") %>">Overview</a> |
|
163 | 163 |
</li> |
164 | 164 |
<li class="<%= $display eq 'active' ? 'active' : '' %>"> |
165 |
- <a href="<%= url_for("/$user/$project/branches/active") %>">Active</a> |
|
165 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/active") %>">Active</a> |
|
166 | 166 |
</li> |
167 | 167 |
<li class="<%= $display eq 'stale' ? 'active' : '' %>"> |
168 |
- <a href="<%= url_for("/$user/$project/branches/stale") %>">Stale</a> |
|
168 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/stale") %>">Stale</a> |
|
169 | 169 |
</li> |
170 | 170 |
<li class="<%= $display eq 'all' ? 'active' : '' %>"> |
171 |
- <a href="<%= url_for("/$user/$project/branches/all") %>">All branches</a> |
|
171 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/all") %>">All branches</a> |
|
172 | 172 |
</li> |
173 | 173 |
</ul> |
174 | 174 |
<% |
... | ... |
@@ -207,18 +207,27 @@ |
207 | 207 |
% for (my $i = 0; $i < @$branches; $i++) { |
208 | 208 |
<% |
209 | 209 |
my $branch = $branches->[$i]; |
210 |
- my $bname = $branch->{name}; |
|
210 |
+ my $branch_name = $branch->{name}; |
|
211 | 211 |
|
212 | 212 |
my $commit_author_email = $branch->{commit}{author_email}; |
213 | 213 |
my $commit_author_id = app->dbi->model('user')->select( |
214 | 214 |
'id', |
215 | 215 |
where => {email => $commit_author_email} |
216 | 216 |
)->value; |
217 |
- |
|
217 |
+ |
|
218 |
+ my $pull_request = app->dbi->model('pull_request')->select( |
|
219 |
+ {__MY__ => ['row_id', 'open']}, |
|
220 |
+ where => { |
|
221 |
+ 'project.id' => $project_id, |
|
222 |
+ 'project_user.id' => $user_id, |
|
223 |
+ branch1 => $default_branch_name, |
|
224 |
+ branch2 => $branch_name |
|
225 |
+ } |
|
226 |
+ )->one; |
|
218 | 227 |
%> |
219 | 228 |
% if ($display eq 'overview' && $i > 4) { |
220 | 229 |
<li class="branches-overview-more"> |
221 |
- <a href="<%= url_for("/$user/$project/branches/$branch_type") %>"> |
|
230 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/$branch_type") %>"> |
|
222 | 231 |
View more <%= $branch_type %> branches |
223 | 232 |
</a> |
224 | 233 |
</li> |
... | ... |
@@ -229,8 +238,8 @@ |
229 | 238 |
<ul> |
230 | 239 |
<li> |
231 | 240 |
<div class="branches-name"> |
232 |
- <a href="<%= url_for("/$user/$project/tree/$bname") %>"> |
|
233 |
- <%= $bname %> |
|
241 |
+ <a href="<%= url_for("/$user_id/$project_id/tree/$branch_name") %>"> |
|
242 |
+ <%= $branch_name %> |
|
234 | 243 |
</a> |
235 | 244 |
</div> |
236 | 245 |
<div class="branches-age" title="<%= $branch->{commit}{age_string_datetime_local} %>"> |
... | ... |
@@ -245,7 +254,7 @@ |
245 | 254 |
</div> |
246 | 255 |
</li> |
247 | 256 |
<li class="second-child"> |
248 |
- % if ($bname eq $default_branch_name) { |
|
257 |
+ % if ($branch_name eq $default_branch_name) { |
|
249 | 258 |
<div style="padding-left:80px;padding-top:3px"> |
250 | 259 |
<div class="branches-default"> |
251 | 260 |
Default |
... | ... |
@@ -277,23 +286,40 @@ |
277 | 286 |
% } |
278 | 287 |
</li> |
279 | 288 |
<li class="last-child"> |
280 |
- % if ($bname eq $default_branch_name) { |
|
281 |
- % if ($api->logined($user)) { |
|
282 |
- <a href="<%= url_for("/$user/$project/settings#form-default-branch") %>" type="submit" class="btn btn-small">Change default branch</a> |
|
289 |
+ % if ($branch_name eq $default_branch_name) { |
|
290 |
+ % if ($api->logined($user_id)) { |
|
291 |
+ <a href="<%= url_for("/$user_id/$project_id/settings#form-default-branch") %>" type="submit" class="btn btn-small">Change default branch</a> |
|
283 | 292 |
% } |
284 | 293 |
% } else { |
285 |
- <a class="btn btn-small" href="<%= url_for("/$user/$project/compare/$bname")->query(expand => 1) %>"> |
|
286 |
- % if ($api->logined) { |
|
287 |
- New pull request |
|
294 |
+ % if ($api->logined) { |
|
295 |
+ % if ($pull_request) { |
|
296 |
+ % if ($pull_request->{open}) { |
|
297 |
+ #<%= $pull_request->{row_id} %> |
|
298 |
+ <a class="branches-open" href="<%= url_for("/$user/$project/pull/$pull_request->{row_id}") %>"> |
|
299 |
+ open |
|
300 |
+ </a> |
|
301 |
+ % } else { |
|
302 |
+ closed |
|
303 |
+ % } |
|
288 | 304 |
% } else { |
305 |
+ <a class="btn btn-small" href="<%= url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1) %>"> |
|
306 |
+ New pull request |
|
307 |
+ </a> |
|
308 |
+ % } |
|
309 |
+ % } else { |
|
310 |
+ <a class="btn btn-small" href="<%= url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1) %>"> |
|
289 | 311 |
Compare |
312 |
+ </a> |
|
313 |
+ % } |
|
314 |
+ % if ($api->logined($user_id)) { |
|
315 |
+ % if ($pull_request && $pull_request->{open}) { |
|
316 |
+ <button class="btn btn-small disabled delete-branch"value="Delete">Delete</button> |
|
317 |
+ % } else { |
|
318 |
+ <form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block"> |
|
319 |
+ <input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete"> |
|
320 |
+ %= hidden_field branch => $branch_name; |
|
321 |
+ </form> |
|
290 | 322 |
% } |
291 |
- </a> |
|
292 |
- % if ($api->logined($user)) { |
|
293 |
- <form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block"> |
|
294 |
- <input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete"> |
|
295 |
- %= hidden_field branch => $bname; |
|
296 |
- </form> |
|
297 | 323 |
% } |
298 | 324 |
% } |
299 | 325 |
</li> |
... | ... |
@@ -312,7 +338,7 @@ |
312 | 338 |
% } else { |
313 | 339 |
% my $newer_page = $page - 1; |
314 | 340 |
<li> |
315 |
- <a href="<%= url_for("/$user/$project/branches/$display?page=$newer_page") %>">Newer</a> |
|
341 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$newer_page") %>">Newer</a> |
|
316 | 342 |
</li> |
317 | 343 |
% } |
318 | 344 |
% if ($branches_count < $page_count) { |
... | ... |
@@ -320,7 +346,7 @@ |
320 | 346 |
% } else { |
321 | 347 |
% my $older_page = $page + 1; |
322 | 348 |
<li> |
323 |
- <a href="<%= url_for("/$user/$project/branches/$display?page=$older_page") %>">Older</a> |
|
349 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$older_page") %>">Older</a> |
|
324 | 350 |
</li> |
325 | 351 |
% } |
326 | 352 |
</ul> |