# HG changeset patch # User Marcin Kuzminski # Date 2017-01-08 20:49:26 # Node ID e783fdd1a94e51b5a5a997ef440faa4cc0249aa8 # Parent ef42222859394dc17ad7f4984f38513fd36aab16 comments: properly show version of pull request into added comments. - index them by numeric index instead of DB id - show inside main comments a version in which they were made. diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -357,6 +357,8 @@ class ChangesetController(BaseRepoContro if status else None), status_change_type=status ) + c.inline_comment = True if comment.line_no else False + # get status if set ! if status: # if latest status was from pull request and it's closed diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py --- a/rhodecode/controllers/pullrequests.py +++ b/rhodecode/controllers/pullrequests.py @@ -814,7 +814,11 @@ class PullrequestsController(BaseRepoCon _inline_cnt, c.inline_versions = cc_model.get_inline_comments_count( inline_comments, version=at_version, include_aggregates=True) + c.versions = pull_request_display_obj.versions() c.at_version_num = at_version if at_version and at_version != 'latest' else None + c.at_version_pos = ChangesetComment.get_index_from_version( + c.at_version_num, c.versions) + is_outdated = lambda co: \ not c.at_version_num \ or co.pull_request_version_id <= c.at_version_num @@ -872,7 +876,6 @@ class PullrequestsController(BaseRepoCon c.pull_request_latest = pull_request_latest c.at_version = at_version - c.versions = pull_request_display_obj.versions() c.changes = None c.file_changes = None @@ -983,6 +986,7 @@ class PullrequestsController(BaseRepoCon } if comm: c.co = comm + c.inline_comment = True if comm.line_no else False data.update(comm.get_dict()) data.update({'rendered_text': render('changeset/changeset_comment_block.mako')}) diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -2935,6 +2935,14 @@ class ChangesetComment(Base, BaseModel): q = q.filter(cls.pull_request_id == pull_request_id) return q.all() + @classmethod + def get_index_from_version(cls, pr_version, versions): + num_versions = [x.pull_request_version_id for x in versions] + try: + return num_versions.index(pr_version) +1 + except (IndexError, ValueError): + return + @property def outdated(self): return self.display_state == self.COMMENT_OUTDATED @@ -2945,6 +2953,10 @@ class ChangesetComment(Base, BaseModel): """ return self.outdated and self.pull_request_version_id != version + def get_index_version(self, versions): + return self.get_index_from_version( + self.pull_request_version_id, versions) + def render(self, mentions=False): from rhodecode.lib import helpers as h return h.render(self.text, renderer=self.renderer, mentions=mentions) 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 @@ -48,6 +48,12 @@ tr.inline-comments div { } .comment { + + &.comment-general { + border: 1px solid @grey5; + padding: 5px 5px 5px 5px; + } + margin: @padding 0; padding: 4px 0 0 0; line-height: 1em; @@ -61,6 +67,8 @@ tr.inline-comments div { position: relative; width: 100%; margin: 0 0 .5em 0; + border-bottom: 1px solid @grey5; + padding: 8px 0px; &:hover .permalink { visibility: visible; @@ -71,8 +79,6 @@ tr.inline-comments div { .author, .date { display: inline; - margin: 0 .5 0 0; - padding: 0 .5 0 0; &:after { content: ' | '; @@ -80,6 +86,13 @@ tr.inline-comments div { } } + .author-general img { + top: -3px; + } + .author-inline img { + top: -3px; + } + .status-change, .permalink, .changeset-status-lbl { @@ -153,7 +166,6 @@ tr.inline-comments div { .text { clear: both; - border: @border-thickness solid @grey5; .border-radius(@border-radius); .box-sizing(border-box); @@ -163,6 +175,19 @@ tr.inline-comments div { // TODO: lisa: This is needed because of other rst !important rules :[ } } + + .pr-version { + float: left; + margin: 0px 4px; + } + .pr-version-inline { + float: left; + margin: 1px 4px; + } + .pr-version-num { + font-size: 10px; + } + } .show-outdated-comments { diff --git a/rhodecode/templates/changeset/changeset_comment_block.mako b/rhodecode/templates/changeset/changeset_comment_block.mako --- a/rhodecode/templates/changeset/changeset_comment_block.mako +++ b/rhodecode/templates/changeset/changeset_comment_block.mako @@ -1,4 +1,4 @@ ## this is a dummy html file for partial rendering on server and sending ## generated output via ajax after comment submit <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> -${comment.comment_block(c.co, inline=True)} +${comment.comment_block(c.co, inline=c.inline_comment)} 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 @@ -7,9 +7,10 @@ <%def name="comment_block(comment, inline=False)"> <% outdated_at_ver = comment.outdated_at_version(getattr(c, 'at_version', None)) %> + <% pr_index_ver = comment.get_index_version(getattr(c, 'versions', [])) %>
-
- ${base.gravatar_with_user(comment.author.email, 16)} +
+ ${base.gravatar_with_user(comment.author.email, 20)}
${h.age_component(comment.modified_at, time_is_local=True)}
+ % if inline: + + % else: - %if comment.status_change: + % endif + + % if comment.status_change:
${comment.status_change[0].status_lbl}
- %endif + % endif +