comments: re-implemented diff and comments/todos in pull-requests.

This commit is contained in:
Marcin Kuzminski 2019-08-13 12:45:25 +02:00
parent 324bbd3ace
commit 000b072a3f
9 changed files with 98 additions and 76 deletions

View file

@ -426,6 +426,12 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
c.inline_versions = comments_model.aggregate_comments(
inline_comments, versions, c.at_version_num, inline=True)
# TODOs
c.unresolved_comments = CommentsModel() \
.get_pull_request_unresolved_todos(pull_request)
c.resolved_comments = CommentsModel() \
.get_pull_request_resolved_todos(pull_request)
# inject latest version
latest_ver = PullRequest.get_pr_display_object(
pull_request_latest, pull_request_latest)

View file

@ -170,6 +170,23 @@ class CommentsModel(BaseModel):
return todos
def get_pull_request_resolved_todos(self, pull_request, show_outdated=True):
todos = Session().query(ChangesetComment) \
.filter(ChangesetComment.pull_request == pull_request) \
.filter(ChangesetComment.resolved_by != None) \
.filter(ChangesetComment.comment_type
== ChangesetComment.COMMENT_TYPE_TODO)
if not show_outdated:
todos = todos.filter(
coalesce(ChangesetComment.display_state, '') !=
ChangesetComment.COMMENT_OUTDATED)
todos = todos.all()
return todos
def get_commit_unresolved_todos(self, commit_id, show_outdated=True):
todos = Session().query(ChangesetComment) \

View file

@ -18,6 +18,10 @@
font-size: 18px
}
#comment-tr-show {
padding: 5px 0;
}
tr.inline-comments div {
max-width: 100%;

View file

@ -1536,10 +1536,6 @@ table.integrations {
margin: -15px 0px 0px 0px;
}
.comments-summary-td {
border-top: 1px dashed @grey5;
}
// new entry in group_members
.td-author-new-entry {
background-color: rgba(red(@alert1), green(@alert1), blue(@alert1), 0.3);

View file

@ -11,7 +11,7 @@
padding: .25em;
text-align: center;
font-size: (-1 + @basefontsize); //fit in tables
line-height: .9em;
line-height: 1.1em;
border: none;
box-shadow: @button-shadow;
.border-radius(@border-radius);

View file

@ -161,14 +161,15 @@
c.changes[c.commit.raw_id], commit=c.commit, use_comments=True,inline_comments=c.inline_comments )}
</div>
## template for inline comment form
<%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
## comments heading with count
<div class="comments-heading">
<i class="icon-comment"></i>
${_('Comments')} ${len(c.comments)}
</div>
## template for inline comment form
<%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
## render comments
${comment.generate_comments(c.comments)}

View file

@ -45,6 +45,9 @@
% else:
% if comment.resolved_comment:
fix
<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)})">
<span style="text-decoration: line-through">#${comment.resolved_comment.comment_id}</span>
</a>
% else:
${comment.comment_type or 'note'}
% endif
@ -85,12 +88,6 @@
</div>
% endif
% if comment.resolved_comment:
<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)})">
${_('resolves comment #{}').format(comment.resolved_comment.comment_id)}
</a>
% endif
<a class="permalink" href="#comment-${comment.comment_id}"> &para;</a>
<div class="comment-links-block">

View file

@ -49,6 +49,9 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
# for cache purpose
inline_comments=None,
# additional menu for PRs
pull_request_menu=None
)">
<%
@ -125,6 +128,12 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
</div>
## todos
% if getattr(c, 'at_version', None):
<div class="pull-right">
<i class="icon-flag-filled" style="color: #949494">TODOs:</i>
${_('not available in this view')}
</div>
% else:
<div class="pull-right">
<div class="comments-number" style="padding-left: 10px">
% if hasattr(c, 'unresolved_comments') and hasattr(c, 'resolved_comments'):
@ -137,10 +146,11 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
${_('0 unresolved')}
% endif
${_('{} Resolved').format(len(c.unresolved_comments))}
${_('{} Resolved').format(len(c.resolved_comments))}
% endif
</div>
</div>
% endif
## comments
<div class="pull-right">
@ -161,6 +171,24 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
${_('0 Inline')}
% endif
% endif
% if pull_request_menu:
<%
outdated_comm_count_ver = pull_request_menu['outdated_comm_count_ver']
%>
% if outdated_comm_count_ver:
<a href="#" onclick="showOutdated(); Rhodecode.comments.nextOutdatedComment(); return false;">
(${_("{} Outdated").format(outdated_comm_count_ver)})
</a>
<a href="#" class="showOutdatedComments" onclick="showOutdated(this); return false;"> | ${_('show outdated')}</a>
<a href="#" class="hideOutdatedComments" style="display: none" onclick="hideOutdated(this); return false;"> | ${_('hide outdated')}</a>
% else:
(${_("{} Outdated").format(outdated_comm_count_ver)})
% endif
% endif
</div>
</div>
@ -349,7 +377,7 @@ return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line)
<input ${(collapse_all and 'checked' or '')} class="filediff-collapse-state collapse-${diffset_container_id}" id="filediff-collapse-${id(filename)}" type="checkbox" onchange="updateSticky();">
<div class="filediff" data-f-path="${filename}" id="a_${h.FID(filediff.raw_id, filename)}">
<label for="filediff-collapse-${id(filename)}" class="filediff-heading">
<div class="filediff-collapse-indicator"></div>
<div class="filediff-collapse-indicator icon-"></div>
<span class="pill">
## file was deleted

View file

@ -244,56 +244,11 @@
</button>
</td>
</tr>
## show comment/inline comments summary
<%def name="comments_summary()">
<tr>
<td colspan="6" class="comments-summary-td">
% if c.at_version:
<% inline_comm_count_ver = len(c.inline_versions[c.at_version_num]['display']) %>
<% general_comm_count_ver = len(c.comment_versions[c.at_version_num]['display']) %>
${_('Comments at this version')}:
% else:
<% inline_comm_count_ver = len(c.inline_versions[c.at_version_num]['until']) %>
<% general_comm_count_ver = len(c.comment_versions[c.at_version_num]['until']) %>
${_('Comments for this pull request')}:
% endif
%if general_comm_count_ver:
<a href="#comments">${_("%d General ") % general_comm_count_ver}</a>
%else:
${_("%d General ") % general_comm_count_ver}
%endif
%if inline_comm_count_ver:
, <a href="#" onclick="return Rhodecode.comments.nextComment();" id="inline-comments-counter">${_("%d Inline") % inline_comm_count_ver}</a>
%else:
, ${_("%d Inline") % inline_comm_count_ver}
%endif
%if outdated_comm_count_ver:
, <a href="#" onclick="showOutdated(); Rhodecode.comments.nextOutdatedComment(); return false;">${_("%d Outdated") % outdated_comm_count_ver}</a>
<a href="#" class="showOutdatedComments" onclick="showOutdated(this); return false;"> | ${_('show outdated comments')}</a>
<a href="#" class="hideOutdatedComments" style="display: none" onclick="hideOutdated(this); return false;"> | ${_('hide outdated comments')}</a>
%else:
, ${_("%d Outdated") % outdated_comm_count_ver}
%endif
</td>
</tr>
</%def>
${comments_summary()}
</table>
% else:
<div class="input">
${_('Pull request versions not available')}.
</div>
<div>
<table>
${comments_summary()}
</table>
</div>
% endif
</div>
</div>
@ -534,6 +489,19 @@
<div class="cs_files">
<%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
% if c.at_version:
<% c.inline_cnt = len(c.inline_versions[c.at_version_num]['display']) %>
<% c.comments = c.comment_versions[c.at_version_num]['display'] %>
% else:
<% c.inline_cnt = len(c.inline_versions[c.at_version_num]['until']) %>
<% c.comments = c.comment_versions[c.at_version_num]['until'] %>
% endif
<%
pr_menu_data = {
'outdated_comm_count_ver': outdated_comm_count_ver
}
%>
${cbdiffs.render_diffset_menu(c.diffset, range_diff_on=c.range_diff_on)}
@ -545,7 +513,8 @@
collapse_when_files_over=5,
disable_new_comments=True,
deleted_files_comments=c.deleted_files_comments,
inline_comments=c.inline_comments)}
inline_comments=c.inline_comments,
pull_request_menu=pr_menu_data)}
% endfor
% else:
${cbdiffs.render_diffset(
@ -553,7 +522,8 @@
collapse_when_files_over=30,
disable_new_comments=not c.allowed_to_comment,
deleted_files_comments=c.deleted_files_comments,
inline_comments=c.inline_comments)}
inline_comments=c.inline_comments,
pull_request_menu=pr_menu_data)}
% endif
</div>
@ -568,22 +538,25 @@
## template for inline comment form
<%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
## render general comments
## comments heading with count
<div class="comments-heading">
<i class="icon-comment"></i>
${_('Comments')} ${len(c.comments)}
</div>
## render general comments
<div id="comment-tr-show">
<div class="comment">
% if general_outdated_comm_count_ver:
<div class="meta">
% if general_outdated_comm_count_ver == 1:
${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)},
<a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show it')}</a>
% else:
${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)},
<a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show them')}</a>
% endif
</div>
% if general_outdated_comm_count_ver:
<div class="info-box">
% if general_outdated_comm_count_ver == 1:
${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)},
<a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show it')}</a>
% else:
${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)},
<a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show them')}</a>
% endif
</div>
</div>
% endif
</div>
${comment.generate_comments(c.comments, include_pull_request=True, is_pull_request=True)}