##// END OF EJS Templates
ux: fix show inline comments link
dan -
r1185:2123e47c default
parent child Browse files
Show More
@@ -1,511 +1,511 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%def name="title()">
4 4 ${_('%s Pull Request #%s') % (c.repo_name, c.pull_request.pull_request_id)}
5 5 %if c.rhodecode_name:
6 6 &middot; ${h.branding(c.rhodecode_name)}
7 7 %endif
8 8 </%def>
9 9
10 10 <%def name="breadcrumbs_links()">
11 11 <span id="pr-title">
12 12 ${c.pull_request.title}
13 13 %if c.pull_request.is_closed():
14 14 (${_('Closed')})
15 15 %endif
16 16 </span>
17 17 <div id="pr-title-edit" class="input" style="display: none;">
18 18 ${h.text('pullrequest_title', id_="pr-title-input", class_="large", value=c.pull_request.title)}
19 19 </div>
20 20 </%def>
21 21
22 22 <%def name="menu_bar_nav()">
23 23 ${self.menu_items(active='repositories')}
24 24 </%def>
25 25
26 26 <%def name="menu_bar_subnav()">
27 27 ${self.repo_menu(active='showpullrequest')}
28 28 </%def>
29 29
30 30 <%def name="main()">
31 31 <script type="text/javascript">
32 32 // TODO: marcink switch this to pyroutes
33 33 AJAX_COMMENT_DELETE_URL = "${url('pullrequest_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}";
34 34 templateContext.pull_request_data.pull_request_id = ${c.pull_request.pull_request_id};
35 35 </script>
36 36 <div class="box">
37 37 <div class="title">
38 38 ${self.repo_page_title(c.rhodecode_db_repo)}
39 39 </div>
40 40
41 41 ${self.breadcrumbs()}
42 42
43 43
44 44 <div class="box pr-summary">
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 ${_('Pull request #%s') % c.pull_request.pull_request_id} ${_('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(url('pullrequest_delete', repo_name=c.pull_request.target_repo.repo_name, pull_request_id=c.pull_request.pull_request_id),method='delete')}
53 53 ${h.submit('remove_%s' % c.pull_request.pull_request_id, _('Delete'),
54 54 class_="btn btn-link btn-danger",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 edit')}</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>${_('Origin')}:</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.url('changelog_home', repo_name=c.pull_request.source_repo.repo_name, 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.url('summary_home', repo_name=c.pull_request.source_repo.repo_name)}">${c.pull_request.source_repo.clone_url()}</a>
82 82 </span>
83 83 </div>
84 84 <div class="pr-pullinfo">
85 85 %if h.is_hg(c.pull_request.source_repo):
86 86 <input type="text" value="hg pull -r ${h.short_id(c.source_ref)} ${c.pull_request.source_repo.clone_url()}" readonly="readonly">
87 87 %elif h.is_git(c.pull_request.source_repo):
88 88 <input type="text" value="git pull ${c.pull_request.source_repo.clone_url()} ${c.pull_request.source_ref_parts.name}" readonly="readonly">
89 89 %endif
90 90 </div>
91 91 </div>
92 92 </div>
93 93 <div class="field">
94 94 <div class="label-summary">
95 95 <label>${_('Target')}:</label>
96 96 </div>
97 97 <div class="input">
98 98 <div class="pr-targetinfo">
99 99 ## branch link is only valid if it is a branch
100 100 <span class="tag">
101 101 %if c.pull_request.target_ref_parts.type == 'branch':
102 102 <a href="${h.url('changelog_home', repo_name=c.pull_request.target_repo.repo_name, branch=c.pull_request.target_ref_parts.name)}">${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}</a>
103 103 %else:
104 104 ${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}
105 105 %endif
106 106 </span>
107 107 <span class="clone-url">
108 108 <a href="${h.url('summary_home', repo_name=c.pull_request.target_repo.repo_name)}">${c.pull_request.target_repo.clone_url()}</a>
109 109 </span>
110 110 </div>
111 111 </div>
112 112 </div>
113 113
114 114 ## Link to the shadow repository.
115 115 %if not c.pull_request.is_closed() and c.pull_request.shadow_merge_ref:
116 116 <div class="field">
117 117 <div class="label-summary">
118 118 <label>Merge:</label>
119 119 </div>
120 120 <div class="input">
121 121 <div class="pr-mergeinfo">
122 122 %if h.is_hg(c.pull_request.target_repo):
123 123 <input type="text" value="hg clone -u ${c.pull_request.shadow_merge_ref.name} ${c.shadow_clone_url} pull-request-${c.pull_request.pull_request_id}" readonly="readonly">
124 124 %elif h.is_git(c.pull_request.target_repo):
125 125 <input type="text" value="git clone --branch ${c.pull_request.shadow_merge_ref.name} ${c.shadow_clone_url} pull-request-${c.pull_request.pull_request_id}" readonly="readonly">
126 126 %endif
127 127 </div>
128 128 </div>
129 129 </div>
130 130 %endif
131 131
132 132 <div class="field">
133 133 <div class="label-summary">
134 134 <label>${_('Review')}:</label>
135 135 </div>
136 136 <div class="input">
137 137 %if c.pull_request_review_status:
138 138 <div class="${'flag_status %s' % c.pull_request_review_status} tooltip pull-left"></div>
139 139 <span class="changeset-status-lbl tooltip">
140 140 %if c.pull_request.is_closed():
141 141 ${_('Closed')},
142 142 %endif
143 143 ${h.commit_status_lbl(c.pull_request_review_status)}
144 144 </span>
145 145 - ${ungettext('calculated based on %s reviewer vote', 'calculated based on %s reviewers votes', len(c.pull_request_reviewers)) % len(c.pull_request_reviewers)}
146 146 %endif
147 147 </div>
148 148 </div>
149 149 <div class="field">
150 150 <div class="pr-description-label label-summary">
151 151 <label>${_('Description')}:</label>
152 152 </div>
153 153 <div id="pr-desc" class="input">
154 154 <div class="pr-description">${h.urlify_commit_message(c.pull_request.description, c.repo_name)}</div>
155 155 </div>
156 156 <div id="pr-desc-edit" class="input textarea editor" style="display: none;">
157 157 <textarea id="pr-description-input" size="30">${c.pull_request.description}</textarea>
158 158 </div>
159 159 </div>
160 160 <div class="field">
161 161 <div class="label-summary">
162 162 <label>${_('Comments')}:</label>
163 163 </div>
164 164 <div class="input">
165 165 <div>
166 166 <div class="comments-number">
167 167 %if c.comments:
168 168 <a href="#comments">${ungettext("%d Pull request comment", "%d Pull request comments", len(c.comments)) % len(c.comments)}</a>,
169 169 %else:
170 170 ${ungettext("%d Pull request comment", "%d Pull request comments", len(c.comments)) % len(c.comments)}
171 171 %endif
172 172 %if c.inline_cnt:
173 ## this is replaced with a proper link to first comment via JS linkifyComments() func
174 <a href="#inline-comments" id="inline-comments-counter">${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}</a>
173 <a href="#" onclick="return Rhodecode.comments.nextComment();" id="inline-comments-counter">${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}</a>
175 174 %else:
176 175 ${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}
177 176 %endif
178 177
178
179 179 % if c.outdated_cnt:
180 180 ,${ungettext("%d Outdated Comment", "%d Outdated Comments", c.outdated_cnt) % c.outdated_cnt} <span id="show-outdated-comments" class="btn btn-link">${_('(Show)')}</span>
181 181 % endif
182 182 </div>
183 183 </div>
184 184 </div>
185 185 </div>
186 186 <div id="pr-save" class="field" style="display: none;">
187 187 <div class="label-summary"></div>
188 188 <div class="input">
189 189 <span id="edit_pull_request" class="btn btn-small">${_('Save Changes')}</span>
190 190 </div>
191 191 </div>
192 192 </div>
193 193 </div>
194 194 <div>
195 195 ## AUTHOR
196 196 <div class="reviewers-title block-right">
197 197 <div class="pr-details-title">
198 198 ${_('Author')}
199 199 </div>
200 200 </div>
201 201 <div class="block-right pr-details-content reviewers">
202 202 <ul class="group_members">
203 203 <li>
204 204 ${self.gravatar_with_user(c.pull_request.author.email, 16)}
205 205 </li>
206 206 </ul>
207 207 </div>
208 208 ## REVIEWERS
209 209 <div class="reviewers-title block-right">
210 210 <div class="pr-details-title">
211 211 ${_('Pull request reviewers')}
212 212 %if c.allowed_to_update:
213 213 <span id="open_edit_reviewers" class="block-right action_button">${_('Edit')}</span>
214 214 <span id="close_edit_reviewers" class="block-right action_button" style="display: none;">${_('Close')}</span>
215 215 %endif
216 216 </div>
217 217 </div>
218 218 <div id="reviewers" class="block-right pr-details-content reviewers">
219 219 ## members goes here !
220 220 <input type="hidden" name="__start__" value="review_members:sequence">
221 221 <ul id="review_members" class="group_members">
222 222 %for member,reasons,status in c.pull_request_reviewers:
223 223 <li id="reviewer_${member.user_id}">
224 224 <div class="reviewers_member">
225 225 <div class="reviewer_status tooltip" title="${h.tooltip(h.commit_status_lbl(status[0][1].status if status else 'not_reviewed'))}">
226 226 <div class="${'flag_status %s' % (status[0][1].status if status else 'not_reviewed')} pull-left reviewer_member_status"></div>
227 227 </div>
228 228 <div id="reviewer_${member.user_id}_name" class="reviewer_name">
229 229 ${self.gravatar_with_user(member.email, 16)}
230 230 </div>
231 231 <input type="hidden" name="__start__" value="reviewer:mapping">
232 232 <input type="hidden" name="__start__" value="reasons:sequence">
233 233 %for reason in reasons:
234 234 <div class="reviewer_reason">- ${reason}</div>
235 235 <input type="hidden" name="reason" value="${reason}">
236 236
237 237 %endfor
238 238 <input type="hidden" name="__end__" value="reasons:sequence">
239 239 <input id="reviewer_${member.user_id}_input" type="hidden" value="${member.user_id}" name="user_id" />
240 240 <input type="hidden" name="__end__" value="reviewer:mapping">
241 241 %if c.allowed_to_update:
242 242 <div class="reviewer_member_remove action_button" onclick="removeReviewMember(${member.user_id}, true)" style="visibility: hidden;">
243 243 <i class="icon-remove-sign" ></i>
244 244 </div>
245 245 %endif
246 246 </div>
247 247 </li>
248 248 %endfor
249 249 </ul>
250 250 <input type="hidden" name="__end__" value="review_members:sequence">
251 251 %if not c.pull_request.is_closed():
252 252 <div id="add_reviewer_input" class='ac' style="display: none;">
253 253 %if c.allowed_to_update:
254 254 <div class="reviewer_ac">
255 255 ${h.text('user', class_='ac-input', placeholder=_('Add reviewer'))}
256 256 <div id="reviewers_container"></div>
257 257 </div>
258 258 <div>
259 259 <span id="update_pull_request" class="btn btn-small">${_('Save Changes')}</span>
260 260 </div>
261 261 %endif
262 262 </div>
263 263 %endif
264 264 </div>
265 265 </div>
266 266 </div>
267 267 <div class="box">
268 268 ##DIFF
269 269 <div class="table" >
270 270 <div id="changeset_compare_view_content">
271 271 ##CS
272 272 % if c.missing_requirements:
273 273 <div class="box">
274 274 <div class="alert alert-warning">
275 275 <div>
276 276 <strong>${_('Missing requirements:')}</strong>
277 277 ${_('These commits cannot be displayed, because this repository uses the Mercurial largefiles extension, which was not enabled.')}
278 278 </div>
279 279 </div>
280 280 </div>
281 281 % elif c.missing_commits:
282 282 <div class="box">
283 283 <div class="alert alert-warning">
284 284 <div>
285 285 <strong>${_('Missing commits')}:</strong>
286 286 ${_('This pull request cannot be displayed, because one or more commits no longer exist in the source repository.')}
287 287 ${_('Please update this pull request, push the commits back into the source repository, or consider closing this pull request.')}
288 288 </div>
289 289 </div>
290 290 </div>
291 291 % endif
292 292 <div class="compare_view_commits_title">
293 293 % if c.allowed_to_update and not c.pull_request.is_closed():
294 294 <button id="update_commits" class="btn btn-small">${_('Update commits')}</button>
295 295 % endif
296 296 % if len(c.commit_ranges):
297 297 <h2>${ungettext('Compare View: %s commit','Compare View: %s commits', len(c.commit_ranges)) % len(c.commit_ranges)}</h2>
298 298 % endif
299 299 </div>
300 300 % if not c.missing_commits:
301 301 <%include file="/compare/compare_commits.html" />
302 302 <div class="cs_files">
303 303 <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/>
304 304 ${cbdiffs.render_diffset_menu()}
305 305 ${cbdiffs.render_diffset(
306 306 c.diffset, use_comments=True,
307 307 collapse_when_files_over=30,
308 308 disable_new_comments=c.pull_request.is_closed())}
309 309
310 310 </div>
311 311 % endif
312 312 </div>
313 313
314 314 ## template for inline comment form
315 315 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
316 316 ${comment.comment_inline_form()}
317 317
318 318 ## render comments and inlines
319 319 ${comment.generate_comments(include_pull_request=True, is_pull_request=True)}
320 320
321 321 % if not c.pull_request.is_closed():
322 322 ## main comment form and it status
323 323 ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name,
324 324 pull_request_id=c.pull_request.pull_request_id),
325 325 c.pull_request_review_status,
326 326 is_pull_request=True, change_status=c.allowed_to_change_status)}
327 327 %endif
328 328
329 329 <script type="text/javascript">
330 330 if (location.hash) {
331 331 var result = splitDelimitedHash(location.hash);
332 332 var line = $('html').find(result.loc);
333 333 if (line.length > 0){
334 334 offsetScroll(line, 70);
335 335 }
336 336 }
337 337 $(function(){
338 338 ReviewerAutoComplete('user');
339 339 // custom code mirror
340 340 var codeMirrorInstance = initPullRequestsCodeMirror('#pr-description-input');
341 341
342 342 var PRDetails = {
343 343 editButton: $('#open_edit_pullrequest'),
344 344 closeButton: $('#close_edit_pullrequest'),
345 345 deleteButton: $('#delete_pullrequest'),
346 346 viewFields: $('#pr-desc, #pr-title'),
347 347 editFields: $('#pr-desc-edit, #pr-title-edit, #pr-save'),
348 348
349 349 init: function() {
350 350 var that = this;
351 351 this.editButton.on('click', function(e) { that.edit(); });
352 352 this.closeButton.on('click', function(e) { that.view(); });
353 353 },
354 354
355 355 edit: function(event) {
356 356 this.viewFields.hide();
357 357 this.editButton.hide();
358 358 this.deleteButton.hide();
359 359 this.closeButton.show();
360 360 this.editFields.show();
361 361 codeMirrorInstance.refresh();
362 362 },
363 363
364 364 view: function(event) {
365 365 this.editButton.show();
366 366 this.deleteButton.show();
367 367 this.editFields.hide();
368 368 this.closeButton.hide();
369 369 this.viewFields.show();
370 370 }
371 371 };
372 372
373 373 var ReviewersPanel = {
374 374 editButton: $('#open_edit_reviewers'),
375 375 closeButton: $('#close_edit_reviewers'),
376 376 addButton: $('#add_reviewer_input'),
377 377 removeButtons: $('.reviewer_member_remove'),
378 378
379 379 init: function() {
380 380 var that = this;
381 381 this.editButton.on('click', function(e) { that.edit(); });
382 382 this.closeButton.on('click', function(e) { that.close(); });
383 383 },
384 384
385 385 edit: function(event) {
386 386 this.editButton.hide();
387 387 this.closeButton.show();
388 388 this.addButton.show();
389 389 this.removeButtons.css('visibility', 'visible');
390 390 },
391 391
392 392 close: function(event) {
393 393 this.editButton.show();
394 394 this.closeButton.hide();
395 395 this.addButton.hide();
396 396 this.removeButtons.css('visibility', 'hidden');
397 397 },
398 398 };
399 399
400 400 PRDetails.init();
401 401 ReviewersPanel.init();
402 402
403 403 $('#show-outdated-comments').on('click', function(e){
404 404 var button = $(this);
405 405 var outdated = $('.outdated');
406 406 if (button.html() === "(Show)") {
407 407 button.html("(Hide)");
408 408 outdated.show();
409 409 } else {
410 410 button.html("(Show)");
411 411 outdated.hide();
412 412 }
413 413 });
414 414
415 415 $('.show-inline-comments').on('change', function(e){
416 416 var show = 'none';
417 417 var target = e.currentTarget;
418 418 if(target.checked){
419 419 show = ''
420 420 }
421 421 var boxid = $(target).attr('id_for');
422 422 var comments = $('#{0} .inline-comments'.format(boxid));
423 423 var fn_display = function(idx){
424 424 $(this).css('display', show);
425 425 };
426 426 $(comments).each(fn_display);
427 427 var btns = $('#{0} .inline-comments-button'.format(boxid));
428 428 $(btns).each(fn_display);
429 429 });
430 430
431 431 // inject comments into their proper positions
432 432 var file_comments = $('.inline-comment-placeholder');
433 433 %if c.pull_request.is_closed():
434 434 renderInlineComments(file_comments, false);
435 435 %else:
436 436 renderInlineComments(file_comments, true);
437 437 %endif
438 438 var commentTotals = {};
439 439 $.each(file_comments, function(i, comment) {
440 440 var path = $(comment).attr('path');
441 441 var comms = $(comment).children().length;
442 442 if (path in commentTotals) {
443 443 commentTotals[path] += comms;
444 444 } else {
445 445 commentTotals[path] = comms;
446 446 }
447 447 });
448 448 $.each(commentTotals, function(path, total) {
449 449 var elem = $('.comment-bubble[data-path="'+ path +'"]');
450 450 elem.css('visibility', 'visible');
451 451 elem.html(elem.html() + ' ' + total );
452 452 });
453 453
454 454 $('#merge_pull_request_form').submit(function() {
455 455 if (!$('#merge_pull_request').attr('disabled')) {
456 456 $('#merge_pull_request').attr('disabled', 'disabled');
457 457 }
458 458 return true;
459 459 });
460 460
461 461 $('#edit_pull_request').on('click', function(e){
462 462 var title = $('#pr-title-input').val();
463 463 var description = codeMirrorInstance.getValue();
464 464 editPullRequest(
465 465 "${c.repo_name}", "${c.pull_request.pull_request_id}",
466 466 title, description);
467 467 });
468 468
469 469 $('#update_pull_request').on('click', function(e){
470 470 updateReviewers(undefined, "${c.repo_name}", "${c.pull_request.pull_request_id}");
471 471 });
472 472
473 473 $('#update_commits').on('click', function(e){
474 474 var isDisabled = !$(e.currentTarget).attr('disabled');
475 475 $(e.currentTarget).text(_gettext('Updating...'));
476 476 $(e.currentTarget).attr('disabled', 'disabled');
477 477 if(isDisabled){
478 478 updateCommits("${c.repo_name}", "${c.pull_request.pull_request_id}");
479 479 }
480 480
481 481 });
482 482 // fixing issue with caches on firefox
483 483 $('#update_commits').removeAttr("disabled");
484 484
485 485 $('#close_pull_request').on('click', function(e){
486 486 closePullRequest("${c.repo_name}", "${c.pull_request.pull_request_id}");
487 487 });
488 488
489 489 $('.show-inline-comments').on('click', function(e){
490 490 var boxid = $(this).attr('data-comment-id');
491 491 var button = $(this);
492 492
493 493 if(button.hasClass("comments-visible")) {
494 494 $('#{0} .inline-comments'.format(boxid)).each(function(index){
495 495 $(this).hide();
496 496 });
497 497 button.removeClass("comments-visible");
498 498 } else {
499 499 $('#{0} .inline-comments'.format(boxid)).each(function(index){
500 500 $(this).show();
501 501 });
502 502 button.addClass("comments-visible");
503 503 }
504 504 });
505 505 })
506 506 </script>
507 507
508 508 </div>
509 509 </div>
510 510
511 511 </%def>
General Comments 0
You need to be logged in to leave comments. Login now