##// END OF EJS Templates
pull-requests: confirm close without merge
marcink -
r4054:c11100bc default
parent child Browse files
Show More
@@ -1,791 +1,794 b''
1 1 <%inherit file="/base/base.mako"/>
2 2 <%namespace name="base" file="/base/base.mako"/>
3 3 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
4 4
5 5 <%def name="title()">
6 6 ${_('{} Pull Request !{}').format(c.repo_name, c.pull_request.pull_request_id)}
7 7 %if c.rhodecode_name:
8 8 &middot; ${h.branding(c.rhodecode_name)}
9 9 %endif
10 10 </%def>
11 11
12 12 <%def name="breadcrumbs_links()">
13 13 <span id="pr-title">
14 14 ${c.pull_request.title}
15 15 %if c.pull_request.is_closed():
16 16 (${_('Closed')})
17 17 %endif
18 18 </span>
19 19 <div id="pr-title-edit" class="input" style="display: none;">
20 20 ${h.text('pullrequest_title', id_="pr-title-input", class_="large", value=c.pull_request.title)}
21 21 </div>
22 22 </%def>
23 23
24 24 <%def name="menu_bar_nav()">
25 25 ${self.menu_items(active='repositories')}
26 26 </%def>
27 27
28 28 <%def name="menu_bar_subnav()">
29 29 ${self.repo_menu(active='showpullrequest')}
30 30 </%def>
31 31
32 32 <%def name="main()">
33 33
34 34 <script type="text/javascript">
35 35 // TODO: marcink switch this to pyroutes
36 36 AJAX_COMMENT_DELETE_URL = "${h.route_path('pullrequest_comment_delete',repo_name=c.repo_name,pull_request_id=c.pull_request.pull_request_id,comment_id='__COMMENT_ID__')}";
37 37 templateContext.pull_request_data.pull_request_id = ${c.pull_request.pull_request_id};
38 38 </script>
39 39 <div class="box">
40 40
41 41 ${self.breadcrumbs()}
42 42
43 43 <div class="box pr-summary">
44 44
45 45 <div class="summary-details block-left">
46 46 <% summary = lambda n:{False:'summary-short'}.get(n) %>
47 47 <div class="pr-details-title">
48 48 <a href="${h.route_path('pull_requests_global', pull_request_id=c.pull_request.pull_request_id)}">${_('Pull request !{}').format(c.pull_request.pull_request_id)}</a> ${_('From')} ${h.format_date(c.pull_request.created_on)}
49 49 %if c.allowed_to_update:
50 50 <div id="delete_pullrequest" class="pull-right action_button ${'' if c.allowed_to_delete else 'disabled' }" style="clear:inherit;padding: 0">
51 51 % if c.allowed_to_delete:
52 52 ${h.secure_form(h.route_path('pullrequest_delete', repo_name=c.pull_request.target_repo.repo_name, pull_request_id=c.pull_request.pull_request_id), request=request)}
53 53 ${h.submit('remove_%s' % c.pull_request.pull_request_id, _('Delete'),
54 54 class_="btn btn-link btn-danger no-margin",onclick="return confirm('"+_('Confirm to delete this pull request')+"');")}
55 55 ${h.end_form()}
56 56 % else:
57 57 ${_('Delete')}
58 58 % endif
59 59 </div>
60 60 <div id="open_edit_pullrequest" class="pull-right action_button">${_('Edit')}</div>
61 61 <div id="close_edit_pullrequest" class="pull-right action_button" style="display: none;padding: 0">${_('Cancel')}</div>
62 62 %endif
63 63 </div>
64 64
65 65 <div id="summary" class="fields pr-details-content">
66 66 <div class="field">
67 67 <div class="label-summary">
68 68 <label>${_('Source')}:</label>
69 69 </div>
70 70 <div class="input">
71 71 <div class="pr-origininfo">
72 72 ## branch link is only valid if it is a branch
73 73 <span class="tag">
74 74 %if c.pull_request.source_ref_parts.type == 'branch':
75 75 <a href="${h.route_path('repo_commits', repo_name=c.pull_request.source_repo.repo_name, _query=dict(branch=c.pull_request.source_ref_parts.name))}">${c.pull_request.source_ref_parts.type}: ${c.pull_request.source_ref_parts.name}</a>
76 76 %else:
77 77 ${c.pull_request.source_ref_parts.type}: ${c.pull_request.source_ref_parts.name}
78 78 %endif
79 79 </span>
80 80 <span class="clone-url">
81 81 <a href="${h.route_path('repo_summary', repo_name=c.pull_request.source_repo.repo_name)}">${c.pull_request.source_repo.clone_url()}</a>
82 82 </span>
83 83 <br/>
84 84 % if c.ancestor_commit:
85 85 ${_('Common ancestor')}:
86 86 <code><a href="${h.route_path('repo_commit', repo_name=c.target_repo.repo_name, commit_id=c.ancestor_commit.raw_id)}">${h.show_id(c.ancestor_commit)}</a></code>
87 87 % endif
88 88 </div>
89 89 %if h.is_hg(c.pull_request.source_repo):
90 90 <% clone_url = 'hg pull -r {} {}'.format(h.short_id(c.source_ref), c.pull_request.source_repo.clone_url()) %>
91 91 %elif h.is_git(c.pull_request.source_repo):
92 92 <% clone_url = 'git pull {} {}'.format(c.pull_request.source_repo.clone_url(), c.pull_request.source_ref_parts.name) %>
93 93 %endif
94 94
95 95 <div class="">
96 96 <input type="text" class="input-monospace pr-pullinfo" value="${clone_url}" readonly="readonly">
97 97 <i class="tooltip icon-clipboard clipboard-action pull-right pr-pullinfo-copy" data-clipboard-text="${clone_url}" title="${_('Copy the pull url')}"></i>
98 98 </div>
99 99
100 100 </div>
101 101 </div>
102 102 <div class="field">
103 103 <div class="label-summary">
104 104 <label>${_('Target')}:</label>
105 105 </div>
106 106 <div class="input">
107 107 <div class="pr-targetinfo">
108 108 ## branch link is only valid if it is a branch
109 109 <span class="tag">
110 110 %if c.pull_request.target_ref_parts.type == 'branch':
111 111 <a href="${h.route_path('repo_commits', repo_name=c.pull_request.target_repo.repo_name, _query=dict(branch=c.pull_request.target_ref_parts.name))}">${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}</a>
112 112 %else:
113 113 ${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}
114 114 %endif
115 115 </span>
116 116 <span class="clone-url">
117 117 <a href="${h.route_path('repo_summary', repo_name=c.pull_request.target_repo.repo_name)}">${c.pull_request.target_repo.clone_url()}</a>
118 118 </span>
119 119 </div>
120 120 </div>
121 121 </div>
122 122
123 123 ## Link to the shadow repository.
124 124 <div class="field">
125 125 <div class="label-summary">
126 126 <label>${_('Merge')}:</label>
127 127 </div>
128 128 <div class="input">
129 129 % if not c.pull_request.is_closed() and c.pull_request.shadow_merge_ref:
130 130 %if h.is_hg(c.pull_request.target_repo):
131 131 <% clone_url = 'hg clone --update {} {} pull-request-{}'.format(c.pull_request.shadow_merge_ref.name, c.shadow_clone_url, c.pull_request.pull_request_id) %>
132 132 %elif h.is_git(c.pull_request.target_repo):
133 133 <% clone_url = 'git clone --branch {} {} pull-request-{}'.format(c.pull_request.shadow_merge_ref.name, c.shadow_clone_url, c.pull_request.pull_request_id) %>
134 134 %endif
135 135 <div class="">
136 136 <input type="text" class="input-monospace pr-mergeinfo" value="${clone_url}" readonly="readonly">
137 137 <i class="tooltip icon-clipboard clipboard-action pull-right pr-mergeinfo-copy" data-clipboard-text="${clone_url}" title="${_('Copy the clone url')}"></i>
138 138 </div>
139 139 % else:
140 140 <div class="">
141 141 ${_('Shadow repository data not available')}.
142 142 </div>
143 143 % endif
144 144 </div>
145 145 </div>
146 146
147 147 <div class="field">
148 148 <div class="label-summary">
149 149 <label>${_('Review')}:</label>
150 150 </div>
151 151 <div class="input">
152 152 %if c.pull_request_review_status:
153 153 <i class="icon-circle review-status-${c.pull_request_review_status}"></i>
154 154 <span class="changeset-status-lbl tooltip">
155 155 %if c.pull_request.is_closed():
156 156 ${_('Closed')},
157 157 %endif
158 158 ${h.commit_status_lbl(c.pull_request_review_status)}
159 159 </span>
160 160 - ${_ungettext('calculated based on %s reviewer vote', 'calculated based on %s reviewers votes', len(c.pull_request_reviewers)) % len(c.pull_request_reviewers)}
161 161 %endif
162 162 </div>
163 163 </div>
164 164 <div class="field">
165 165 <div class="pr-description-label label-summary" title="${_('Rendered using {} renderer').format(c.renderer)}">
166 166 <label>${_('Description')}:</label>
167 167 </div>
168 168 <div id="pr-desc" class="input">
169 169 <div class="pr-description">${h.render(c.pull_request.description, renderer=c.renderer, repo_name=c.repo_name)}</div>
170 170 </div>
171 171 <div id="pr-desc-edit" class="input textarea editor" style="display: none;">
172 172 <input id="pr-renderer-input" type="hidden" name="description_renderer" value="${c.visual.default_renderer}">
173 173 ${dt.markup_form('pr-description-input', form_text=c.pull_request.description)}
174 174 </div>
175 175 </div>
176 176
177 177 <div class="field">
178 178 <div class="label-summary">
179 179 <label>${_('Versions')}:</label>
180 180 </div>
181 181
182 182 <% outdated_comm_count_ver = len(c.inline_versions[None]['outdated']) %>
183 183 <% general_outdated_comm_count_ver = len(c.comment_versions[None]['outdated']) %>
184 184
185 185 <div class="pr-versions">
186 186 % if c.show_version_changes:
187 187 <% outdated_comm_count_ver = len(c.inline_versions[c.at_version_num]['outdated']) %>
188 188 <% general_outdated_comm_count_ver = len(c.comment_versions[c.at_version_num]['outdated']) %>
189 189 <a id="show-pr-versions" class="input" onclick="return versionController.toggleVersionView(this)" href="#show-pr-versions"
190 190 data-toggle-on="${_ungettext('{} version available for this pull request, show it.', '{} versions available for this pull request, show them.', len(c.versions)).format(len(c.versions))}"
191 191 data-toggle-off="${_('Hide all versions of this pull request')}">
192 192 ${_ungettext('{} version available for this pull request, show it.', '{} versions available for this pull request, show them.', len(c.versions)).format(len(c.versions))}
193 193 </a>
194 194 <table>
195 195 ## SHOW ALL VERSIONS OF PR
196 196 <% ver_pr = None %>
197 197
198 198 % for data in reversed(list(enumerate(c.versions, 1))):
199 199 <% ver_pos = data[0] %>
200 200 <% ver = data[1] %>
201 201 <% ver_pr = ver.pull_request_version_id %>
202 202 <% display_row = '' if c.at_version and (c.at_version_num == ver_pr or c.from_version_num == ver_pr) else 'none' %>
203 203
204 204 <tr class="version-pr" style="display: ${display_row}">
205 205 <td>
206 206 <code>
207 207 <a href="${request.current_route_path(_query=dict(version=ver_pr or 'latest'))}">v${ver_pos}</a>
208 208 </code>
209 209 </td>
210 210 <td>
211 211 <input ${'checked="checked"' if c.from_version_num == ver_pr else ''} class="compare-radio-button" type="radio" name="ver_source" value="${ver_pr or 'latest'}" data-ver-pos="${ver_pos}"/>
212 212 <input ${'checked="checked"' if c.at_version_num == ver_pr else ''} class="compare-radio-button" type="radio" name="ver_target" value="${ver_pr or 'latest'}" data-ver-pos="${ver_pos}"/>
213 213 </td>
214 214 <td>
215 215 <% review_status = c.review_versions[ver_pr].status if ver_pr in c.review_versions else 'not_reviewed' %>
216 216 <i class="tooltip icon-circle review-status-${review_status}" title="${_('Your review status at this version')}"></i>
217 217 </div>
218 218 </td>
219 219 <td>
220 220 % if c.at_version_num != ver_pr:
221 221 <i class="icon-comment"></i>
222 222 <code class="tooltip" title="${_('Comment from pull request version v{0}, general:{1} inline:{2}').format(ver_pos, len(c.comment_versions[ver_pr]['at']), len(c.inline_versions[ver_pr]['at']))}">
223 223 G:${len(c.comment_versions[ver_pr]['at'])} / I:${len(c.inline_versions[ver_pr]['at'])}
224 224 </code>
225 225 % endif
226 226 </td>
227 227 <td>
228 228 ##<code>${ver.source_ref_parts.commit_id[:6]}</code>
229 229 </td>
230 230 <td>
231 231 ${h.age_component(ver.updated_on, time_is_local=True)}
232 232 </td>
233 233 </tr>
234 234 % endfor
235 235
236 236 <tr>
237 237 <td colspan="6">
238 238 <button id="show-version-diff" onclick="return versionController.showVersionDiff()" class="btn btn-sm" style="display: none"
239 239 data-label-text-locked="${_('select versions to show changes')}"
240 240 data-label-text-diff="${_('show changes between versions')}"
241 241 data-label-text-show="${_('show pull request for this version')}"
242 242 >
243 243 ${_('select versions to show changes')}
244 244 </button>
245 245 </td>
246 246 </tr>
247 247 </table>
248 248 % else:
249 249 <div class="input">
250 250 ${_('Pull request versions not available')}.
251 251 </div>
252 252 % endif
253 253 </div>
254 254 </div>
255 255
256 256 <div id="pr-save" class="field" style="display: none;">
257 257 <div class="label-summary"></div>
258 258 <div class="input">
259 259 <span id="edit_pull_request" class="btn btn-small no-margin">${_('Save Changes')}</span>
260 260 </div>
261 261 </div>
262 262 </div>
263 263 </div>
264 264 <div>
265 265 ## AUTHOR
266 266 <div class="reviewers-title block-right">
267 267 <div class="pr-details-title">
268 268 ${_('Author of this pull request')}
269 269 </div>
270 270 </div>
271 271 <div class="block-right pr-details-content reviewers">
272 272 <ul class="group_members">
273 273 <li>
274 274 ${self.gravatar_with_user(c.pull_request.author.email, 16, tooltip=True)}
275 275 </li>
276 276 </ul>
277 277 </div>
278 278
279 279 ## REVIEW RULES
280 280 <div id="review_rules" style="display: none" class="reviewers-title block-right">
281 281 <div class="pr-details-title">
282 282 ${_('Reviewer rules')}
283 283 %if c.allowed_to_update:
284 284 <span id="close_edit_reviewers" class="block-right action_button last-item" style="display: none;">${_('Close')}</span>
285 285 %endif
286 286 </div>
287 287 <div class="pr-reviewer-rules">
288 288 ## review rules will be appended here, by default reviewers logic
289 289 </div>
290 290 <input id="review_data" type="hidden" name="review_data" value="">
291 291 </div>
292 292
293 293 ## REVIEWERS
294 294 <div class="reviewers-title block-right">
295 295 <div class="pr-details-title">
296 296 ${_('Pull request reviewers')}
297 297 %if c.allowed_to_update:
298 298 <span id="open_edit_reviewers" class="block-right action_button last-item">${_('Edit')}</span>
299 299 %endif
300 300 </div>
301 301 </div>
302 302 <div id="reviewers" class="block-right pr-details-content reviewers">
303 303
304 304 ## members redering block
305 305 <input type="hidden" name="__start__" value="review_members:sequence">
306 306 <ul id="review_members" class="group_members">
307 307
308 308 % for review_obj, member, reasons, mandatory, status in c.pull_request_reviewers:
309 309 <script>
310 310 var member = ${h.json.dumps(h.reviewer_as_json(member, reasons=reasons, mandatory=mandatory, user_group=review_obj.rule_user_group_data()))|n};
311 311 var status = "${(status[0][1].status if status else 'not_reviewed')}";
312 312 var status_lbl = "${h.commit_status_lbl(status[0][1].status if status else 'not_reviewed')}";
313 313 var allowed_to_update = ${h.json.dumps(c.allowed_to_update)};
314 314
315 315 var entry = renderTemplate('reviewMemberEntry', {
316 316 'member': member,
317 317 'mandatory': member.mandatory,
318 318 'reasons': member.reasons,
319 319 'allowed_to_update': allowed_to_update,
320 320 'review_status': status,
321 321 'review_status_label': status_lbl,
322 322 'user_group': member.user_group,
323 323 'create': false
324 324 });
325 325 $('#review_members').append(entry)
326 326 </script>
327 327
328 328 % endfor
329 329
330 330 </ul>
331 331
332 332 <input type="hidden" name="__end__" value="review_members:sequence">
333 333 ## end members redering block
334 334
335 335 %if not c.pull_request.is_closed():
336 336 <div id="add_reviewer" class="ac" style="display: none;">
337 337 %if c.allowed_to_update:
338 338 % if not c.forbid_adding_reviewers:
339 339 <div id="add_reviewer_input" class="reviewer_ac">
340 340 ${h.text('user', class_='ac-input', placeholder=_('Add reviewer or reviewer group'))}
341 341 <div id="reviewers_container"></div>
342 342 </div>
343 343 % endif
344 344 <div class="pull-right">
345 345 <button id="update_pull_request" class="btn btn-small no-margin">${_('Save Changes')}</button>
346 346 </div>
347 347 %endif
348 348 </div>
349 349 %endif
350 350 </div>
351 351 </div>
352 352 </div>
353 353 <div class="box">
354 354 ##DIFF
355 355 <div class="table" >
356 356 <div id="changeset_compare_view_content">
357 357 ##CS
358 358 % if c.missing_requirements:
359 359 <div class="box">
360 360 <div class="alert alert-warning">
361 361 <div>
362 362 <strong>${_('Missing requirements:')}</strong>
363 363 ${_('These commits cannot be displayed, because this repository uses the Mercurial largefiles extension, which was not enabled.')}
364 364 </div>
365 365 </div>
366 366 </div>
367 367 % elif c.missing_commits:
368 368 <div class="box">
369 369 <div class="alert alert-warning">
370 370 <div>
371 371 <strong>${_('Missing commits')}:</strong>
372 372 ${_('This pull request cannot be displayed, because one or more commits no longer exist in the source repository.')}
373 373 ${_('Please update this pull request, push the commits back into the source repository, or consider closing this pull request.')}
374 374 ${_('Consider doing a {force_refresh_url} in case you think this is an error.').format(force_refresh_url=h.link_to('force refresh', h.current_route_path(request, force_refresh='1')))|n}
375 375 </div>
376 376 </div>
377 377 </div>
378 378 % endif
379 379
380 380 <div class="compare_view_commits_title">
381 381 % if not c.compare_mode:
382 382
383 383 % if c.at_version_pos:
384 384 <h4>
385 385 ${_('Showing changes at v%d, commenting is disabled.') % c.at_version_pos}
386 386 </h4>
387 387 % endif
388 388
389 389 <div class="pull-left">
390 390 <div class="btn-group">
391 391 <a
392 392 class="btn"
393 393 href="#"
394 394 onclick="$('.compare_select').show();$('.compare_select_hidden').hide(); return false">
395 395 ${_ungettext('Expand %s commit','Expand %s commits', len(c.commit_ranges)) % len(c.commit_ranges)}
396 396 </a>
397 397 <a
398 398 class="btn"
399 399 href="#"
400 400 onclick="$('.compare_select').hide();$('.compare_select_hidden').show(); return false">
401 401 ${_ungettext('Collapse %s commit','Collapse %s commits', len(c.commit_ranges)) % len(c.commit_ranges)}
402 402 </a>
403 403 </div>
404 404 </div>
405 405
406 406 <div class="pull-right">
407 407 % if c.allowed_to_update and not c.pull_request.is_closed():
408 408 <a id="update_commits" class="btn btn-primary no-margin pull-right">${_('Update commits')}</a>
409 409 % else:
410 410 <a class="tooltip btn disabled pull-right" disabled="disabled" title="${_('Update is disabled for current view')}">${_('Update commits')}</a>
411 411 % endif
412 412
413 413 </div>
414 414 % endif
415 415 </div>
416 416
417 417 % if not c.missing_commits:
418 418 % if c.compare_mode:
419 419 % if c.at_version:
420 420 <h4>
421 421 ${_('Commits and changes between v{ver_from} and {ver_to} of this pull request, commenting is disabled').format(ver_from=c.from_version_pos, ver_to=c.at_version_pos if c.at_version_pos else 'latest')}:
422 422 </h4>
423 423
424 424 <div class="subtitle-compare">
425 425 ${_('commits added: {}, removed: {}').format(len(c.commit_changes_summary.added), len(c.commit_changes_summary.removed))}
426 426 </div>
427 427
428 428 <div class="container">
429 429 <table class="rctable compare_view_commits">
430 430 <tr>
431 431 <th></th>
432 432 <th>${_('Time')}</th>
433 433 <th>${_('Author')}</th>
434 434 <th>${_('Commit')}</th>
435 435 <th></th>
436 436 <th>${_('Description')}</th>
437 437 </tr>
438 438
439 439 % for c_type, commit in c.commit_changes:
440 440 % if c_type in ['a', 'r']:
441 441 <%
442 442 if c_type == 'a':
443 443 cc_title = _('Commit added in displayed changes')
444 444 elif c_type == 'r':
445 445 cc_title = _('Commit removed in displayed changes')
446 446 else:
447 447 cc_title = ''
448 448 %>
449 449 <tr id="row-${commit.raw_id}" commit_id="${commit.raw_id}" class="compare_select">
450 450 <td>
451 451 <div class="commit-change-indicator color-${c_type}-border">
452 452 <div class="commit-change-content color-${c_type} tooltip" title="${h.tooltip(cc_title)}">
453 453 ${c_type.upper()}
454 454 </div>
455 455 </div>
456 456 </td>
457 457 <td class="td-time">
458 458 ${h.age_component(commit.date)}
459 459 </td>
460 460 <td class="td-user">
461 461 ${base.gravatar_with_user(commit.author, 16, tooltip=True)}
462 462 </td>
463 463 <td class="td-hash">
464 464 <code>
465 465 <a href="${h.route_path('repo_commit', repo_name=c.target_repo.repo_name, commit_id=commit.raw_id)}">
466 466 r${commit.idx}:${h.short_id(commit.raw_id)}
467 467 </a>
468 468 ${h.hidden('revisions', commit.raw_id)}
469 469 </code>
470 470 </td>
471 471 <td class="td-message expand_commit" data-commit-id="${commit.raw_id}" title="${_( 'Expand commit message')}" onclick="commitsController.expandCommit(this); return false">
472 472 <i class="icon-expand-linked"></i>
473 473 </td>
474 474 <td class="mid td-description">
475 475 <div class="log-container truncate-wrap">
476 476 <div class="message truncate" id="c-${commit.raw_id}" data-message-raw="${commit.message}">${h.urlify_commit_message(commit.message, c.repo_name)}</div>
477 477 </div>
478 478 </td>
479 479 </tr>
480 480 % endif
481 481 % endfor
482 482 </table>
483 483 </div>
484 484
485 485 % endif
486 486
487 487 % else:
488 488 <%include file="/compare/compare_commits.mako" />
489 489 % endif
490 490
491 491 <div class="cs_files">
492 492 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
493 493 % if c.at_version:
494 494 <% c.inline_cnt = len(c.inline_versions[c.at_version_num]['display']) %>
495 495 <% c.comments = c.comment_versions[c.at_version_num]['display'] %>
496 496 % else:
497 497 <% c.inline_cnt = len(c.inline_versions[c.at_version_num]['until']) %>
498 498 <% c.comments = c.comment_versions[c.at_version_num]['until'] %>
499 499 % endif
500 500
501 501 <%
502 502 pr_menu_data = {
503 503 'outdated_comm_count_ver': outdated_comm_count_ver
504 504 }
505 505 %>
506 506
507 507 ${cbdiffs.render_diffset_menu(c.diffset, range_diff_on=c.range_diff_on)}
508 508
509 509 % if c.range_diff_on:
510 510 % for commit in c.commit_ranges:
511 511 ${cbdiffs.render_diffset(
512 512 c.changes[commit.raw_id],
513 513 commit=commit, use_comments=True,
514 514 collapse_when_files_over=5,
515 515 disable_new_comments=True,
516 516 deleted_files_comments=c.deleted_files_comments,
517 517 inline_comments=c.inline_comments,
518 518 pull_request_menu=pr_menu_data)}
519 519 % endfor
520 520 % else:
521 521 ${cbdiffs.render_diffset(
522 522 c.diffset, use_comments=True,
523 523 collapse_when_files_over=30,
524 524 disable_new_comments=not c.allowed_to_comment,
525 525 deleted_files_comments=c.deleted_files_comments,
526 526 inline_comments=c.inline_comments,
527 527 pull_request_menu=pr_menu_data)}
528 528 % endif
529 529
530 530 </div>
531 531 % else:
532 532 ## skipping commits we need to clear the view for missing commits
533 533 <div style="clear:both;"></div>
534 534 % endif
535 535
536 536 </div>
537 537 </div>
538 538
539 539 ## template for inline comment form
540 540 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
541 541
542 542 ## comments heading with count
543 543 <div class="comments-heading">
544 544 <i class="icon-comment"></i>
545 545 ${_('Comments')} ${len(c.comments)}
546 546 </div>
547 547
548 548 ## render general comments
549 549 <div id="comment-tr-show">
550 550 % if general_outdated_comm_count_ver:
551 551 <div class="info-box">
552 552 % if general_outdated_comm_count_ver == 1:
553 553 ${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)},
554 554 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show it')}</a>
555 555 % else:
556 556 ${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)},
557 557 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show them')}</a>
558 558 % endif
559 559 </div>
560 560 % endif
561 561 </div>
562 562
563 563 ${comment.generate_comments(c.comments, include_pull_request=True, is_pull_request=True)}
564 564
565 565 % if not c.pull_request.is_closed():
566 566 ## main comment form and it status
567 567 ${comment.comments(h.route_path('pullrequest_comment_create', repo_name=c.repo_name,
568 568 pull_request_id=c.pull_request.pull_request_id),
569 569 c.pull_request_review_status,
570 570 is_pull_request=True, change_status=c.allowed_to_change_status)}
571 571
572 572 ## merge status, and merge action
573 573 <div class="pull-request-merge">
574 574 <%include file="/pullrequests/pullrequest_merge_checks.mako"/>
575 575 </div>
576 576
577 577 %endif
578 578
579 579 <script type="text/javascript">
580 580
581 581 versionController = new VersionController();
582 582 versionController.init();
583 583
584 584 reviewersController = new ReviewersController();
585 585 commitsController = new CommitsController();
586 586
587 587 $(function(){
588 588
589 589 // custom code mirror
590 590 var codeMirrorInstance = $('#pr-description-input').get(0).MarkupForm.cm;
591 591
592 592 var PRDetails = {
593 593 editButton: $('#open_edit_pullrequest'),
594 594 closeButton: $('#close_edit_pullrequest'),
595 595 deleteButton: $('#delete_pullrequest'),
596 596 viewFields: $('#pr-desc, #pr-title'),
597 597 editFields: $('#pr-desc-edit, #pr-title-edit, #pr-save'),
598 598
599 599 init: function() {
600 600 var that = this;
601 601 this.editButton.on('click', function(e) { that.edit(); });
602 602 this.closeButton.on('click', function(e) { that.view(); });
603 603 },
604 604
605 605 edit: function(event) {
606 606 this.viewFields.hide();
607 607 this.editButton.hide();
608 608 this.deleteButton.hide();
609 609 this.closeButton.show();
610 610 this.editFields.show();
611 611 codeMirrorInstance.refresh();
612 612 },
613 613
614 614 view: function(event) {
615 615 this.editButton.show();
616 616 this.deleteButton.show();
617 617 this.editFields.hide();
618 618 this.closeButton.hide();
619 619 this.viewFields.show();
620 620 }
621 621 };
622 622
623 623 var ReviewersPanel = {
624 624 editButton: $('#open_edit_reviewers'),
625 625 closeButton: $('#close_edit_reviewers'),
626 626 addButton: $('#add_reviewer'),
627 627 removeButtons: $('.reviewer_member_remove,.reviewer_member_mandatory_remove'),
628 628
629 629 init: function() {
630 630 var self = this;
631 631 this.editButton.on('click', function(e) { self.edit(); });
632 632 this.closeButton.on('click', function(e) { self.close(); });
633 633 },
634 634
635 635 edit: function(event) {
636 636 this.editButton.hide();
637 637 this.closeButton.show();
638 638 this.addButton.show();
639 639 this.removeButtons.css('visibility', 'visible');
640 640 // review rules
641 641 reviewersController.loadReviewRules(
642 642 ${c.pull_request.reviewer_data_json | n});
643 643 },
644 644
645 645 close: function(event) {
646 646 this.editButton.show();
647 647 this.closeButton.hide();
648 648 this.addButton.hide();
649 649 this.removeButtons.css('visibility', 'hidden');
650 650 // hide review rules
651 651 reviewersController.hideReviewRules()
652 652 }
653 653 };
654 654
655 655 PRDetails.init();
656 656 ReviewersPanel.init();
657 657
658 658 showOutdated = function(self){
659 659 $('.comment-inline.comment-outdated').show();
660 660 $('.filediff-outdated').show();
661 661 $('.showOutdatedComments').hide();
662 662 $('.hideOutdatedComments').show();
663 663 };
664 664
665 665 hideOutdated = function(self){
666 666 $('.comment-inline.comment-outdated').hide();
667 667 $('.filediff-outdated').hide();
668 668 $('.hideOutdatedComments').hide();
669 669 $('.showOutdatedComments').show();
670 670 };
671 671
672 672 refreshMergeChecks = function(){
673 673 var loadUrl = "${request.current_route_path(_query=dict(merge_checks=1))}";
674 674 $('.pull-request-merge').css('opacity', 0.3);
675 675 $('.action-buttons-extra').css('opacity', 0.3);
676 676
677 677 $('.pull-request-merge').load(
678 678 loadUrl, function() {
679 679 $('.pull-request-merge').css('opacity', 1);
680 680
681 681 $('.action-buttons-extra').css('opacity', 1);
682 682 }
683 683 );
684 684 };
685 685
686 686 closePullRequest = function (status) {
687 if (!confirm(_gettext('Are you sure to close this pull request without merging?'))) {
688 return false;
689 }
687 690 // inject closing flag
688 691 $('.action-buttons-extra').append('<input type="hidden" class="close-pr-input" id="close_pull_request" value="1">');
689 692 $(generalCommentForm.statusChange).select2("val", status).trigger('change');
690 693 $(generalCommentForm.submitForm).submit();
691 694 };
692 695
693 696 $('#show-outdated-comments').on('click', function(e){
694 697 var button = $(this);
695 698 var outdated = $('.comment-outdated');
696 699
697 700 if (button.html() === "(Show)") {
698 701 button.html("(Hide)");
699 702 outdated.show();
700 703 } else {
701 704 button.html("(Show)");
702 705 outdated.hide();
703 706 }
704 707 });
705 708
706 709 $('.show-inline-comments').on('change', function(e){
707 710 var show = 'none';
708 711 var target = e.currentTarget;
709 712 if(target.checked){
710 713 show = ''
711 714 }
712 715 var boxid = $(target).attr('id_for');
713 716 var comments = $('#{0} .inline-comments'.format(boxid));
714 717 var fn_display = function(idx){
715 718 $(this).css('display', show);
716 719 };
717 720 $(comments).each(fn_display);
718 721 var btns = $('#{0} .inline-comments-button'.format(boxid));
719 722 $(btns).each(fn_display);
720 723 });
721 724
722 725 $('#merge_pull_request_form').submit(function() {
723 726 if (!$('#merge_pull_request').attr('disabled')) {
724 727 $('#merge_pull_request').attr('disabled', 'disabled');
725 728 }
726 729 return true;
727 730 });
728 731
729 732 $('#edit_pull_request').on('click', function(e){
730 733 var title = $('#pr-title-input').val();
731 734 var description = codeMirrorInstance.getValue();
732 735 var renderer = $('#pr-renderer-input').val();
733 736 editPullRequest(
734 737 "${c.repo_name}", "${c.pull_request.pull_request_id}",
735 738 title, description, renderer);
736 739 });
737 740
738 741 $('#update_pull_request').on('click', function(e){
739 742 $(this).attr('disabled', 'disabled');
740 743 $(this).addClass('disabled');
741 744 $(this).html(_gettext('Saving...'));
742 745 reviewersController.updateReviewers(
743 746 "${c.repo_name}", "${c.pull_request.pull_request_id}");
744 747 });
745 748
746 749 $('#update_commits').on('click', function(e){
747 750 var isDisabled = !$(e.currentTarget).attr('disabled');
748 751 $(e.currentTarget).attr('disabled', 'disabled');
749 752 $(e.currentTarget).addClass('disabled');
750 753 $(e.currentTarget).removeClass('btn-primary');
751 754 $(e.currentTarget).text(_gettext('Updating...'));
752 755 if(isDisabled){
753 756 updateCommits(
754 757 "${c.repo_name}", "${c.pull_request.pull_request_id}");
755 758 }
756 759 });
757 760 // fixing issue with caches on firefox
758 761 $('#update_commits').removeAttr("disabled");
759 762
760 763 $('.show-inline-comments').on('click', function(e){
761 764 var boxid = $(this).attr('data-comment-id');
762 765 var button = $(this);
763 766
764 767 if(button.hasClass("comments-visible")) {
765 768 $('#{0} .inline-comments'.format(boxid)).each(function(index){
766 769 $(this).hide();
767 770 });
768 771 button.removeClass("comments-visible");
769 772 } else {
770 773 $('#{0} .inline-comments'.format(boxid)).each(function(index){
771 774 $(this).show();
772 775 });
773 776 button.addClass("comments-visible");
774 777 }
775 778 });
776 779
777 780 // register submit callback on commentForm form to track TODOs
778 781 window.commentFormGlobalSubmitSuccessCallback = function(){
779 782 refreshMergeChecks();
780 783 };
781 784
782 785 ReviewerAutoComplete('#user');
783 786
784 787 })
785 788
786 789 </script>
787 790
788 791 </div>
789 792 </div>
790 793
791 794 </%def>
General Comments 0
You need to be logged in to leave comments. Login now