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