##// END OF EJS Templates
comments: re-implemented diff and comments/todos in pull-requests.
marcink -
r3884:761273d6 default
parent child Browse files
Show More
@@ -426,6 +426,12 b' class RepoPullRequestsView(RepoAppView, '
426 c.inline_versions = comments_model.aggregate_comments(
426 c.inline_versions = comments_model.aggregate_comments(
427 inline_comments, versions, c.at_version_num, inline=True)
427 inline_comments, versions, c.at_version_num, inline=True)
428
428
429 # TODOs
430 c.unresolved_comments = CommentsModel() \
431 .get_pull_request_unresolved_todos(pull_request)
432 c.resolved_comments = CommentsModel() \
433 .get_pull_request_resolved_todos(pull_request)
434
429 # inject latest version
435 # inject latest version
430 latest_ver = PullRequest.get_pr_display_object(
436 latest_ver = PullRequest.get_pr_display_object(
431 pull_request_latest, pull_request_latest)
437 pull_request_latest, pull_request_latest)
@@ -170,6 +170,23 b' class CommentsModel(BaseModel):'
170
170
171 return todos
171 return todos
172
172
173 def get_pull_request_resolved_todos(self, pull_request, show_outdated=True):
174
175 todos = Session().query(ChangesetComment) \
176 .filter(ChangesetComment.pull_request == pull_request) \
177 .filter(ChangesetComment.resolved_by != None) \
178 .filter(ChangesetComment.comment_type
179 == ChangesetComment.COMMENT_TYPE_TODO)
180
181 if not show_outdated:
182 todos = todos.filter(
183 coalesce(ChangesetComment.display_state, '') !=
184 ChangesetComment.COMMENT_OUTDATED)
185
186 todos = todos.all()
187
188 return todos
189
173 def get_commit_unresolved_todos(self, commit_id, show_outdated=True):
190 def get_commit_unresolved_todos(self, commit_id, show_outdated=True):
174
191
175 todos = Session().query(ChangesetComment) \
192 todos = Session().query(ChangesetComment) \
@@ -18,6 +18,10 b''
18 font-size: 18px
18 font-size: 18px
19 }
19 }
20
20
21 #comment-tr-show {
22 padding: 5px 0;
23 }
24
21 tr.inline-comments div {
25 tr.inline-comments div {
22 max-width: 100%;
26 max-width: 100%;
23
27
@@ -1536,10 +1536,6 b' table.integrations {'
1536 margin: -15px 0px 0px 0px;
1536 margin: -15px 0px 0px 0px;
1537 }
1537 }
1538
1538
1539 .comments-summary-td {
1540 border-top: 1px dashed @grey5;
1541 }
1542
1543 // new entry in group_members
1539 // new entry in group_members
1544 .td-author-new-entry {
1540 .td-author-new-entry {
1545 background-color: rgba(red(@alert1), green(@alert1), blue(@alert1), 0.3);
1541 background-color: rgba(red(@alert1), green(@alert1), blue(@alert1), 0.3);
@@ -11,7 +11,7 b''
11 padding: .25em;
11 padding: .25em;
12 text-align: center;
12 text-align: center;
13 font-size: (-1 + @basefontsize); //fit in tables
13 font-size: (-1 + @basefontsize); //fit in tables
14 line-height: .9em;
14 line-height: 1.1em;
15 border: none;
15 border: none;
16 box-shadow: @button-shadow;
16 box-shadow: @button-shadow;
17 .border-radius(@border-radius);
17 .border-radius(@border-radius);
@@ -161,14 +161,15 b''
161 c.changes[c.commit.raw_id], commit=c.commit, use_comments=True,inline_comments=c.inline_comments )}
161 c.changes[c.commit.raw_id], commit=c.commit, use_comments=True,inline_comments=c.inline_comments )}
162 </div>
162 </div>
163
163
164 ## template for inline comment form
165 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
166
167 ## comments heading with count
164 <div class="comments-heading">
168 <div class="comments-heading">
165 <i class="icon-comment"></i>
169 <i class="icon-comment"></i>
166 ${_('Comments')} ${len(c.comments)}
170 ${_('Comments')} ${len(c.comments)}
167 </div>
171 </div>
168
172
169 ## template for inline comment form
170 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
171
172 ## render comments
173 ## render comments
173 ${comment.generate_comments(c.comments)}
174 ${comment.generate_comments(c.comments)}
174
175
@@ -45,6 +45,9 b''
45 % else:
45 % else:
46 % if comment.resolved_comment:
46 % if comment.resolved_comment:
47 fix
47 fix
48 <a href="#comment-${comment.resolved_comment.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${comment.resolved_comment.comment_id}'), 0, ${h.json.dumps(comment.resolved_comment.outdated)})">
49 <span style="text-decoration: line-through">#${comment.resolved_comment.comment_id}</span>
50 </a>
48 % else:
51 % else:
49 ${comment.comment_type or 'note'}
52 ${comment.comment_type or 'note'}
50 % endif
53 % endif
@@ -85,12 +88,6 b''
85 </div>
88 </div>
86 % endif
89 % endif
87
90
88 % if comment.resolved_comment:
89 <a class="has-spacer-before" href="#comment-${comment.resolved_comment.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${comment.resolved_comment.comment_id}'), 0, ${h.json.dumps(comment.resolved_comment.outdated)})">
90 ${_('resolves comment #{}').format(comment.resolved_comment.comment_id)}
91 </a>
92 % endif
93
94 <a class="permalink" href="#comment-${comment.comment_id}"> &para;</a>
91 <a class="permalink" href="#comment-${comment.comment_id}"> &para;</a>
95
92
96 <div class="comment-links-block">
93 <div class="comment-links-block">
@@ -49,6 +49,9 b" return '%s_%s_%i' % (h.md5_safe(commit+f"
49 # for cache purpose
49 # for cache purpose
50 inline_comments=None,
50 inline_comments=None,
51
51
52 # additional menu for PRs
53 pull_request_menu=None
54
52 )">
55 )">
53
56
54 <%
57 <%
@@ -125,6 +128,12 b" return '%s_%s_%i' % (h.md5_safe(commit+f"
125 </div>
128 </div>
126
129
127 ## todos
130 ## todos
131 % if getattr(c, 'at_version', None):
132 <div class="pull-right">
133 <i class="icon-flag-filled" style="color: #949494">TODOs:</i>
134 ${_('not available in this view')}
135 </div>
136 % else:
128 <div class="pull-right">
137 <div class="pull-right">
129 <div class="comments-number" style="padding-left: 10px">
138 <div class="comments-number" style="padding-left: 10px">
130 % if hasattr(c, 'unresolved_comments') and hasattr(c, 'resolved_comments'):
139 % if hasattr(c, 'unresolved_comments') and hasattr(c, 'resolved_comments'):
@@ -137,10 +146,11 b" return '%s_%s_%i' % (h.md5_safe(commit+f"
137 ${_('0 unresolved')}
146 ${_('0 unresolved')}
138 % endif
147 % endif
139
148
140 ${_('{} Resolved').format(len(c.unresolved_comments))}
149 ${_('{} Resolved').format(len(c.resolved_comments))}
141 % endif
150 % endif
142 </div>
151 </div>
143 </div>
152 </div>
153 % endif
144
154
145 ## comments
155 ## comments
146 <div class="pull-right">
156 <div class="pull-right">
@@ -161,6 +171,24 b" return '%s_%s_%i' % (h.md5_safe(commit+f"
161 ${_('0 Inline')}
171 ${_('0 Inline')}
162 % endif
172 % endif
163 % endif
173 % endif
174
175 % if pull_request_menu:
176 <%
177 outdated_comm_count_ver = pull_request_menu['outdated_comm_count_ver']
178 %>
179
180 % if outdated_comm_count_ver:
181 <a href="#" onclick="showOutdated(); Rhodecode.comments.nextOutdatedComment(); return false;">
182 (${_("{} Outdated").format(outdated_comm_count_ver)})
183 </a>
184 <a href="#" class="showOutdatedComments" onclick="showOutdated(this); return false;"> | ${_('show outdated')}</a>
185 <a href="#" class="hideOutdatedComments" style="display: none" onclick="hideOutdated(this); return false;"> | ${_('hide outdated')}</a>
186 % else:
187 (${_("{} Outdated").format(outdated_comm_count_ver)})
188 % endif
189
190 % endif
191
164 </div>
192 </div>
165 </div>
193 </div>
166
194
@@ -349,7 +377,7 b" return '%s_%s_%i' % (h.md5_safe(commit+f"
349 <input ${(collapse_all and 'checked' or '')} class="filediff-collapse-state collapse-${diffset_container_id}" id="filediff-collapse-${id(filename)}" type="checkbox" onchange="updateSticky();">
377 <input ${(collapse_all and 'checked' or '')} class="filediff-collapse-state collapse-${diffset_container_id}" id="filediff-collapse-${id(filename)}" type="checkbox" onchange="updateSticky();">
350 <div class="filediff" data-f-path="${filename}" id="a_${h.FID(filediff.raw_id, filename)}">
378 <div class="filediff" data-f-path="${filename}" id="a_${h.FID(filediff.raw_id, filename)}">
351 <label for="filediff-collapse-${id(filename)}" class="filediff-heading">
379 <label for="filediff-collapse-${id(filename)}" class="filediff-heading">
352 <div class="filediff-collapse-indicator"></div>
380 <div class="filediff-collapse-indicator icon-"></div>
353
381
354 <span class="pill">
382 <span class="pill">
355 ## file was deleted
383 ## file was deleted
@@ -244,56 +244,11 b''
244 </button>
244 </button>
245 </td>
245 </td>
246 </tr>
246 </tr>
247
248 ## show comment/inline comments summary
249 <%def name="comments_summary()">
250 <tr>
251 <td colspan="6" class="comments-summary-td">
252
253 % if c.at_version:
254 <% inline_comm_count_ver = len(c.inline_versions[c.at_version_num]['display']) %>
255 <% general_comm_count_ver = len(c.comment_versions[c.at_version_num]['display']) %>
256 ${_('Comments at this version')}:
257 % else:
258 <% inline_comm_count_ver = len(c.inline_versions[c.at_version_num]['until']) %>
259 <% general_comm_count_ver = len(c.comment_versions[c.at_version_num]['until']) %>
260 ${_('Comments for this pull request')}:
261 % endif
262
263
264 %if general_comm_count_ver:
265 <a href="#comments">${_("%d General ") % general_comm_count_ver}</a>
266 %else:
267 ${_("%d General ") % general_comm_count_ver}
268 %endif
269
270 %if inline_comm_count_ver:
271 , <a href="#" onclick="return Rhodecode.comments.nextComment();" id="inline-comments-counter">${_("%d Inline") % inline_comm_count_ver}</a>
272 %else:
273 , ${_("%d Inline") % inline_comm_count_ver}
274 %endif
275
276 %if outdated_comm_count_ver:
277 , <a href="#" onclick="showOutdated(); Rhodecode.comments.nextOutdatedComment(); return false;">${_("%d Outdated") % outdated_comm_count_ver}</a>
278 <a href="#" class="showOutdatedComments" onclick="showOutdated(this); return false;"> | ${_('show outdated comments')}</a>
279 <a href="#" class="hideOutdatedComments" style="display: none" onclick="hideOutdated(this); return false;"> | ${_('hide outdated comments')}</a>
280 %else:
281 , ${_("%d Outdated") % outdated_comm_count_ver}
282 %endif
283 </td>
284 </tr>
285 </%def>
286 ${comments_summary()}
287 </table>
247 </table>
288 % else:
248 % else:
289 <div class="input">
249 <div class="input">
290 ${_('Pull request versions not available')}.
250 ${_('Pull request versions not available')}.
291 </div>
251 </div>
292 <div>
293 <table>
294 ${comments_summary()}
295 </table>
296 </div>
297 % endif
252 % endif
298 </div>
253 </div>
299 </div>
254 </div>
@@ -534,6 +489,19 b''
534
489
535 <div class="cs_files">
490 <div class="cs_files">
536 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
491 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
492 % if c.at_version:
493 <% c.inline_cnt = len(c.inline_versions[c.at_version_num]['display']) %>
494 <% c.comments = c.comment_versions[c.at_version_num]['display'] %>
495 % else:
496 <% c.inline_cnt = len(c.inline_versions[c.at_version_num]['until']) %>
497 <% c.comments = c.comment_versions[c.at_version_num]['until'] %>
498 % endif
499
500 <%
501 pr_menu_data = {
502 'outdated_comm_count_ver': outdated_comm_count_ver
503 }
504 %>
537
505
538 ${cbdiffs.render_diffset_menu(c.diffset, range_diff_on=c.range_diff_on)}
506 ${cbdiffs.render_diffset_menu(c.diffset, range_diff_on=c.range_diff_on)}
539
507
@@ -545,7 +513,8 b''
545 collapse_when_files_over=5,
513 collapse_when_files_over=5,
546 disable_new_comments=True,
514 disable_new_comments=True,
547 deleted_files_comments=c.deleted_files_comments,
515 deleted_files_comments=c.deleted_files_comments,
548 inline_comments=c.inline_comments)}
516 inline_comments=c.inline_comments,
517 pull_request_menu=pr_menu_data)}
549 % endfor
518 % endfor
550 % else:
519 % else:
551 ${cbdiffs.render_diffset(
520 ${cbdiffs.render_diffset(
@@ -553,7 +522,8 b''
553 collapse_when_files_over=30,
522 collapse_when_files_over=30,
554 disable_new_comments=not c.allowed_to_comment,
523 disable_new_comments=not c.allowed_to_comment,
555 deleted_files_comments=c.deleted_files_comments,
524 deleted_files_comments=c.deleted_files_comments,
556 inline_comments=c.inline_comments)}
525 inline_comments=c.inline_comments,
526 pull_request_menu=pr_menu_data)}
557 % endif
527 % endif
558
528
559 </div>
529 </div>
@@ -568,22 +538,25 b''
568 ## template for inline comment form
538 ## template for inline comment form
569 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
539 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
570
540
541 ## comments heading with count
542 <div class="comments-heading">
543 <i class="icon-comment"></i>
544 ${_('Comments')} ${len(c.comments)}
545 </div>
546
571 ## render general comments
547 ## render general comments
572
573 <div id="comment-tr-show">
548 <div id="comment-tr-show">
574 <div class="comment">
549 % if general_outdated_comm_count_ver:
575 % if general_outdated_comm_count_ver:
550 <div class="info-box">
576 <div class="meta">
551 % if general_outdated_comm_count_ver == 1:
577 % if general_outdated_comm_count_ver == 1:
552 ${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)},
578 ${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)},
553 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show it')}</a>
579 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show it')}</a>
554 % else:
580 % else:
555 ${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)},
581 ${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)},
556 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show them')}</a>
582 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show them')}</a>
583 % endif
584 </div>
585 % endif
557 % endif
586 </div>
558 </div>
559 % endif
587 </div>
560 </div>
588
561
589 ${comment.generate_comments(c.comments, include_pull_request=True, is_pull_request=True)}
562 ${comment.generate_comments(c.comments, include_pull_request=True, is_pull_request=True)}
General Comments 0
You need to be logged in to leave comments. Login now