Show More
@@ -1,287 +1,287 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | ## usage: |
|
3 | 3 | ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
4 | 4 | ## ${comment.comment_block(comment)} |
|
5 | 5 | ## |
|
6 | 6 | <%namespace name="base" file="/base/base.html"/> |
|
7 | 7 | |
|
8 | 8 | <%def name="comment_block(comment, inline=False)"> |
|
9 | 9 | <div |
|
10 | 10 | class="comment |
|
11 | 11 | ${'comment-inline' if inline else ''} |
|
12 | 12 | ${'comment-outdated' if comment.outdated else 'comment-current'}" |
|
13 | 13 | " |
|
14 | 14 | id="comment-${comment.comment_id}" |
|
15 | 15 | line="${comment.line_no}" |
|
16 | 16 | data-comment-id="${comment.comment_id}"> |
|
17 | 17 | <div class="meta"> |
|
18 | 18 | <div class="author"> |
|
19 | 19 | ${base.gravatar_with_user(comment.author.email, 16)} |
|
20 | 20 | </div> |
|
21 | 21 | <div class="date"> |
|
22 | 22 | ${h.age_component(comment.modified_at, time_is_local=True)} |
|
23 | 23 | </div> |
|
24 | 24 | <div class="status-change"> |
|
25 | 25 | %if comment.pull_request: |
|
26 | 26 | <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}"> |
|
27 | 27 | %if comment.status_change: |
|
28 | 28 | ${_('Vote on pull request #%s') % comment.pull_request.pull_request_id}: |
|
29 | 29 | %else: |
|
30 | 30 | ${_('Comment on pull request #%s') % comment.pull_request.pull_request_id} |
|
31 | 31 | %endif |
|
32 | 32 | </a> |
|
33 | 33 | %else: |
|
34 | 34 | %if comment.status_change: |
|
35 | 35 | ${_('Status change on commit')}: |
|
36 | 36 | %else: |
|
37 | 37 | ${_('Comment on commit')} |
|
38 | 38 | %endif |
|
39 | 39 | %endif |
|
40 | 40 | </div> |
|
41 | 41 | %if comment.status_change: |
|
42 | 42 | <div class="${'flag_status %s' % comment.status_change[0].status}"></div> |
|
43 | 43 | <div title="${_('Commit status')}" class="changeset-status-lbl"> |
|
44 | 44 | ${comment.status_change[0].status_lbl} |
|
45 | 45 | </div> |
|
46 | 46 | %endif |
|
47 | 47 | <a class="permalink" href="#comment-${comment.comment_id}"> ¶</a> |
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | <div class="comment-links-block"> |
|
51 | 51 | |
|
52 | 52 | ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed |
|
53 | 53 | ## only super-admin, repo admin OR comment owner can delete |
|
54 | 54 | %if not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed()): |
|
55 | 55 | %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id: |
|
56 | 56 | ## TODO: dan: add edit comment here |
|
57 | <a onclick="return Rhodecode.comments.deleteComment(this);" class="delete-comment"> ${_('Delete')}</a> | |
|
57 | <a onclick="return Rhodecode.comments.deleteComment(this);" class="delete-comment"> ${_('Delete')}</a> | | |
|
58 | 58 | %if not comment.outdated: |
|
59 | <a onclick="return Rhodecode.comments.prevComment(this);" class="prev-comment"> ${_('Prev')}</a> | |
|
59 | <a onclick="return Rhodecode.comments.prevComment(this);" class="prev-comment"> ${_('Prev')}</a> | | |
|
60 | 60 | <a onclick="return Rhodecode.comments.nextComment(this);" class="next-comment"> ${_('Next')}</a> |
|
61 | 61 | %endif |
|
62 | 62 | %endif |
|
63 | 63 | %endif |
|
64 | 64 | |
|
65 | 65 | </div> |
|
66 | 66 | </div> |
|
67 | 67 | <div class="text"> |
|
68 | 68 | ${comment.render(mentions=True)|n} |
|
69 | 69 | </div> |
|
70 | 70 | </div> |
|
71 | 71 | </%def> |
|
72 | 72 | |
|
73 | 73 | <%def name="comment_block_outdated(comment)"> |
|
74 | 74 | <div class="comments" id="comment-${comment.comment_id}"> |
|
75 | 75 | <div class="comment comment-wrapp"> |
|
76 | 76 | <div class="meta"> |
|
77 | 77 | <div class="author"> |
|
78 | 78 | ${base.gravatar_with_user(comment.author.email, 16)} |
|
79 | 79 | </div> |
|
80 | 80 | <div class="date"> |
|
81 | 81 | ${h.age_component(comment.modified_at, time_is_local=True)} |
|
82 | 82 | </div> |
|
83 | 83 | %if comment.status_change: |
|
84 | 84 | <span class="changeset-status-container"> |
|
85 | 85 | <span class="changeset-status-ico"> |
|
86 | 86 | <div class="${'flag_status %s' % comment.status_change[0].status}"></div> |
|
87 | 87 | </span> |
|
88 | 88 | <span title="${_('Commit status')}" class="changeset-status-lbl"> ${comment.status_change[0].status_lbl}</span> |
|
89 | 89 | </span> |
|
90 | 90 | %endif |
|
91 | 91 | <a class="permalink" href="#comment-${comment.comment_id}">¶</a> |
|
92 | 92 | ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed |
|
93 | 93 | ## only super-admin, repo admin OR comment owner can delete |
|
94 | 94 | %if not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed()): |
|
95 | 95 | <div class="comment-links-block"> |
|
96 | 96 | %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id: |
|
97 | 97 | <div data-comment-id=${comment.comment_id} class="delete-comment">${_('Delete')}</div> |
|
98 | 98 | %endif |
|
99 | 99 | </div> |
|
100 | 100 | %endif |
|
101 | 101 | </div> |
|
102 | 102 | <div class="text"> |
|
103 | 103 | ${comment.render(mentions=True)|n} |
|
104 | 104 | </div> |
|
105 | 105 | </div> |
|
106 | 106 | </div> |
|
107 | 107 | </%def> |
|
108 | 108 | |
|
109 | 109 | <%def name="comment_inline_form()"> |
|
110 | 110 | <div id="comment-inline-form-template" style="display: none;"> |
|
111 | 111 | <div class="comment-inline-form ac"> |
|
112 | 112 | %if c.rhodecode_user.username != h.DEFAULT_USER: |
|
113 | 113 | ${h.form('#', class_='inline-form', method='get')} |
|
114 | 114 | <div id="edit-container_{1}" class="clearfix"> |
|
115 | 115 | <div class="comment-title pull-left"> |
|
116 | 116 | ${_('Create a comment on line {1}.')} |
|
117 | 117 | </div> |
|
118 | 118 | <div class="comment-help pull-right"> |
|
119 | 119 | ${(_('Comments parsed using %s syntax with %s support.') % ( |
|
120 | 120 | ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())), |
|
121 | 121 | ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user')) |
|
122 | 122 | ) |
|
123 | 123 | )|n |
|
124 | 124 | } |
|
125 | 125 | </div> |
|
126 | 126 | <div style="clear: both"></div> |
|
127 | 127 | <textarea id="text_{1}" name="text" class="comment-block-ta ac-input"></textarea> |
|
128 | 128 | </div> |
|
129 | 129 | <div id="preview-container_{1}" class="clearfix" style="display: none;"> |
|
130 | 130 | <div class="comment-help"> |
|
131 | 131 | ${_('Comment preview')} |
|
132 | 132 | </div> |
|
133 | 133 | <div id="preview-box_{1}" class="preview-box"></div> |
|
134 | 134 | </div> |
|
135 | 135 | <div class="comment-footer"> |
|
136 | 136 | <div class="comment-button hide-inline-form-button cancel-button"> |
|
137 | 137 | ${h.reset('hide-inline-form', _('Cancel'), class_='btn hide-inline-form', id_="cancel-btn_{1}")} |
|
138 | 138 | </div> |
|
139 | 139 | <div class="action-buttons"> |
|
140 | 140 | <input type="hidden" name="f_path" value="{0}"> |
|
141 | 141 | <input type="hidden" name="line" value="{1}"> |
|
142 | 142 | <button id="preview-btn_{1}" class="btn btn-secondary">${_('Preview')}</button> |
|
143 | 143 | <button id="edit-btn_{1}" class="btn btn-secondary" style="display: none;">${_('Edit')}</button> |
|
144 | 144 | ${h.submit('save', _('Comment'), class_='btn btn-success save-inline-form')} |
|
145 | 145 | </div> |
|
146 | 146 | ${h.end_form()} |
|
147 | 147 | </div> |
|
148 | 148 | %else: |
|
149 | 149 | ${h.form('', class_='inline-form comment-form-login', method='get')} |
|
150 | 150 | <div class="pull-left"> |
|
151 | 151 | <div class="comment-help pull-right"> |
|
152 | 152 | ${_('You need to be logged in to comment.')} <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a> |
|
153 | 153 | </div> |
|
154 | 154 | </div> |
|
155 | 155 | <div class="comment-button pull-right"> |
|
156 | 156 | ${h.reset('hide-inline-form', _('Hide'), class_='btn hide-inline-form')} |
|
157 | 157 | </div> |
|
158 | 158 | <div class="clearfix"></div> |
|
159 | 159 | ${h.end_form()} |
|
160 | 160 | %endif |
|
161 | 161 | </div> |
|
162 | 162 | </div> |
|
163 | 163 | </%def> |
|
164 | 164 | |
|
165 | 165 | |
|
166 | 166 | ## generate main comments |
|
167 | 167 | <%def name="generate_comments(include_pull_request=False, is_pull_request=False)"> |
|
168 | 168 | %for comment in c.comments: |
|
169 | 169 | <div id="comment-tr-${comment.comment_id}"> |
|
170 | 170 | ## only render comments that are not from pull request, or from |
|
171 | 171 | ## pull request and a status change |
|
172 | 172 | %if not comment.pull_request or (comment.pull_request and comment.status_change) or include_pull_request: |
|
173 | 173 | ${comment_block(comment)} |
|
174 | 174 | %endif |
|
175 | 175 | </div> |
|
176 | 176 | %endfor |
|
177 | 177 | ## to anchor ajax comments |
|
178 | 178 | <div id="injected_page_comments"></div> |
|
179 | 179 | </%def> |
|
180 | 180 | |
|
181 | 181 | ## MAIN COMMENT FORM |
|
182 | 182 | <%def name="comments(post_url, cur_status, is_pull_request=False, is_compare=False, change_status=True, form_extras=None)"> |
|
183 | 183 | %if is_compare: |
|
184 | 184 | <% form_id = "comments_form_compare" %> |
|
185 | 185 | %else: |
|
186 | 186 | <% form_id = "comments_form" %> |
|
187 | 187 | %endif |
|
188 | 188 | |
|
189 | 189 | |
|
190 | 190 | %if is_pull_request: |
|
191 | 191 | <div class="pull-request-merge"> |
|
192 | 192 | %if c.allowed_to_merge: |
|
193 | 193 | <div class="pull-request-wrap"> |
|
194 | 194 | <div class="pull-right"> |
|
195 | 195 | ${h.secure_form(url('pullrequest_merge', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), id='merge_pull_request_form')} |
|
196 | 196 | <span data-role="merge-message">${c.pr_merge_msg} ${c.approval_msg if c.approval_msg else ''}</span> |
|
197 | 197 | <% merge_disabled = ' disabled' if c.pr_merge_status is False else '' %> |
|
198 | 198 | <input type="submit" id="merge_pull_request" value="${_('Merge Pull Request')}" class="btn${merge_disabled}"${merge_disabled}> |
|
199 | 199 | ${h.end_form()} |
|
200 | 200 | </div> |
|
201 | 201 | </div> |
|
202 | 202 | %else: |
|
203 | 203 | <div class="pull-request-wrap"> |
|
204 | 204 | <div class="pull-right"> |
|
205 | 205 | <span>${c.pr_merge_msg} ${c.approval_msg if c.approval_msg else ''}</span> |
|
206 | 206 | </div> |
|
207 | 207 | </div> |
|
208 | 208 | %endif |
|
209 | 209 | </div> |
|
210 | 210 | %endif |
|
211 | 211 | <div class="comments"> |
|
212 | 212 | %if c.rhodecode_user.username != h.DEFAULT_USER: |
|
213 | 213 | <div class="comment-form ac"> |
|
214 | 214 | ${h.secure_form(post_url, id_=form_id)} |
|
215 | 215 | <div id="edit-container" class="clearfix"> |
|
216 | 216 | <div class="comment-title pull-left"> |
|
217 | 217 | %if is_pull_request: |
|
218 | 218 | ${(_('Create a comment on this Pull Request.'))} |
|
219 | 219 | %elif is_compare: |
|
220 | 220 | ${(_('Create comments on this Commit range.'))} |
|
221 | 221 | %else: |
|
222 | 222 | ${(_('Create a comment on this Commit.'))} |
|
223 | 223 | %endif |
|
224 | 224 | </div> |
|
225 | 225 | <div class="comment-help pull-right"> |
|
226 | 226 | ${(_('Comments parsed using %s syntax with %s support.') % ( |
|
227 | 227 | ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())), |
|
228 | 228 | ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user')) |
|
229 | 229 | ) |
|
230 | 230 | )|n |
|
231 | 231 | } |
|
232 | 232 | </div> |
|
233 | 233 | <div style="clear: both"></div> |
|
234 | 234 | ${h.textarea('text', class_="comment-block-ta")} |
|
235 | 235 | </div> |
|
236 | 236 | |
|
237 | 237 | <div id="preview-container" class="clearfix" style="display: none;"> |
|
238 | 238 | <div class="comment-title"> |
|
239 | 239 | ${_('Comment preview')} |
|
240 | 240 | </div> |
|
241 | 241 | <div id="preview-box" class="preview-box"></div> |
|
242 | 242 | </div> |
|
243 | 243 | |
|
244 | 244 | <div id="comment_form_extras"> |
|
245 | 245 | %if form_extras and isinstance(form_extras, (list, tuple)): |
|
246 | 246 | % for form_ex_el in form_extras: |
|
247 | 247 | ${form_ex_el|n} |
|
248 | 248 | % endfor |
|
249 | 249 | %endif |
|
250 | 250 | </div> |
|
251 | 251 | <div class="comment-footer"> |
|
252 | 252 | %if change_status: |
|
253 | 253 | <div class="status_box"> |
|
254 | 254 | <select id="change_status" name="changeset_status"> |
|
255 | 255 | <option></option> # Placeholder |
|
256 | 256 | %for status,lbl in c.commit_statuses: |
|
257 | 257 | <option value="${status}" data-status="${status}">${lbl}</option> |
|
258 | 258 | %if is_pull_request and change_status and status in ('approved', 'rejected'): |
|
259 | 259 | <option value="${status}_closed" data-status="${status}">${lbl} & ${_('Closed')}</option> |
|
260 | 260 | %endif |
|
261 | 261 | %endfor |
|
262 | 262 | </select> |
|
263 | 263 | </div> |
|
264 | 264 | %endif |
|
265 | 265 | <div class="action-buttons"> |
|
266 | 266 | <button id="preview-btn" class="btn btn-secondary">${_('Preview')}</button> |
|
267 | 267 | <button id="edit-btn" class="btn btn-secondary" style="display:none;">${_('Edit')}</button> |
|
268 | 268 | <div class="comment-button">${h.submit('save', _('Comment'), class_="btn btn-success comment-button-input")}</div> |
|
269 | 269 | </div> |
|
270 | 270 | </div> |
|
271 | 271 | ${h.end_form()} |
|
272 | 272 | </div> |
|
273 | 273 | %endif |
|
274 | 274 | </div> |
|
275 | 275 | <script> |
|
276 | 276 | // init active elements of commentForm |
|
277 | 277 | var commitId = templateContext.commit_data.commit_id; |
|
278 | 278 | var pullRequestId = templateContext.pull_request_data.pull_request_id; |
|
279 | 279 | var lineNo; |
|
280 | 280 | |
|
281 | 281 | var mainCommentForm = new CommentForm( |
|
282 | 282 | "#${form_id}", commitId, pullRequestId, lineNo, true); |
|
283 | 283 | |
|
284 | 284 | mainCommentForm.initStatusChangeSelector(); |
|
285 | 285 | bindToggleButtons(); |
|
286 | 286 | </script> |
|
287 | 287 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now