##// END OF EJS Templates
pull-requests: show more info about version of comment vs latest version.
marcink -
r2809:f9dcd621 default
parent child Browse files
Show More
@@ -1,406 +1,407 b''
1 1 ## -*- coding: utf-8 -*-
2 2 ## usage:
3 3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
4 4 ## ${comment.comment_block(comment)}
5 5 ##
6 6 <%namespace name="base" file="/base/base.mako"/>
7 7
8 8 <%def name="comment_block(comment, inline=False)">
9 9 <% pr_index_ver = comment.get_index_version(getattr(c, 'versions', [])) %>
10 <% latest_ver = len(getattr(c, 'versions', [])) %>
10 11 % if inline:
11 12 <% outdated_at_ver = comment.outdated_at_version(getattr(c, 'at_version_num', None)) %>
12 13 % else:
13 14 <% outdated_at_ver = comment.older_than_version(getattr(c, 'at_version_num', None)) %>
14 15 % endif
15 16
16 17
17 18 <div class="comment
18 19 ${'comment-inline' if inline else 'comment-general'}
19 20 ${'comment-outdated' if outdated_at_ver else 'comment-current'}"
20 21 id="comment-${comment.comment_id}"
21 22 line="${comment.line_no}"
22 23 data-comment-id="${comment.comment_id}"
23 24 data-comment-type="${comment.comment_type}"
24 25 data-comment-line-no="${comment.line_no}"
25 26 data-comment-inline=${h.json.dumps(inline)}
26 27 style="${'display: none;' if outdated_at_ver else ''}">
27 28
28 29 <div class="meta">
29 30 <div class="comment-type-label">
30 31 <div class="comment-label ${comment.comment_type or 'note'}" id="comment-label-${comment.comment_id}">
31 32 % if comment.comment_type == 'todo':
32 33 % if comment.resolved:
33 34 <div class="resolved tooltip" title="${_('Resolved by comment #{}').format(comment.resolved.comment_id)}">
34 35 <a href="#comment-${comment.resolved.comment_id}">${comment.comment_type}</a>
35 36 </div>
36 37 % else:
37 38 <div class="resolved tooltip" style="display: none">
38 39 <span>${comment.comment_type}</span>
39 40 </div>
40 41 <div class="resolve tooltip" onclick="return Rhodecode.comments.createResolutionComment(${comment.comment_id});" title="${_('Click to resolve this comment')}">
41 42 ${comment.comment_type}
42 43 </div>
43 44 % endif
44 45 % else:
45 46 % if comment.resolved_comment:
46 47 fix
47 48 % else:
48 49 ${comment.comment_type or 'note'}
49 50 % endif
50 51 % endif
51 52 </div>
52 53 </div>
53 54
54 55 <div class="author ${'author-inline' if inline else 'author-general'}">
55 56 ${base.gravatar_with_user(comment.author.email, 16)}
56 57 </div>
57 58 <div class="date">
58 59 ${h.age_component(comment.modified_at, time_is_local=True)}
59 60 </div>
60 61 % if inline:
61 62 <span></span>
62 63 % else:
63 64 <div class="status-change">
64 65 % if comment.pull_request:
65 66 <a href="${h.route_path('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}">
66 67 % if comment.status_change:
67 68 ${_('pull request #%s') % comment.pull_request.pull_request_id}:
68 69 % else:
69 70 ${_('pull request #%s') % comment.pull_request.pull_request_id}
70 71 % endif
71 72 </a>
72 73 % else:
73 74 % if comment.status_change:
74 75 ${_('Status change on commit')}:
75 76 % endif
76 77 % endif
77 78 </div>
78 79 % endif
79 80
80 81 % if comment.status_change:
81 82 <div class="${'flag_status %s' % comment.status_change[0].status}"></div>
82 83 <div title="${_('Commit status')}" class="changeset-status-lbl">
83 84 ${comment.status_change[0].status_lbl}
84 85 </div>
85 86 % endif
86 87
87 88 % if comment.resolved_comment:
88 89 <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)})">
89 90 ${_('resolves comment #{}').format(comment.resolved_comment.comment_id)}
90 91 </a>
91 92 % endif
92 93
93 94 <a class="permalink" href="#comment-${comment.comment_id}"> &para;</a>
94 95
95 96 <div class="comment-links-block">
96 97 % if comment.pull_request and comment.pull_request.author.user_id == comment.author.user_id:
97 98 <span class="tag authortag tooltip" title="${_('Pull request author')}">
98 99 ${_('author')}
99 100 </span>
100 101 |
101 102 % endif
102 103 % if inline:
103 104 <div class="pr-version-inline">
104 105 <a href="${request.current_route_path(_query=dict(version=comment.pull_request_version_id), _anchor='comment-{}'.format(comment.comment_id))}">
105 106 % if outdated_at_ver:
106 <code class="pr-version-num" title="${_('Outdated comment from pull request version {0}').format(pr_index_ver)}">
107 <code class="pr-version-num" title="${_('Outdated comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}">
107 108 outdated ${'v{}'.format(pr_index_ver)} |
108 109 </code>
109 110 % elif pr_index_ver:
110 <code class="pr-version-num" title="${_('Comment from pull request version {0}').format(pr_index_ver)}">
111 <code class="pr-version-num" title="${_('Comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}">
111 112 ${'v{}'.format(pr_index_ver)} |
112 113 </code>
113 114 % endif
114 115 </a>
115 116 </div>
116 117 % else:
117 118 % if comment.pull_request_version_id and pr_index_ver:
118 119 |
119 120 <div class="pr-version">
120 121 % if comment.outdated:
121 122 <a href="?version=${comment.pull_request_version_id}#comment-${comment.comment_id}">
122 ${_('Outdated comment from pull request version {}').format(pr_index_ver)}
123 ${_('Outdated comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}
123 124 </a>
124 125 % else:
125 <div title="${_('Comment from pull request version {0}').format(pr_index_ver)}">
126 <div title="${_('Comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}">
126 127 <a href="${h.route_path('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)}">
127 128 <code class="pr-version-num">
128 129 ${'v{}'.format(pr_index_ver)}
129 130 </code>
130 131 </a>
131 132 </div>
132 133 % endif
133 134 </div>
134 135 % endif
135 136 % endif
136 137
137 138 ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed
138 139 ## only super-admin, repo admin OR comment owner can delete, also hide delete if currently viewed comment is outdated
139 140 %if not outdated_at_ver and (not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed())):
140 141 ## permissions to delete
141 142 %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id:
142 143 ## TODO: dan: add edit comment here
143 144 <a onclick="return Rhodecode.comments.deleteComment(this);" class="delete-comment"> ${_('Delete')}</a>
144 145 %else:
145 146 <button class="btn-link" disabled="disabled"> ${_('Delete')}</button>
146 147 %endif
147 148 %else:
148 149 <button class="btn-link" disabled="disabled"> ${_('Delete')}</button>
149 150 %endif
150 151
151 152 % if outdated_at_ver:
152 153 | <a onclick="return Rhodecode.comments.prevOutdatedComment(this);" class="prev-comment"> ${_('Prev')}</a>
153 154 | <a onclick="return Rhodecode.comments.nextOutdatedComment(this);" class="next-comment"> ${_('Next')}</a>
154 155 % else:
155 156 | <a onclick="return Rhodecode.comments.prevComment(this);" class="prev-comment"> ${_('Prev')}</a>
156 157 | <a onclick="return Rhodecode.comments.nextComment(this);" class="next-comment"> ${_('Next')}</a>
157 158 % endif
158 159
159 160 </div>
160 161 </div>
161 162 <div class="text">
162 163 ${h.render(comment.text, renderer=comment.renderer, mentions=True)}
163 164 </div>
164 165
165 166 </div>
166 167 </%def>
167 168
168 169 ## generate main comments
169 170 <%def name="generate_comments(comments, include_pull_request=False, is_pull_request=False)">
170 171 <div class="general-comments" id="comments">
171 172 %for comment in comments:
172 173 <div id="comment-tr-${comment.comment_id}">
173 174 ## only render comments that are not from pull request, or from
174 175 ## pull request and a status change
175 176 %if not comment.pull_request or (comment.pull_request and comment.status_change) or include_pull_request:
176 177 ${comment_block(comment)}
177 178 %endif
178 179 </div>
179 180 %endfor
180 181 ## to anchor ajax comments
181 182 <div id="injected_page_comments"></div>
182 183 </div>
183 184 </%def>
184 185
185 186
186 187 <%def name="comments(post_url, cur_status, is_pull_request=False, is_compare=False, change_status=True, form_extras=None)">
187 188
188 189 <div class="comments">
189 190 <%
190 191 if is_pull_request:
191 192 placeholder = _('Leave a comment on this Pull Request.')
192 193 elif is_compare:
193 194 placeholder = _('Leave a comment on {} commits in this range.').format(len(form_extras))
194 195 else:
195 196 placeholder = _('Leave a comment on this Commit.')
196 197 %>
197 198
198 199 % if c.rhodecode_user.username != h.DEFAULT_USER:
199 200 <div class="js-template" id="cb-comment-general-form-template">
200 201 ## template generated for injection
201 202 ${comment_form(form_type='general', review_statuses=c.commit_statuses, form_extras=form_extras)}
202 203 </div>
203 204
204 205 <div id="cb-comment-general-form-placeholder" class="comment-form ac">
205 206 ## inject form here
206 207 </div>
207 208 <script type="text/javascript">
208 209 var lineNo = 'general';
209 210 var resolvesCommentId = null;
210 211 var generalCommentForm = Rhodecode.comments.createGeneralComment(
211 212 lineNo, "${placeholder}", resolvesCommentId);
212 213
213 214 // set custom success callback on rangeCommit
214 215 % if is_compare:
215 216 generalCommentForm.setHandleFormSubmit(function(o) {
216 217 var self = generalCommentForm;
217 218
218 219 var text = self.cm.getValue();
219 220 var status = self.getCommentStatus();
220 221 var commentType = self.getCommentType();
221 222
222 223 if (text === "" && !status) {
223 224 return;
224 225 }
225 226
226 227 // we can pick which commits we want to make the comment by
227 228 // selecting them via click on preview pane, this will alter the hidden inputs
228 229 var cherryPicked = $('#changeset_compare_view_content .compare_select.hl').length > 0;
229 230
230 231 var commitIds = [];
231 232 $('#changeset_compare_view_content .compare_select').each(function(el) {
232 233 var commitId = this.id.replace('row-', '');
233 234 if ($(this).hasClass('hl') || !cherryPicked) {
234 235 $("input[data-commit-id='{0}']".format(commitId)).val(commitId);
235 236 commitIds.push(commitId);
236 237 } else {
237 238 $("input[data-commit-id='{0}']".format(commitId)).val('')
238 239 }
239 240 });
240 241
241 242 self.setActionButtonsDisabled(true);
242 243 self.cm.setOption("readOnly", true);
243 244 var postData = {
244 245 'text': text,
245 246 'changeset_status': status,
246 247 'comment_type': commentType,
247 248 'commit_ids': commitIds,
248 249 'csrf_token': CSRF_TOKEN
249 250 };
250 251
251 252 var submitSuccessCallback = function(o) {
252 253 location.reload(true);
253 254 };
254 255 var submitFailCallback = function(){
255 256 self.resetCommentFormState(text)
256 257 };
257 258 self.submitAjaxPOST(
258 259 self.submitUrl, postData, submitSuccessCallback, submitFailCallback);
259 260 });
260 261 % endif
261 262
262 263
263 264 </script>
264 265 % else:
265 266 ## form state when not logged in
266 267 <div class="comment-form ac">
267 268
268 269 <div class="comment-area">
269 270 <div class="comment-area-header">
270 271 <ul class="nav-links clearfix">
271 272 <li class="active">
272 273 <a class="disabled" href="#edit-btn" disabled="disabled" onclick="return false">${_('Write')}</a>
273 274 </li>
274 275 <li class="">
275 276 <a class="disabled" href="#preview-btn" disabled="disabled" onclick="return false">${_('Preview')}</a>
276 277 </li>
277 278 </ul>
278 279 </div>
279 280
280 281 <div class="comment-area-write" style="display: block;">
281 282 <div id="edit-container">
282 283 <div style="padding: 40px 0">
283 284 ${_('You need to be logged in to leave comments.')}
284 285 <a href="${h.route_path('login', _query={'came_from': h.current_route_path(request)})}">${_('Login now')}</a>
285 286 </div>
286 287 </div>
287 288 <div id="preview-container" class="clearfix" style="display: none;">
288 289 <div id="preview-box" class="preview-box"></div>
289 290 </div>
290 291 </div>
291 292
292 293 <div class="comment-area-footer">
293 294 <div class="toolbar">
294 295 <div class="toolbar-text">
295 296 </div>
296 297 </div>
297 298 </div>
298 299 </div>
299 300
300 301 <div class="comment-footer">
301 302 </div>
302 303
303 304 </div>
304 305 % endif
305 306
306 307 <script type="text/javascript">
307 308 bindToggleButtons();
308 309 </script>
309 310 </div>
310 311 </%def>
311 312
312 313
313 314 <%def name="comment_form(form_type, form_id='', lineno_id='{1}', review_statuses=None, form_extras=None)">
314 315 ## comment injected based on assumption that user is logged in
315 316
316 317 <form ${'id="{}"'.format(form_id) if form_id else '' |n} action="#" method="GET">
317 318
318 319 <div class="comment-area">
319 320 <div class="comment-area-header">
320 321 <ul class="nav-links clearfix">
321 322 <li class="active">
322 323 <a href="#edit-btn" tabindex="-1" id="edit-btn_${lineno_id}">${_('Write')}</a>
323 324 </li>
324 325 <li class="">
325 326 <a href="#preview-btn" tabindex="-1" id="preview-btn_${lineno_id}">${_('Preview')}</a>
326 327 </li>
327 328 <li class="pull-right">
328 329 <select class="comment-type" id="comment_type_${lineno_id}" name="comment_type">
329 330 % for val in c.visual.comment_types:
330 331 <option value="${val}">${val.upper()}</option>
331 332 % endfor
332 333 </select>
333 334 </li>
334 335 </ul>
335 336 </div>
336 337
337 338 <div class="comment-area-write" style="display: block;">
338 339 <div id="edit-container_${lineno_id}">
339 340 <textarea id="text_${lineno_id}" name="text" class="comment-block-ta ac-input"></textarea>
340 341 </div>
341 342 <div id="preview-container_${lineno_id}" class="clearfix" style="display: none;">
342 343 <div id="preview-box_${lineno_id}" class="preview-box"></div>
343 344 </div>
344 345 </div>
345 346
346 347 <div class="comment-area-footer">
347 348 <div class="toolbar">
348 349 <div class="toolbar-text">
349 350 ${(_('Comments parsed using %s syntax with %s, and %s actions support.') % (
350 351 ('<a href="%s">%s</a>' % (h.route_url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
351 352 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user')),
352 353 ('<span class="tooltip" title="%s">`/`</span>' % _('Start typing with / for certain actions to be triggered via text box.'))
353 354 )
354 355 )|n}
355 356 </div>
356 357 </div>
357 358 </div>
358 359 </div>
359 360
360 361 <div class="comment-footer">
361 362
362 363 % if review_statuses:
363 364 <div class="status_box">
364 365 <select id="change_status_${lineno_id}" name="changeset_status">
365 366 <option></option> ## Placeholder
366 367 % for status, lbl in review_statuses:
367 368 <option value="${status}" data-status="${status}">${lbl}</option>
368 369 %if is_pull_request and change_status and status in ('approved', 'rejected'):
369 370 <option value="${status}_closed" data-status="${status}">${lbl} & ${_('Closed')}</option>
370 371 %endif
371 372 % endfor
372 373 </select>
373 374 </div>
374 375 % endif
375 376
376 377 ## inject extra inputs into the form
377 378 % if form_extras and isinstance(form_extras, (list, tuple)):
378 379 <div id="comment_form_extras">
379 380 % for form_ex_el in form_extras:
380 381 ${form_ex_el|n}
381 382 % endfor
382 383 </div>
383 384 % endif
384 385
385 386 <div class="action-buttons">
386 387 ## inline for has a file, and line-number together with cancel hide button.
387 388 % if form_type == 'inline':
388 389 <input type="hidden" name="f_path" value="{0}">
389 390 <input type="hidden" name="line" value="${lineno_id}">
390 391 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
391 392 ${_('Cancel')}
392 393 </button>
393 394 % endif
394 395
395 396 % if form_type != 'inline':
396 397 <div class="action-buttons-extra"></div>
397 398 % endif
398 399
399 400 ${h.submit('save', _('Comment'), class_='btn btn-success comment-button-input')}
400 401
401 402 </div>
402 403 </div>
403 404
404 405 </form>
405 406
406 407 </%def> No newline at end of file
@@ -1,856 +1,856 b''
1 1 <%inherit file="/base/base.mako"/>
2 2 <%namespace name="base" file="/base/base.mako"/>
3 3
4 4 <%def name="title()">
5 5 ${_('%s Pull Request #%s') % (c.repo_name, c.pull_request.pull_request_id)}
6 6 %if c.rhodecode_name:
7 7 &middot; ${h.branding(c.rhodecode_name)}
8 8 %endif
9 9 </%def>
10 10
11 11 <%def name="breadcrumbs_links()">
12 12 <span id="pr-title">
13 13 ${c.pull_request.title}
14 14 %if c.pull_request.is_closed():
15 15 (${_('Closed')})
16 16 %endif
17 17 </span>
18 18 <div id="pr-title-edit" class="input" style="display: none;">
19 19 ${h.text('pullrequest_title', id_="pr-title-input", class_="large", value=c.pull_request.title)}
20 20 </div>
21 21 </%def>
22 22
23 23 <%def name="menu_bar_nav()">
24 24 ${self.menu_items(active='repositories')}
25 25 </%def>
26 26
27 27 <%def name="menu_bar_subnav()">
28 28 ${self.repo_menu(active='showpullrequest')}
29 29 </%def>
30 30
31 31 <%def name="main()">
32 32
33 33 <script type="text/javascript">
34 34 // TODO: marcink switch this to pyroutes
35 35 AJAX_COMMENT_DELETE_URL = "${h.route_path('pullrequest_comment_delete',repo_name=c.repo_name,pull_request_id=c.pull_request.pull_request_id,comment_id='__COMMENT_ID__')}";
36 36 templateContext.pull_request_data.pull_request_id = ${c.pull_request.pull_request_id};
37 37 </script>
38 38 <div class="box">
39 39
40 40 <div class="title">
41 41 ${self.repo_page_title(c.rhodecode_db_repo)}
42 42 </div>
43 43
44 44 ${self.breadcrumbs()}
45 45
46 46 <div class="box pr-summary">
47 47
48 48 <div class="summary-details block-left">
49 49 <% summary = lambda n:{False:'summary-short'}.get(n) %>
50 50 <div class="pr-details-title">
51 51 <a href="${h.route_path('pull_requests_global', pull_request_id=c.pull_request.pull_request_id)}">${_('Pull request #%s') % c.pull_request.pull_request_id}</a> ${_('From')} ${h.format_date(c.pull_request.created_on)}
52 52 %if c.allowed_to_update:
53 53 <div id="delete_pullrequest" class="pull-right action_button ${'' if c.allowed_to_delete else 'disabled' }" style="clear:inherit;padding: 0">
54 54 % if c.allowed_to_delete:
55 55 ${h.secure_form(h.route_path('pullrequest_delete', repo_name=c.pull_request.target_repo.repo_name, pull_request_id=c.pull_request.pull_request_id), request=request)}
56 56 ${h.submit('remove_%s' % c.pull_request.pull_request_id, _('Delete'),
57 57 class_="btn btn-link btn-danger no-margin",onclick="return confirm('"+_('Confirm to delete this pull request')+"');")}
58 58 ${h.end_form()}
59 59 % else:
60 60 ${_('Delete')}
61 61 % endif
62 62 </div>
63 63 <div id="open_edit_pullrequest" class="pull-right action_button">${_('Edit')}</div>
64 64 <div id="close_edit_pullrequest" class="pull-right action_button" style="display: none;padding: 0">${_('Cancel')}</div>
65 65 %endif
66 66 </div>
67 67
68 68 <div id="summary" class="fields pr-details-content">
69 69 <div class="field">
70 70 <div class="label-summary">
71 71 <label>${_('Source')}:</label>
72 72 </div>
73 73 <div class="input">
74 74 <div class="pr-origininfo">
75 75 ## branch link is only valid if it is a branch
76 76 <span class="tag">
77 77 %if c.pull_request.source_ref_parts.type == 'branch':
78 78 <a href="${h.route_path('repo_changelog', repo_name=c.pull_request.source_repo.repo_name, _query=dict(branch=c.pull_request.source_ref_parts.name))}">${c.pull_request.source_ref_parts.type}: ${c.pull_request.source_ref_parts.name}</a>
79 79 %else:
80 80 ${c.pull_request.source_ref_parts.type}: ${c.pull_request.source_ref_parts.name}
81 81 %endif
82 82 </span>
83 83 <span class="clone-url">
84 84 <a href="${h.route_path('repo_summary', repo_name=c.pull_request.source_repo.repo_name)}">${c.pull_request.source_repo.clone_url()}</a>
85 85 </span>
86 86 <br/>
87 87 % if c.ancestor_commit:
88 88 ${_('Common ancestor')}:
89 89 <code><a href="${h.route_path('repo_commit', repo_name=c.target_repo.repo_name, commit_id=c.ancestor_commit.raw_id)}">${h.show_id(c.ancestor_commit)}</a></code>
90 90 % endif
91 91 </div>
92 92 %if h.is_hg(c.pull_request.source_repo):
93 93 <% clone_url = 'hg pull -r {} {}'.format(h.short_id(c.source_ref), c.pull_request.source_repo.clone_url()) %>
94 94 %elif h.is_git(c.pull_request.source_repo):
95 95 <% clone_url = 'git pull {} {}'.format(c.pull_request.source_repo.clone_url(), c.pull_request.source_ref_parts.name) %>
96 96 %endif
97 97
98 98 <div class="">
99 99 <input type="text" class="input-monospace pr-pullinfo" value="${clone_url}" readonly="readonly">
100 100 <i class="tooltip icon-clipboard clipboard-action pull-right pr-pullinfo-copy" data-clipboard-text="${clone_url}" title="${_('Copy the pull url')}"></i>
101 101 </div>
102 102
103 103 </div>
104 104 </div>
105 105 <div class="field">
106 106 <div class="label-summary">
107 107 <label>${_('Target')}:</label>
108 108 </div>
109 109 <div class="input">
110 110 <div class="pr-targetinfo">
111 111 ## branch link is only valid if it is a branch
112 112 <span class="tag">
113 113 %if c.pull_request.target_ref_parts.type == 'branch':
114 114 <a href="${h.route_path('repo_changelog', repo_name=c.pull_request.target_repo.repo_name, _query=dict(branch=c.pull_request.target_ref_parts.name))}">${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}</a>
115 115 %else:
116 116 ${c.pull_request.target_ref_parts.type}: ${c.pull_request.target_ref_parts.name}
117 117 %endif
118 118 </span>
119 119 <span class="clone-url">
120 120 <a href="${h.route_path('repo_summary', repo_name=c.pull_request.target_repo.repo_name)}">${c.pull_request.target_repo.clone_url()}</a>
121 121 </span>
122 122 </div>
123 123 </div>
124 124 </div>
125 125
126 126 ## Link to the shadow repository.
127 127 <div class="field">
128 128 <div class="label-summary">
129 129 <label>${_('Merge')}:</label>
130 130 </div>
131 131 <div class="input">
132 132 % if not c.pull_request.is_closed() and c.pull_request.shadow_merge_ref:
133 133 %if h.is_hg(c.pull_request.target_repo):
134 134 <% clone_url = 'hg clone --update {} {} pull-request-{}'.format(c.pull_request.shadow_merge_ref.name, c.shadow_clone_url, c.pull_request.pull_request_id) %>
135 135 %elif h.is_git(c.pull_request.target_repo):
136 136 <% clone_url = 'git clone --branch {} {} pull-request-{}'.format(c.pull_request.shadow_merge_ref.name, c.shadow_clone_url, c.pull_request.pull_request_id) %>
137 137 %endif
138 138 <div class="">
139 139 <input type="text" class="input-monospace pr-mergeinfo" value="${clone_url}" readonly="readonly">
140 140 <i class="tooltip icon-clipboard clipboard-action pull-right pr-mergeinfo-copy" data-clipboard-text="${clone_url}" title="${_('Copy the clone url')}"></i>
141 141 </div>
142 142 % else:
143 143 <div class="">
144 144 ${_('Shadow repository data not available')}.
145 145 </div>
146 146 % endif
147 147 </div>
148 148 </div>
149 149
150 150 <div class="field">
151 151 <div class="label-summary">
152 152 <label>${_('Review')}:</label>
153 153 </div>
154 154 <div class="input">
155 155 %if c.pull_request_review_status:
156 156 <div class="${'flag_status %s' % c.pull_request_review_status} tooltip pull-left"></div>
157 157 <span class="changeset-status-lbl tooltip">
158 158 %if c.pull_request.is_closed():
159 159 ${_('Closed')},
160 160 %endif
161 161 ${h.commit_status_lbl(c.pull_request_review_status)}
162 162 </span>
163 163 - ${_ungettext('calculated based on %s reviewer vote', 'calculated based on %s reviewers votes', len(c.pull_request_reviewers)) % len(c.pull_request_reviewers)}
164 164 %endif
165 165 </div>
166 166 </div>
167 167 <div class="field">
168 168 <div class="pr-description-label label-summary">
169 169 <label>${_('Description')}:</label>
170 170 </div>
171 171 <div id="pr-desc" class="input">
172 172 <div class="pr-description">${h.urlify_commit_message(c.pull_request.description, c.repo_name)}</div>
173 173 </div>
174 174 <div id="pr-desc-edit" class="input textarea editor" style="display: none;">
175 175 <textarea id="pr-description-input" size="30">${c.pull_request.description}</textarea>
176 176 </div>
177 177 </div>
178 178
179 179 <div class="field">
180 180 <div class="label-summary">
181 181 <label>${_('Versions')}:</label>
182 182 </div>
183 183
184 184 <% outdated_comm_count_ver = len(c.inline_versions[None]['outdated']) %>
185 185 <% general_outdated_comm_count_ver = len(c.comment_versions[None]['outdated']) %>
186 186
187 187 <div class="pr-versions">
188 188 % if c.show_version_changes:
189 189 <% outdated_comm_count_ver = len(c.inline_versions[c.at_version_num]['outdated']) %>
190 190 <% general_outdated_comm_count_ver = len(c.comment_versions[c.at_version_num]['outdated']) %>
191 191 <a id="show-pr-versions" class="input" onclick="return versionController.toggleVersionView(this)" href="#show-pr-versions"
192 192 data-toggle-on="${_ungettext('{} version available for this pull request, show it.', '{} versions available for this pull request, show them.', len(c.versions)).format(len(c.versions))}"
193 193 data-toggle-off="${_('Hide all versions of this pull request')}">
194 194 ${_ungettext('{} version available for this pull request, show it.', '{} versions available for this pull request, show them.', len(c.versions)).format(len(c.versions))}
195 195 </a>
196 196 <table>
197 197 ## SHOW ALL VERSIONS OF PR
198 198 <% ver_pr = None %>
199 199
200 200 % for data in reversed(list(enumerate(c.versions, 1))):
201 201 <% ver_pos = data[0] %>
202 202 <% ver = data[1] %>
203 203 <% ver_pr = ver.pull_request_version_id %>
204 204 <% display_row = '' if c.at_version and (c.at_version_num == ver_pr or c.from_version_num == ver_pr) else 'none' %>
205 205
206 206 <tr class="version-pr" style="display: ${display_row}">
207 207 <td>
208 208 <code>
209 209 <a href="${request.current_route_path(_query=dict(version=ver_pr or 'latest'))}">v${ver_pos}</a>
210 210 </code>
211 211 </td>
212 212 <td>
213 213 <input ${'checked="checked"' if c.from_version_num == ver_pr else ''} class="compare-radio-button" type="radio" name="ver_source" value="${ver_pr or 'latest'}" data-ver-pos="${ver_pos}"/>
214 214 <input ${'checked="checked"' if c.at_version_num == ver_pr else ''} class="compare-radio-button" type="radio" name="ver_target" value="${ver_pr or 'latest'}" data-ver-pos="${ver_pos}"/>
215 215 </td>
216 216 <td>
217 217 <% review_status = c.review_versions[ver_pr].status if ver_pr in c.review_versions else 'not_reviewed' %>
218 218 <div class="${'flag_status %s' % review_status} tooltip pull-left" title="${_('Your review status at this version')}">
219 219 </div>
220 220 </td>
221 221 <td>
222 222 % if c.at_version_num != ver_pr:
223 223 <i class="icon-comment"></i>
224 <code class="tooltip" title="${_('Comment from pull request version {0}, general:{1} inline:{2}').format(ver_pos, len(c.comment_versions[ver_pr]['at']), len(c.inline_versions[ver_pr]['at']))}">
224 <code class="tooltip" title="${_('Comment from pull request version v{0}, general:{1} inline:{2}').format(ver_pos, len(c.comment_versions[ver_pr]['at']), len(c.inline_versions[ver_pr]['at']))}">
225 225 G:${len(c.comment_versions[ver_pr]['at'])} / I:${len(c.inline_versions[ver_pr]['at'])}
226 226 </code>
227 227 % endif
228 228 </td>
229 229 <td>
230 230 ##<code>${ver.source_ref_parts.commit_id[:6]}</code>
231 231 </td>
232 232 <td>
233 233 ${h.age_component(ver.updated_on, time_is_local=True)}
234 234 </td>
235 235 </tr>
236 236 % endfor
237 237
238 238 <tr>
239 239 <td colspan="6">
240 240 <button id="show-version-diff" onclick="return versionController.showVersionDiff()" class="btn btn-sm" style="display: none"
241 241 data-label-text-locked="${_('select versions to show changes')}"
242 242 data-label-text-diff="${_('show changes between versions')}"
243 243 data-label-text-show="${_('show pull request for this version')}"
244 244 >
245 245 ${_('select versions to show changes')}
246 246 </button>
247 247 </td>
248 248 </tr>
249 249
250 250 ## show comment/inline comments summary
251 251 <%def name="comments_summary()">
252 252 <tr>
253 253 <td colspan="6" class="comments-summary-td">
254 254
255 255 % if c.at_version:
256 256 <% inline_comm_count_ver = len(c.inline_versions[c.at_version_num]['display']) %>
257 257 <% general_comm_count_ver = len(c.comment_versions[c.at_version_num]['display']) %>
258 258 ${_('Comments at this version')}:
259 259 % else:
260 260 <% inline_comm_count_ver = len(c.inline_versions[c.at_version_num]['until']) %>
261 261 <% general_comm_count_ver = len(c.comment_versions[c.at_version_num]['until']) %>
262 262 ${_('Comments for this pull request')}:
263 263 % endif
264 264
265 265
266 266 %if general_comm_count_ver:
267 267 <a href="#comments">${_("%d General ") % general_comm_count_ver}</a>
268 268 %else:
269 269 ${_("%d General ") % general_comm_count_ver}
270 270 %endif
271 271
272 272 %if inline_comm_count_ver:
273 273 , <a href="#" onclick="return Rhodecode.comments.nextComment();" id="inline-comments-counter">${_("%d Inline") % inline_comm_count_ver}</a>
274 274 %else:
275 275 , ${_("%d Inline") % inline_comm_count_ver}
276 276 %endif
277 277
278 278 %if outdated_comm_count_ver:
279 279 , <a href="#" onclick="showOutdated(); Rhodecode.comments.nextOutdatedComment(); return false;">${_("%d Outdated") % outdated_comm_count_ver}</a>
280 280 <a href="#" class="showOutdatedComments" onclick="showOutdated(this); return false;"> | ${_('show outdated comments')}</a>
281 281 <a href="#" class="hideOutdatedComments" style="display: none" onclick="hideOutdated(this); return false;"> | ${_('hide outdated comments')}</a>
282 282 %else:
283 283 , ${_("%d Outdated") % outdated_comm_count_ver}
284 284 %endif
285 285 </td>
286 286 </tr>
287 287 </%def>
288 288 ${comments_summary()}
289 289 </table>
290 290 % else:
291 291 <div class="input">
292 292 ${_('Pull request versions not available')}.
293 293 </div>
294 294 <div>
295 295 <table>
296 296 ${comments_summary()}
297 297 </table>
298 298 </div>
299 299 % endif
300 300 </div>
301 301 </div>
302 302
303 303 <div id="pr-save" class="field" style="display: none;">
304 304 <div class="label-summary"></div>
305 305 <div class="input">
306 306 <span id="edit_pull_request" class="btn btn-small no-margin">${_('Save Changes')}</span>
307 307 </div>
308 308 </div>
309 309 </div>
310 310 </div>
311 311 <div>
312 312 ## AUTHOR
313 313 <div class="reviewers-title block-right">
314 314 <div class="pr-details-title">
315 315 ${_('Author of this pull request')}
316 316 </div>
317 317 </div>
318 318 <div class="block-right pr-details-content reviewers">
319 319 <ul class="group_members">
320 320 <li>
321 321 ${self.gravatar_with_user(c.pull_request.author.email, 16)}
322 322 </li>
323 323 </ul>
324 324 </div>
325 325
326 326 ## REVIEW RULES
327 327 <div id="review_rules" style="display: none" class="reviewers-title block-right">
328 328 <div class="pr-details-title">
329 329 ${_('Reviewer rules')}
330 330 %if c.allowed_to_update:
331 331 <span id="close_edit_reviewers" class="block-right action_button last-item" style="display: none;">${_('Close')}</span>
332 332 %endif
333 333 </div>
334 334 <div class="pr-reviewer-rules">
335 335 ## review rules will be appended here, by default reviewers logic
336 336 </div>
337 337 <input id="review_data" type="hidden" name="review_data" value="">
338 338 </div>
339 339
340 340 ## REVIEWERS
341 341 <div class="reviewers-title block-right">
342 342 <div class="pr-details-title">
343 343 ${_('Pull request reviewers')}
344 344 %if c.allowed_to_update:
345 345 <span id="open_edit_reviewers" class="block-right action_button last-item">${_('Edit')}</span>
346 346 %endif
347 347 </div>
348 348 </div>
349 349 <div id="reviewers" class="block-right pr-details-content reviewers">
350 350
351 351 ## members redering block
352 352 <input type="hidden" name="__start__" value="review_members:sequence">
353 353 <ul id="review_members" class="group_members">
354 354
355 355 % for review_obj, member, reasons, mandatory, status in c.pull_request_reviewers:
356 356 <script>
357 357 var member = ${h.json.dumps(h.reviewer_as_json(member, reasons=reasons, mandatory=mandatory, user_group=review_obj.rule_user_group_data()))|n};
358 358 var status = "${(status[0][1].status if status else 'not_reviewed')}";
359 359 var status_lbl = "${h.commit_status_lbl(status[0][1].status if status else 'not_reviewed')}";
360 360 var allowed_to_update = ${h.json.dumps(c.allowed_to_update)};
361 361
362 362 var entry = renderTemplate('reviewMemberEntry', {
363 363 'member': member,
364 364 'mandatory': member.mandatory,
365 365 'reasons': member.reasons,
366 366 'allowed_to_update': allowed_to_update,
367 367 'review_status': status,
368 368 'review_status_label': status_lbl,
369 369 'user_group': member.user_group,
370 370 'create': false
371 371 });
372 372 $('#review_members').append(entry)
373 373 </script>
374 374
375 375 % endfor
376 376
377 377 </ul>
378 378 <input type="hidden" name="__end__" value="review_members:sequence">
379 379 ## end members redering block
380 380
381 381 %if not c.pull_request.is_closed():
382 382 <div id="add_reviewer" class="ac" style="display: none;">
383 383 %if c.allowed_to_update:
384 384 % if not c.forbid_adding_reviewers:
385 385 <div id="add_reviewer_input" class="reviewer_ac">
386 386 ${h.text('user', class_='ac-input', placeholder=_('Add reviewer or reviewer group'))}
387 387 <div id="reviewers_container"></div>
388 388 </div>
389 389 % endif
390 390 <div class="pull-right">
391 391 <button id="update_pull_request" class="btn btn-small no-margin">${_('Save Changes')}</button>
392 392 </div>
393 393 %endif
394 394 </div>
395 395 %endif
396 396 </div>
397 397 </div>
398 398 </div>
399 399 <div class="box">
400 400 ##DIFF
401 401 <div class="table" >
402 402 <div id="changeset_compare_view_content">
403 403 ##CS
404 404 % if c.missing_requirements:
405 405 <div class="box">
406 406 <div class="alert alert-warning">
407 407 <div>
408 408 <strong>${_('Missing requirements:')}</strong>
409 409 ${_('These commits cannot be displayed, because this repository uses the Mercurial largefiles extension, which was not enabled.')}
410 410 </div>
411 411 </div>
412 412 </div>
413 413 % elif c.missing_commits:
414 414 <div class="box">
415 415 <div class="alert alert-warning">
416 416 <div>
417 417 <strong>${_('Missing commits')}:</strong>
418 418 ${_('This pull request cannot be displayed, because one or more commits no longer exist in the source repository.')}
419 419 ${_('Please update this pull request, push the commits back into the source repository, or consider closing this pull request.')}
420 420 ${_('Consider doing a {force_refresh_url} in case you think this is an error.').format(force_refresh_url=h.link_to('force refresh', h.current_route_path(request, force_refresh='1')))|n}
421 421 </div>
422 422 </div>
423 423 </div>
424 424 % endif
425 425
426 426 <div class="compare_view_commits_title">
427 427 % if not c.compare_mode:
428 428
429 429 % if c.at_version_pos:
430 430 <h4>
431 431 ${_('Showing changes at v%d, commenting is disabled.') % c.at_version_pos}
432 432 </h4>
433 433 % endif
434 434
435 435 <div class="pull-left">
436 436 <div class="btn-group">
437 437 <a
438 438 class="btn"
439 439 href="#"
440 440 onclick="$('.compare_select').show();$('.compare_select_hidden').hide(); return false">
441 441 ${_ungettext('Expand %s commit','Expand %s commits', len(c.commit_ranges)) % len(c.commit_ranges)}
442 442 </a>
443 443 <a
444 444 class="btn"
445 445 href="#"
446 446 onclick="$('.compare_select').hide();$('.compare_select_hidden').show(); return false">
447 447 ${_ungettext('Collapse %s commit','Collapse %s commits', len(c.commit_ranges)) % len(c.commit_ranges)}
448 448 </a>
449 449 </div>
450 450 </div>
451 451
452 452 <div class="pull-right">
453 453 % if c.allowed_to_update and not c.pull_request.is_closed():
454 454 <a id="update_commits" class="btn btn-primary no-margin pull-right">${_('Update commits')}</a>
455 455 % else:
456 456 <a class="tooltip btn disabled pull-right" disabled="disabled" title="${_('Update is disabled for current view')}">${_('Update commits')}</a>
457 457 % endif
458 458
459 459 </div>
460 460 % endif
461 461 </div>
462 462
463 463 % if not c.missing_commits:
464 464 % if c.compare_mode:
465 465 % if c.at_version:
466 466 <h4>
467 467 ${_('Commits and changes between v{ver_from} and {ver_to} of this pull request, commenting is disabled').format(ver_from=c.from_version_pos, ver_to=c.at_version_pos if c.at_version_pos else 'latest')}:
468 468 </h4>
469 469
470 470 <div class="subtitle-compare">
471 471 ${_('commits added: {}, removed: {}').format(len(c.commit_changes_summary.added), len(c.commit_changes_summary.removed))}
472 472 </div>
473 473
474 474 <div class="container">
475 475 <table class="rctable compare_view_commits">
476 476 <tr>
477 477 <th></th>
478 478 <th>${_('Time')}</th>
479 479 <th>${_('Author')}</th>
480 480 <th>${_('Commit')}</th>
481 481 <th></th>
482 482 <th>${_('Description')}</th>
483 483 </tr>
484 484
485 485 % for c_type, commit in c.commit_changes:
486 486 % if c_type in ['a', 'r']:
487 487 <%
488 488 if c_type == 'a':
489 489 cc_title = _('Commit added in displayed changes')
490 490 elif c_type == 'r':
491 491 cc_title = _('Commit removed in displayed changes')
492 492 else:
493 493 cc_title = ''
494 494 %>
495 495 <tr id="row-${commit.raw_id}" commit_id="${commit.raw_id}" class="compare_select">
496 496 <td>
497 497 <div class="commit-change-indicator color-${c_type}-border">
498 498 <div class="commit-change-content color-${c_type} tooltip" title="${h.tooltip(cc_title)}">
499 499 ${c_type.upper()}
500 500 </div>
501 501 </div>
502 502 </td>
503 503 <td class="td-time">
504 504 ${h.age_component(commit.date)}
505 505 </td>
506 506 <td class="td-user">
507 507 ${base.gravatar_with_user(commit.author, 16)}
508 508 </td>
509 509 <td class="td-hash">
510 510 <code>
511 511 <a href="${h.route_path('repo_commit', repo_name=c.target_repo.repo_name, commit_id=commit.raw_id)}">
512 512 r${commit.revision}:${h.short_id(commit.raw_id)}
513 513 </a>
514 514 ${h.hidden('revisions', commit.raw_id)}
515 515 </code>
516 516 </td>
517 517 <td class="expand_commit" data-commit-id="${commit.raw_id}" title="${_( 'Expand commit message')}">
518 518 <div class="show_more_col">
519 519 <i class="show_more"></i>
520 520 </div>
521 521 </td>
522 522 <td class="mid td-description">
523 523 <div class="log-container truncate-wrap">
524 524 <div class="message truncate" id="c-${commit.raw_id}" data-message-raw="${commit.message}">
525 525 ${h.urlify_commit_message(commit.message, c.repo_name)}
526 526 </div>
527 527 </div>
528 528 </td>
529 529 </tr>
530 530 % endif
531 531 % endfor
532 532 </table>
533 533 </div>
534 534
535 535 <script>
536 536 $('.expand_commit').on('click',function(e){
537 537 var target_expand = $(this);
538 538 var cid = target_expand.data('commitId');
539 539
540 540 if (target_expand.hasClass('open')){
541 541 $('#c-'+cid).css({
542 542 'height': '1.5em',
543 543 'white-space': 'nowrap',
544 544 'text-overflow': 'ellipsis',
545 545 'overflow':'hidden'
546 546 });
547 547 target_expand.removeClass('open');
548 548 }
549 549 else {
550 550 $('#c-'+cid).css({
551 551 'height': 'auto',
552 552 'white-space': 'pre-line',
553 553 'text-overflow': 'initial',
554 554 'overflow':'visible'
555 555 });
556 556 target_expand.addClass('open');
557 557 }
558 558 });
559 559 </script>
560 560
561 561 % endif
562 562
563 563 % else:
564 564 <%include file="/compare/compare_commits.mako" />
565 565 % endif
566 566
567 567 <div class="cs_files">
568 568 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
569 569 ${cbdiffs.render_diffset_menu()}
570 570 ${cbdiffs.render_diffset(
571 571 c.diffset, use_comments=True,
572 572 collapse_when_files_over=30,
573 573 disable_new_comments=not c.allowed_to_comment,
574 574 deleted_files_comments=c.deleted_files_comments,
575 575 inline_comments=c.inline_comments)}
576 576 </div>
577 577 % else:
578 578 ## skipping commits we need to clear the view for missing commits
579 579 <div style="clear:both;"></div>
580 580 % endif
581 581
582 582 </div>
583 583 </div>
584 584
585 585 ## template for inline comment form
586 586 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
587 587
588 588 ## render general comments
589 589
590 590 <div id="comment-tr-show">
591 591 <div class="comment">
592 592 % if general_outdated_comm_count_ver:
593 593 <div class="meta">
594 594 % if general_outdated_comm_count_ver == 1:
595 595 ${_('there is {num} general comment from older versions').format(num=general_outdated_comm_count_ver)},
596 596 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show it')}</a>
597 597 % else:
598 598 ${_('there are {num} general comments from older versions').format(num=general_outdated_comm_count_ver)},
599 599 <a href="#show-hidden-comments" onclick="$('.comment-general.comment-outdated').show(); $(this).parent().hide(); return false;">${_('show them')}</a>
600 600 % endif
601 601 </div>
602 602 % endif
603 603 </div>
604 604 </div>
605 605
606 606 ${comment.generate_comments(c.comments, include_pull_request=True, is_pull_request=True)}
607 607
608 608 % if not c.pull_request.is_closed():
609 609 ## merge status, and merge action
610 610 <div class="pull-request-merge">
611 611 <%include file="/pullrequests/pullrequest_merge_checks.mako"/>
612 612 </div>
613 613
614 614 ## main comment form and it status
615 615 ${comment.comments(h.route_path('pullrequest_comment_create', repo_name=c.repo_name,
616 616 pull_request_id=c.pull_request.pull_request_id),
617 617 c.pull_request_review_status,
618 618 is_pull_request=True, change_status=c.allowed_to_change_status)}
619 619 %endif
620 620
621 621 <script type="text/javascript">
622 622 if (location.hash) {
623 623 var result = splitDelimitedHash(location.hash);
624 624 var line = $('html').find(result.loc);
625 625 // show hidden comments if we use location.hash
626 626 if (line.hasClass('comment-general')) {
627 627 $(line).show();
628 628 } else if (line.hasClass('comment-inline')) {
629 629 $(line).show();
630 630 var $cb = $(line).closest('.cb');
631 631 $cb.removeClass('cb-collapsed')
632 632 }
633 633 if (line.length > 0){
634 634 offsetScroll(line, 70);
635 635 }
636 636 }
637 637
638 638 versionController = new VersionController();
639 639 versionController.init();
640 640
641 641 reviewersController = new ReviewersController();
642 642
643 643 $(function(){
644 644
645 645 // custom code mirror
646 646 var codeMirrorInstance = initPullRequestsCodeMirror('#pr-description-input');
647 647
648 648 var PRDetails = {
649 649 editButton: $('#open_edit_pullrequest'),
650 650 closeButton: $('#close_edit_pullrequest'),
651 651 deleteButton: $('#delete_pullrequest'),
652 652 viewFields: $('#pr-desc, #pr-title'),
653 653 editFields: $('#pr-desc-edit, #pr-title-edit, #pr-save'),
654 654
655 655 init: function() {
656 656 var that = this;
657 657 this.editButton.on('click', function(e) { that.edit(); });
658 658 this.closeButton.on('click', function(e) { that.view(); });
659 659 },
660 660
661 661 edit: function(event) {
662 662 this.viewFields.hide();
663 663 this.editButton.hide();
664 664 this.deleteButton.hide();
665 665 this.closeButton.show();
666 666 this.editFields.show();
667 667 codeMirrorInstance.refresh();
668 668 },
669 669
670 670 view: function(event) {
671 671 this.editButton.show();
672 672 this.deleteButton.show();
673 673 this.editFields.hide();
674 674 this.closeButton.hide();
675 675 this.viewFields.show();
676 676 }
677 677 };
678 678
679 679 var ReviewersPanel = {
680 680 editButton: $('#open_edit_reviewers'),
681 681 closeButton: $('#close_edit_reviewers'),
682 682 addButton: $('#add_reviewer'),
683 683 removeButtons: $('.reviewer_member_remove,.reviewer_member_mandatory_remove'),
684 684
685 685 init: function() {
686 686 var self = this;
687 687 this.editButton.on('click', function(e) { self.edit(); });
688 688 this.closeButton.on('click', function(e) { self.close(); });
689 689 },
690 690
691 691 edit: function(event) {
692 692 this.editButton.hide();
693 693 this.closeButton.show();
694 694 this.addButton.show();
695 695 this.removeButtons.css('visibility', 'visible');
696 696 // review rules
697 697 reviewersController.loadReviewRules(
698 698 ${c.pull_request.reviewer_data_json | n});
699 699 },
700 700
701 701 close: function(event) {
702 702 this.editButton.show();
703 703 this.closeButton.hide();
704 704 this.addButton.hide();
705 705 this.removeButtons.css('visibility', 'hidden');
706 706 // hide review rules
707 707 reviewersController.hideReviewRules()
708 708 }
709 709 };
710 710
711 711 PRDetails.init();
712 712 ReviewersPanel.init();
713 713
714 714 showOutdated = function(self){
715 715 $('.comment-inline.comment-outdated').show();
716 716 $('.filediff-outdated').show();
717 717 $('.showOutdatedComments').hide();
718 718 $('.hideOutdatedComments').show();
719 719 };
720 720
721 721 hideOutdated = function(self){
722 722 $('.comment-inline.comment-outdated').hide();
723 723 $('.filediff-outdated').hide();
724 724 $('.hideOutdatedComments').hide();
725 725 $('.showOutdatedComments').show();
726 726 };
727 727
728 728 refreshMergeChecks = function(){
729 729 var loadUrl = "${request.current_route_path(_query=dict(merge_checks=1))}";
730 730 $('.pull-request-merge').css('opacity', 0.3);
731 731 $('.action-buttons-extra').css('opacity', 0.3);
732 732
733 733 $('.pull-request-merge').load(
734 734 loadUrl, function() {
735 735 $('.pull-request-merge').css('opacity', 1);
736 736
737 737 $('.action-buttons-extra').css('opacity', 1);
738 738 injectCloseAction();
739 739 }
740 740 );
741 741 };
742 742
743 743 injectCloseAction = function() {
744 744 var closeAction = $('#close-pull-request-action').html();
745 745 var $actionButtons = $('.action-buttons-extra');
746 746 // clear the action before
747 747 $actionButtons.html("");
748 748 $actionButtons.html(closeAction);
749 749 };
750 750
751 751 closePullRequest = function (status) {
752 752 // inject closing flag
753 753 $('.action-buttons-extra').append('<input type="hidden" class="close-pr-input" id="close_pull_request" value="1">');
754 754 $(generalCommentForm.statusChange).select2("val", status).trigger('change');
755 755 $(generalCommentForm.submitForm).submit();
756 756 };
757 757
758 758 $('#show-outdated-comments').on('click', function(e){
759 759 var button = $(this);
760 760 var outdated = $('.comment-outdated');
761 761
762 762 if (button.html() === "(Show)") {
763 763 button.html("(Hide)");
764 764 outdated.show();
765 765 } else {
766 766 button.html("(Show)");
767 767 outdated.hide();
768 768 }
769 769 });
770 770
771 771 $('.show-inline-comments').on('change', function(e){
772 772 var show = 'none';
773 773 var target = e.currentTarget;
774 774 if(target.checked){
775 775 show = ''
776 776 }
777 777 var boxid = $(target).attr('id_for');
778 778 var comments = $('#{0} .inline-comments'.format(boxid));
779 779 var fn_display = function(idx){
780 780 $(this).css('display', show);
781 781 };
782 782 $(comments).each(fn_display);
783 783 var btns = $('#{0} .inline-comments-button'.format(boxid));
784 784 $(btns).each(fn_display);
785 785 });
786 786
787 787 $('#merge_pull_request_form').submit(function() {
788 788 if (!$('#merge_pull_request').attr('disabled')) {
789 789 $('#merge_pull_request').attr('disabled', 'disabled');
790 790 }
791 791 return true;
792 792 });
793 793
794 794 $('#edit_pull_request').on('click', function(e){
795 795 var title = $('#pr-title-input').val();
796 796 var description = codeMirrorInstance.getValue();
797 797 editPullRequest(
798 798 "${c.repo_name}", "${c.pull_request.pull_request_id}",
799 799 title, description);
800 800 });
801 801
802 802 $('#update_pull_request').on('click', function(e){
803 803 $(this).attr('disabled', 'disabled');
804 804 $(this).addClass('disabled');
805 805 $(this).html(_gettext('Saving...'));
806 806 reviewersController.updateReviewers(
807 807 "${c.repo_name}", "${c.pull_request.pull_request_id}");
808 808 });
809 809
810 810 $('#update_commits').on('click', function(e){
811 811 var isDisabled = !$(e.currentTarget).attr('disabled');
812 812 $(e.currentTarget).attr('disabled', 'disabled');
813 813 $(e.currentTarget).addClass('disabled');
814 814 $(e.currentTarget).removeClass('btn-primary');
815 815 $(e.currentTarget).text(_gettext('Updating...'));
816 816 if(isDisabled){
817 817 updateCommits(
818 818 "${c.repo_name}", "${c.pull_request.pull_request_id}");
819 819 }
820 820 });
821 821 // fixing issue with caches on firefox
822 822 $('#update_commits').removeAttr("disabled");
823 823
824 824 $('.show-inline-comments').on('click', function(e){
825 825 var boxid = $(this).attr('data-comment-id');
826 826 var button = $(this);
827 827
828 828 if(button.hasClass("comments-visible")) {
829 829 $('#{0} .inline-comments'.format(boxid)).each(function(index){
830 830 $(this).hide();
831 831 });
832 832 button.removeClass("comments-visible");
833 833 } else {
834 834 $('#{0} .inline-comments'.format(boxid)).each(function(index){
835 835 $(this).show();
836 836 });
837 837 button.addClass("comments-visible");
838 838 }
839 839 });
840 840
841 841 // register submit callback on commentForm form to track TODOs
842 842 window.commentFormGlobalSubmitSuccessCallback = function(){
843 843 refreshMergeChecks();
844 844 };
845 845 // initial injection
846 846 injectCloseAction();
847 847
848 848 ReviewerAutoComplete('#user');
849 849
850 850 })
851 851 </script>
852 852
853 853 </div>
854 854 </div>
855 855
856 856 </%def>
General Comments 0
You need to be logged in to leave comments. Login now