##// END OF EJS Templates
comments: properly show version of pull request into added comments....
marcink -
r1286:e783fdd1 default
parent child Browse files
Show More
@@ -357,6 +357,8 b' class ChangesetController(BaseRepoContro'
357 357 if status else None),
358 358 status_change_type=status
359 359 )
360 c.inline_comment = True if comment.line_no else False
361
360 362 # get status if set !
361 363 if status:
362 364 # if latest status was from pull request and it's closed
@@ -814,7 +814,11 b' class PullrequestsController(BaseRepoCon'
814 814 _inline_cnt, c.inline_versions = cc_model.get_inline_comments_count(
815 815 inline_comments, version=at_version, include_aggregates=True)
816 816
817 c.versions = pull_request_display_obj.versions()
817 818 c.at_version_num = at_version if at_version and at_version != 'latest' else None
819 c.at_version_pos = ChangesetComment.get_index_from_version(
820 c.at_version_num, c.versions)
821
818 822 is_outdated = lambda co: \
819 823 not c.at_version_num \
820 824 or co.pull_request_version_id <= c.at_version_num
@@ -872,7 +876,6 b' class PullrequestsController(BaseRepoCon'
872 876 c.pull_request_latest = pull_request_latest
873 877 c.at_version = at_version
874 878
875 c.versions = pull_request_display_obj.versions()
876 879 c.changes = None
877 880 c.file_changes = None
878 881
@@ -983,6 +986,7 b' class PullrequestsController(BaseRepoCon'
983 986 }
984 987 if comm:
985 988 c.co = comm
989 c.inline_comment = True if comm.line_no else False
986 990 data.update(comm.get_dict())
987 991 data.update({'rendered_text':
988 992 render('changeset/changeset_comment_block.mako')})
@@ -2935,6 +2935,14 b' class ChangesetComment(Base, BaseModel):'
2935 2935 q = q.filter(cls.pull_request_id == pull_request_id)
2936 2936 return q.all()
2937 2937
2938 @classmethod
2939 def get_index_from_version(cls, pr_version, versions):
2940 num_versions = [x.pull_request_version_id for x in versions]
2941 try:
2942 return num_versions.index(pr_version) +1
2943 except (IndexError, ValueError):
2944 return
2945
2938 2946 @property
2939 2947 def outdated(self):
2940 2948 return self.display_state == self.COMMENT_OUTDATED
@@ -2945,6 +2953,10 b' class ChangesetComment(Base, BaseModel):'
2945 2953 """
2946 2954 return self.outdated and self.pull_request_version_id != version
2947 2955
2956 def get_index_version(self, versions):
2957 return self.get_index_from_version(
2958 self.pull_request_version_id, versions)
2959
2948 2960 def render(self, mentions=False):
2949 2961 from rhodecode.lib import helpers as h
2950 2962 return h.render(self.text, renderer=self.renderer, mentions=mentions)
@@ -48,6 +48,12 b' tr.inline-comments div {'
48 48 }
49 49
50 50 .comment {
51
52 &.comment-general {
53 border: 1px solid @grey5;
54 padding: 5px 5px 5px 5px;
55 }
56
51 57 margin: @padding 0;
52 58 padding: 4px 0 0 0;
53 59 line-height: 1em;
@@ -61,6 +67,8 b' tr.inline-comments div {'
61 67 position: relative;
62 68 width: 100%;
63 69 margin: 0 0 .5em 0;
70 border-bottom: 1px solid @grey5;
71 padding: 8px 0px;
64 72
65 73 &:hover .permalink {
66 74 visibility: visible;
@@ -71,8 +79,6 b' tr.inline-comments div {'
71 79 .author,
72 80 .date {
73 81 display: inline;
74 margin: 0 .5 0 0;
75 padding: 0 .5 0 0;
76 82
77 83 &:after {
78 84 content: ' | ';
@@ -80,6 +86,13 b' tr.inline-comments div {'
80 86 }
81 87 }
82 88
89 .author-general img {
90 top: -3px;
91 }
92 .author-inline img {
93 top: -3px;
94 }
95
83 96 .status-change,
84 97 .permalink,
85 98 .changeset-status-lbl {
@@ -153,7 +166,6 b' tr.inline-comments div {'
153 166
154 167 .text {
155 168 clear: both;
156 border: @border-thickness solid @grey5;
157 169 .border-radius(@border-radius);
158 170 .box-sizing(border-box);
159 171
@@ -163,6 +175,19 b' tr.inline-comments div {'
163 175 // TODO: lisa: This is needed because of other rst !important rules :[
164 176 }
165 177 }
178
179 .pr-version {
180 float: left;
181 margin: 0px 4px;
182 }
183 .pr-version-inline {
184 float: left;
185 margin: 1px 4px;
186 }
187 .pr-version-num {
188 font-size: 10px;
189 }
190
166 191 }
167 192
168 193 .show-outdated-comments {
@@ -1,4 +1,4 b''
1 1 ## this is a dummy html file for partial rendering on server and sending
2 2 ## generated output via ajax after comment submit
3 3 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
4 ${comment.comment_block(c.co, inline=True)}
4 ${comment.comment_block(c.co, inline=c.inline_comment)}
@@ -7,9 +7,10 b''
7 7
8 8 <%def name="comment_block(comment, inline=False)">
9 9 <% outdated_at_ver = comment.outdated_at_version(getattr(c, 'at_version', None)) %>
10 <% pr_index_ver = comment.get_index_version(getattr(c, 'versions', [])) %>
10 11
11 12 <div class="comment
12 ${'comment-inline' if inline else ''}
13 ${'comment-inline' if inline else 'comment-general'}
13 14 ${'comment-outdated' if outdated_at_ver else 'comment-current'}"
14 15 id="comment-${comment.comment_id}"
15 16 line="${comment.line_no}"
@@ -17,27 +18,24 b''
17 18 style="${'display: none;' if outdated_at_ver else ''}">
18 19
19 20 <div class="meta">
20 <div class="author">
21 ${base.gravatar_with_user(comment.author.email, 16)}
21 <div class="author ${'author-inline' if inline else 'author-general'}">
22 ${base.gravatar_with_user(comment.author.email, 20)}
22 23 </div>
23 24 <div class="date">
24 25 ${h.age_component(comment.modified_at, time_is_local=True)}
25 26 </div>
27 % if inline:
28 <span></span>
29 % else:
26 30 <div class="status-change">
27 31 % if comment.pull_request:
28 % if comment.outdated:
29 <a href="?version=${comment.pull_request_version_id}#comment-${comment.comment_id}">
30 ${_('Outdated comment from pull request version {}').format(comment.pull_request_version_id)}
31 </a>
32 % else:
33 <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}">
34 %if comment.status_change:
35 ${_('Vote on pull request #%s') % comment.pull_request.pull_request_id}:
36 %else:
37 ${_('Comment on pull request #%s') % comment.pull_request.pull_request_id}
38 %endif
39 </a>
40 % endif
32 <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}">
33 % if comment.status_change:
34 ${_('Vote on pull request #%s') % comment.pull_request.pull_request_id}:
35 % else:
36 ${_('Comment on pull request #%s') % comment.pull_request.pull_request_id}
37 % endif
38 </a>
41 39 % else:
42 40 % if comment.status_change:
43 41 ${_('Status change on commit')}:
@@ -46,15 +44,51 b''
46 44 % endif
47 45 % endif
48 46 </div>
49 %if comment.status_change:
47 % endif
48
49 % if comment.status_change:
50 50 <div class="${'flag_status %s' % comment.status_change[0].status}"></div>
51 51 <div title="${_('Commit status')}" class="changeset-status-lbl">
52 52 ${comment.status_change[0].status_lbl}
53 53 </div>
54 %endif
54 % endif
55
55 56 <a class="permalink" href="#comment-${comment.comment_id}"> &para;</a>
56 57
57 58 <div class="comment-links-block">
59
60 % if inline:
61 % if outdated_at_ver:
62 <div class="pr-version-inline">
63 <a href="${h.url.current(version=comment.pull_request_version_id, anchor='comment-{}'.format(comment.comment_id))}">
64 <code class="pr-version-num">
65 outdated ${'v{}'.format(pr_index_ver)}
66 </code>
67 </a>
68 </div>
69 |
70 % endif
71 % else:
72 % if comment.pull_request_version_id and pr_index_ver:
73 |
74 <div class="pr-version">
75 % if comment.outdated:
76 <a href="?version=${comment.pull_request_version_id}#comment-${comment.comment_id}">
77 ${_('Outdated comment from pull request version {}').format(pr_index_ver)}
78 </a>
79 % else:
80 <div class="tooltip" title="${_('Comment from pull request version {0}').format(pr_index_ver)}">
81 <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id, version=comment.pull_request_version_id)}">
82 <code class="pr-version-num">
83 ${'v{}'.format(pr_index_ver)}
84 </code>
85 </a>
86 </div>
87 % endif
88 </div>
89 % endif
90 % endif
91
58 92 ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed
59 93 ## only super-admin, repo admin OR comment owner can delete, also hide delete if currently viewed comment is outdated
60 94 %if not outdated_at_ver and (not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed())):
@@ -176,10 +176,10 b' collapse_all = len(diffset.files) > coll'
176 176 '%(num)s files changed: %(linesadd)s inserted, %(linesdel)s deleted', diffset.changed_files) % {'num': diffset.changed_files, 'linesadd': diffset.lines_added, 'linesdel': diffset.lines_deleted}}
177 177 %endif
178 178
179 <% at_ver = getattr(c, 'at_version_num', None) %>
179 <% at_ver = getattr(c, 'at_version_pos', None) %>
180 180 % if at_ver:
181 181 <div class="pull-right">
182 ${_('Changes at version %d') % at_ver}
182 ${_('Showing changes at version %d') % at_ver}
183 183 </div>
184 184 % endif
185 185
@@ -203,8 +203,11 b''
203 203
204 204 ## SHOW ALL VERSIONS OF PR
205 205 <% ver_pr = None %>
206 % for ver in reversed(c.pull_request.versions()):
206 % for data in reversed(list(enumerate(c.versions, 1))):
207 <% ver_pos = data[0] %>
208 <% ver = data[1] %>
207 209 <% ver_pr = ver.pull_request_version_id %>
210
208 211 <tr class="version-pr" style="display: ${'' if c.at_version == ver_pr else 'none'}">
209 212 <td>
210 213 % if c.at_version == ver_pr:
@@ -214,7 +217,9 b''
214 217 % endif
215 218 </td>
216 219 <td>
217 <code><a href="${h.url.current(version=ver_pr)}">version ${ver_pr}</a></code>
220 <code class="tooltip" title="${_('Comment from pull request version {0}').format(ver_pos)}">
221 <a href="${h.url.current(version=ver_pr)}">v${ver_pos}</a>
222 </code>
218 223 </td>
219 224 <td>
220 225 <code>${ver.source_ref_parts.commit_id[:6]}</code>
General Comments 0
You need to be logged in to leave comments. Login now