# HG changeset patch # User Marcin Kuzminski # Date 2019-08-13 10:45:25 # Node ID 761273d61c757b68332a70228e13bd3459a71353 # Parent 698bb7ce1d08a736265d9428488f94c4899ac742 comments: re-implemented diff and comments/todos in pull-requests. diff --git a/rhodecode/apps/repository/views/repo_pull_requests.py b/rhodecode/apps/repository/views/repo_pull_requests.py --- a/rhodecode/apps/repository/views/repo_pull_requests.py +++ b/rhodecode/apps/repository/views/repo_pull_requests.py @@ -426,6 +426,12 @@ class RepoPullRequestsView(RepoAppView, 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) diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py --- a/rhodecode/model/comment.py +++ b/rhodecode/model/comment.py @@ -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) \ diff --git a/rhodecode/public/css/comments.less b/rhodecode/public/css/comments.less --- a/rhodecode/public/css/comments.less +++ b/rhodecode/public/css/comments.less @@ -18,6 +18,10 @@ font-size: 18px } +#comment-tr-show { + padding: 5px 0; +} + tr.inline-comments div { max-width: 100%; diff --git a/rhodecode/public/css/main.less b/rhodecode/public/css/main.less --- a/rhodecode/public/css/main.less +++ b/rhodecode/public/css/main.less @@ -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); diff --git a/rhodecode/public/css/tags.less b/rhodecode/public/css/tags.less --- a/rhodecode/public/css/tags.less +++ b/rhodecode/public/css/tags.less @@ -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); diff --git a/rhodecode/templates/changeset/changeset.mako b/rhodecode/templates/changeset/changeset.mako --- a/rhodecode/templates/changeset/changeset.mako +++ b/rhodecode/templates/changeset/changeset.mako @@ -161,14 +161,15 @@ c.changes[c.commit.raw_id], commit=c.commit, use_comments=True,inline_comments=c.inline_comments )} + ## template for inline comment form + <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> + + ## comments heading with count
${_('Comments')} ${len(c.comments)}
- ## template for inline comment form - <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> - ## render comments ${comment.generate_comments(c.comments)} diff --git a/rhodecode/templates/changeset/changeset_file_comment.mako b/rhodecode/templates/changeset/changeset_file_comment.mako --- a/rhodecode/templates/changeset/changeset_file_comment.mako +++ b/rhodecode/templates/changeset/changeset_file_comment.mako @@ -45,6 +45,9 @@ % else: % if comment.resolved_comment: fix + + #${comment.resolved_comment.comment_id} + % else: ${comment.comment_type or 'note'} % endif @@ -85,12 +88,6 @@ % endif - % if comment.resolved_comment: - - ${_('resolves comment #{}').format(comment.resolved_comment.comment_id)} - - % endif - ## todos + % if getattr(c, 'at_version', None): +
+ TODOs: + ${_('not available in this view')} +
+ % else:
% if hasattr(c, 'unresolved_comments') and hasattr(c, 'resolved_comments'): @@ -137,10 +146,11 @@ return '%s_%s_%i' % (h.md5_safe(commit+f ${_('0 unresolved')} % endif - ${_('{} Resolved').format(len(c.unresolved_comments))} + ${_('{} Resolved').format(len(c.resolved_comments))} % endif
+ % endif ## comments
@@ -161,6 +171,24 @@ return '%s_%s_%i' % (h.md5_safe(commit+f ${_('0 Inline')} % endif % endif + + % if pull_request_menu: + <% + outdated_comm_count_ver = pull_request_menu['outdated_comm_count_ver'] + %> + + % if outdated_comm_count_ver: + + (${_("{} Outdated").format(outdated_comm_count_ver)}) + + | ${_('show outdated')} + + % else: + (${_("{} Outdated").format(outdated_comm_count_ver)}) + % endif + + % endif +
@@ -349,7 +377,7 @@ return '%s_%s_%i' % (h.md5_safe(commit+f
@@ -534,6 +489,19 @@
<%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
@@ -568,22 +538,25 @@ ## template for inline comment form <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> + ## comments heading with count +
+ + ${_('Comments')} ${len(c.comments)} +
+ ## render general comments -
-
- % if general_outdated_comm_count_ver: -
- % if general_outdated_comm_count_ver == 1: - ${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)}, - ${_('show it')} - % else: - ${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)}, - ${_('show them')} - % endif -
+ % if general_outdated_comm_count_ver: +
+ % if general_outdated_comm_count_ver == 1: + ${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)}, + ${_('show it')} + % else: + ${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)}, + ${_('show them')} % endif -
+
+ % endif
${comment.generate_comments(c.comments, include_pull_request=True, is_pull_request=True)}