Show More
@@ -1,1193 +1,1215 b'' | |||
|
1 | 1 | <%namespace name="commentblock" file="/changeset/changeset_file_comment.mako"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="diff_line_anchor(commit, filename, line, type)"><% |
|
4 | 4 | return '%s_%s_%i' % (h.md5_safe(commit+filename), type, line) |
|
5 | 5 | %></%def> |
|
6 | 6 | |
|
7 | 7 | <%def name="action_class(action)"> |
|
8 | 8 | <% |
|
9 | 9 | return { |
|
10 | 10 | '-': 'cb-deletion', |
|
11 | 11 | '+': 'cb-addition', |
|
12 | 12 | ' ': 'cb-context', |
|
13 | 13 | }.get(action, 'cb-empty') |
|
14 | 14 | %> |
|
15 | 15 | </%def> |
|
16 | 16 | |
|
17 | 17 | <%def name="op_class(op_id)"> |
|
18 | 18 | <% |
|
19 | 19 | return { |
|
20 | 20 | DEL_FILENODE: 'deletion', # file deleted |
|
21 | 21 | BIN_FILENODE: 'warning' # binary diff hidden |
|
22 | 22 | }.get(op_id, 'addition') |
|
23 | 23 | %> |
|
24 | 24 | </%def> |
|
25 | 25 | |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | <%def name="render_diffset(diffset, commit=None, |
|
29 | 29 | |
|
30 | 30 | # collapse all file diff entries when there are more than this amount of files in the diff |
|
31 | 31 | collapse_when_files_over=20, |
|
32 | 32 | |
|
33 | 33 | # collapse lines in the diff when more than this amount of lines changed in the file diff |
|
34 | 34 | lines_changed_limit=500, |
|
35 | 35 | |
|
36 | 36 | # add a ruler at to the output |
|
37 | 37 | ruler_at_chars=0, |
|
38 | 38 | |
|
39 | 39 | # show inline comments |
|
40 | 40 | use_comments=False, |
|
41 | 41 | |
|
42 | 42 | # disable new comments |
|
43 | 43 | disable_new_comments=False, |
|
44 | 44 | |
|
45 | 45 | # special file-comments that were deleted in previous versions |
|
46 | 46 | # it's used for showing outdated comments for deleted files in a PR |
|
47 | 47 | deleted_files_comments=None, |
|
48 | 48 | |
|
49 | 49 | # for cache purpose |
|
50 | 50 | inline_comments=None, |
|
51 | 51 | |
|
52 | 52 | # additional menu for PRs |
|
53 | 53 | pull_request_menu=None, |
|
54 | 54 | |
|
55 | 55 | # show/hide todo next to comments |
|
56 | 56 | show_todos=True, |
|
57 | 57 | |
|
58 | 58 | )"> |
|
59 | 59 | |
|
60 | 60 | <% |
|
61 | 61 | diffset_container_id = h.md5(diffset.target_ref) |
|
62 | 62 | collapse_all = len(diffset.files) > collapse_when_files_over |
|
63 | 63 | active_pattern_entries = h.get_active_pattern_entries(getattr(c, 'repo_name', None)) |
|
64 | 64 | %> |
|
65 | 65 | |
|
66 | 66 | %if use_comments: |
|
67 | 67 | |
|
68 | 68 | ## Template for injecting comments |
|
69 | 69 | <div id="cb-comments-inline-container-template" class="js-template"> |
|
70 | 70 | ${inline_comments_container([])} |
|
71 | 71 | </div> |
|
72 | 72 | |
|
73 | 73 | <div class="js-template" id="cb-comment-inline-form-template"> |
|
74 | 74 | <div class="comment-inline-form ac"> |
|
75 | 75 | |
|
76 | 76 | %if c.rhodecode_user.username != h.DEFAULT_USER: |
|
77 | 77 | ## render template for inline comments |
|
78 | 78 | ${commentblock.comment_form(form_type='inline')} |
|
79 | 79 | %else: |
|
80 | 80 | ${h.form('', class_='inline-form comment-form-login', method='get')} |
|
81 | 81 | <div class="pull-left"> |
|
82 | 82 | <div class="comment-help pull-right"> |
|
83 | 83 | ${_('You need to be logged in to leave comments.')} <a href="${h.route_path('login', _query={'came_from': h.current_route_path(request)})}">${_('Login now')}</a> |
|
84 | 84 | </div> |
|
85 | 85 | </div> |
|
86 | 86 | <div class="comment-button pull-right"> |
|
87 | 87 | <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);"> |
|
88 | 88 | ${_('Cancel')} |
|
89 | 89 | </button> |
|
90 | 90 | </div> |
|
91 | 91 | <div class="clearfix"></div> |
|
92 | 92 | ${h.end_form()} |
|
93 | 93 | %endif |
|
94 | 94 | </div> |
|
95 | 95 | </div> |
|
96 | 96 | |
|
97 | 97 | %endif |
|
98 | 98 | |
|
99 | 99 | %if c.user_session_attrs["diffmode"] == 'sideside': |
|
100 | 100 | <style> |
|
101 | 101 | .wrapper { |
|
102 | 102 | max-width: 1600px !important; |
|
103 | 103 | } |
|
104 | 104 | </style> |
|
105 | 105 | %endif |
|
106 | 106 | |
|
107 | 107 | %if ruler_at_chars: |
|
108 | 108 | <style> |
|
109 | 109 | .diff table.cb .cb-content:after { |
|
110 | 110 | content: ""; |
|
111 | 111 | border-left: 1px solid blue; |
|
112 | 112 | position: absolute; |
|
113 | 113 | top: 0; |
|
114 | 114 | height: 18px; |
|
115 | 115 | opacity: .2; |
|
116 | 116 | z-index: 10; |
|
117 | 117 | //## +5 to account for diff action (+/-) |
|
118 | 118 | left: ${ruler_at_chars + 5}ch; |
|
119 | 119 | </style> |
|
120 | 120 | %endif |
|
121 | 121 | |
|
122 | 122 | <div class="diffset ${disable_new_comments and 'diffset-comments-disabled'}"> |
|
123 | 123 | |
|
124 | 124 | <div style="height: 20px; line-height: 20px"> |
|
125 | 125 | ## expand/collapse action |
|
126 | 126 | <div class="pull-left"> |
|
127 | 127 | <a class="${'collapsed' if collapse_all else ''}" href="#expand-files" onclick="toggleExpand(this, '${diffset_container_id}'); return false"> |
|
128 | 128 | % if collapse_all: |
|
129 | 129 | <i class="icon-plus-squared-alt icon-no-margin"></i>${_('Expand all files')} |
|
130 | 130 | % else: |
|
131 | 131 | <i class="icon-minus-squared-alt icon-no-margin"></i>${_('Collapse all files')} |
|
132 | 132 | % endif |
|
133 | 133 | </a> |
|
134 | 134 | |
|
135 | 135 | </div> |
|
136 | 136 | |
|
137 | 137 | ## todos |
|
138 | 138 | % if show_todos and getattr(c, 'at_version', None): |
|
139 | 139 | <div class="pull-right"> |
|
140 | 140 | <i class="icon-flag-filled" style="color: #949494">TODOs:</i> |
|
141 | 141 | ${_('not available in this view')} |
|
142 | 142 | </div> |
|
143 | 143 | % elif show_todos: |
|
144 | 144 | <div class="pull-right"> |
|
145 | 145 | <div class="comments-number" style="padding-left: 10px"> |
|
146 | 146 | % if hasattr(c, 'unresolved_comments') and hasattr(c, 'resolved_comments'): |
|
147 | 147 | <i class="icon-flag-filled" style="color: #949494">TODOs:</i> |
|
148 | 148 | % if c.unresolved_comments: |
|
149 | 149 | <a href="#show-todos" onclick="$('#todo-box').toggle(); return false"> |
|
150 | 150 | ${_('{} unresolved').format(len(c.unresolved_comments))} |
|
151 | 151 | </a> |
|
152 | 152 | % else: |
|
153 | 153 | ${_('0 unresolved')} |
|
154 | 154 | % endif |
|
155 | 155 | |
|
156 | 156 | ${_('{} Resolved').format(len(c.resolved_comments))} |
|
157 | 157 | % endif |
|
158 | 158 | </div> |
|
159 | 159 | </div> |
|
160 | 160 | % endif |
|
161 | 161 | |
|
162 | 162 | ## comments |
|
163 | 163 | <div class="pull-right"> |
|
164 | 164 | <div class="comments-number" style="padding-left: 10px"> |
|
165 | 165 | % if hasattr(c, 'comments') and hasattr(c, 'inline_cnt'): |
|
166 | 166 | <i class="icon-comment" style="color: #949494">COMMENTS:</i> |
|
167 | 167 | % if c.comments: |
|
168 | 168 | <a href="#comments">${_ungettext("{} General", "{} General", len(c.comments)).format(len(c.comments))}</a>, |
|
169 | 169 | % else: |
|
170 | 170 | ${_('0 General')} |
|
171 | 171 | % endif |
|
172 | 172 | |
|
173 | 173 | % if c.inline_cnt: |
|
174 | 174 | <a href="#" onclick="return Rhodecode.comments.nextComment();" |
|
175 | 175 | id="inline-comments-counter">${_ungettext("{} Inline", "{} Inline", c.inline_cnt).format(c.inline_cnt)} |
|
176 | 176 | </a> |
|
177 | 177 | % else: |
|
178 | 178 | ${_('0 Inline')} |
|
179 | 179 | % endif |
|
180 | 180 | % endif |
|
181 | 181 | |
|
182 | 182 | % if pull_request_menu: |
|
183 | 183 | <% |
|
184 | 184 | outdated_comm_count_ver = pull_request_menu['outdated_comm_count_ver'] |
|
185 | 185 | %> |
|
186 | 186 | |
|
187 | 187 | % if outdated_comm_count_ver: |
|
188 | 188 | <a href="#" onclick="showOutdated(); Rhodecode.comments.nextOutdatedComment(); return false;"> |
|
189 | 189 | (${_("{} Outdated").format(outdated_comm_count_ver)}) |
|
190 | 190 | </a> |
|
191 | 191 | <a href="#" class="showOutdatedComments" onclick="showOutdated(this); return false;"> | ${_('show outdated')}</a> |
|
192 | 192 | <a href="#" class="hideOutdatedComments" style="display: none" onclick="hideOutdated(this); return false;"> | ${_('hide outdated')}</a> |
|
193 | 193 | % else: |
|
194 | 194 | (${_("{} Outdated").format(outdated_comm_count_ver)}) |
|
195 | 195 | % endif |
|
196 | 196 | |
|
197 | 197 | % endif |
|
198 | 198 | |
|
199 | 199 | </div> |
|
200 | 200 | </div> |
|
201 | 201 | |
|
202 | 202 | </div> |
|
203 | 203 | |
|
204 | 204 | % if diffset.limited_diff: |
|
205 | 205 | <div class="diffset-heading ${(diffset.limited_diff and 'diffset-heading-warning' or '')}"> |
|
206 | 206 | <h2 class="clearinner"> |
|
207 | 207 | ${_('The requested changes are too big and content was truncated.')} |
|
208 | 208 | <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a> |
|
209 | 209 | </h2> |
|
210 | 210 | </div> |
|
211 | 211 | ## commit range header for each individual diff |
|
212 | 212 | % elif commit and hasattr(c, 'commit_ranges') and len(c.commit_ranges) > 1: |
|
213 | 213 | <div class="diffset-heading ${(diffset.limited_diff and 'diffset-heading-warning' or '')}"> |
|
214 | 214 | <div class="clearinner"> |
|
215 | 215 | <a class="tooltip revision" title="${h.tooltip(commit.message)}" href="${h.route_path('repo_commit',repo_name=diffset.repo_name,commit_id=commit.raw_id)}">${('r%s:%s' % (commit.idx,h.short_id(commit.raw_id)))}</a> |
|
216 | 216 | </div> |
|
217 | 217 | </div> |
|
218 | 218 | % endif |
|
219 | 219 | |
|
220 | 220 | <div id="todo-box"> |
|
221 | 221 | % if hasattr(c, 'unresolved_comments') and c.unresolved_comments: |
|
222 | 222 | % for co in c.unresolved_comments: |
|
223 | 223 | <a class="permalink" href="#comment-${co.comment_id}" |
|
224 | 224 | onclick="Rhodecode.comments.scrollToComment($('#comment-${co.comment_id}'))"> |
|
225 | 225 | <i class="icon-flag-filled-red"></i> |
|
226 | 226 | ${co.comment_id}</a>${('' if loop.last else ',')} |
|
227 | 227 | % endfor |
|
228 | 228 | % endif |
|
229 | 229 | </div> |
|
230 | 230 | %if diffset.has_hidden_changes: |
|
231 | 231 | <p class="empty_data">${_('Some changes may be hidden')}</p> |
|
232 | 232 | %elif not diffset.files: |
|
233 | 233 | <p class="empty_data">${_('No files')}</p> |
|
234 | 234 | %endif |
|
235 | 235 | |
|
236 | 236 | <div class="filediffs"> |
|
237 | 237 | |
|
238 | 238 | ## initial value could be marked as False later on |
|
239 | 239 | <% over_lines_changed_limit = False %> |
|
240 | 240 | %for i, filediff in enumerate(diffset.files): |
|
241 | 241 | |
|
242 | 242 | <% |
|
243 | 243 | lines_changed = filediff.patch['stats']['added'] + filediff.patch['stats']['deleted'] |
|
244 | 244 | over_lines_changed_limit = lines_changed > lines_changed_limit |
|
245 | 245 | %> |
|
246 | 246 | ## anchor with support of sticky header |
|
247 | 247 | <div class="anchor" id="a_${h.FID(filediff.raw_id, filediff.patch['filename'])}"></div> |
|
248 | 248 | |
|
249 | 249 | <input ${(collapse_all and 'checked' or '')} class="filediff-collapse-state collapse-${diffset_container_id}" id="filediff-collapse-${id(filediff)}" type="checkbox" onchange="updateSticky();"> |
|
250 | 250 | <div |
|
251 | 251 | class="filediff" |
|
252 | 252 | data-f-path="${filediff.patch['filename']}" |
|
253 | 253 | data-anchor-id="${h.FID(filediff.raw_id, filediff.patch['filename'])}" |
|
254 | 254 | > |
|
255 | 255 | <label for="filediff-collapse-${id(filediff)}" class="filediff-heading"> |
|
256 | <% | |
|
257 | file_comments = (get_inline_comments(inline_comments, filediff.patch['filename']) or {}).values() | |
|
258 | total_file_comments = [_c for _c in h.itertools.chain.from_iterable(file_comments) if not _c.outdated] | |
|
259 | %> | |
|
256 | 260 | <div class="filediff-collapse-indicator icon-"></div> |
|
261 | <span class="pill-group pull-right" > | |
|
262 | <span class="pill"><i class="icon-comment"></i> ${len(total_file_comments)}</span> | |
|
263 | </span> | |
|
257 | 264 | ${diff_ops(filediff)} |
|
265 | ||
|
258 | 266 | </label> |
|
259 | 267 | |
|
260 | 268 | ${diff_menu(filediff, use_comments=use_comments)} |
|
261 | 269 | <table data-f-path="${filediff.patch['filename']}" data-anchor-id="${h.FID(filediff.raw_id, filediff.patch['filename'])}" class="code-visible-block cb cb-diff-${c.user_session_attrs["diffmode"]} code-highlight ${(over_lines_changed_limit and 'cb-collapsed' or '')}"> |
|
262 | 270 | |
|
263 | 271 | ## new/deleted/empty content case |
|
264 | 272 | % if not filediff.hunks: |
|
265 | 273 | ## Comment container, on "fakes" hunk that contains all data to render comments |
|
266 | 274 | ${render_hunk_lines(filediff, c.user_session_attrs["diffmode"], filediff.hunk_ops, use_comments=use_comments, inline_comments=inline_comments, active_pattern_entries=active_pattern_entries)} |
|
267 | 275 | % endif |
|
268 | 276 | |
|
269 | 277 | %if filediff.limited_diff: |
|
270 | 278 | <tr class="cb-warning cb-collapser"> |
|
271 | 279 | <td class="cb-text" ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=4' or 'colspan=6')}> |
|
272 | 280 | ${_('The requested commit or file is too big and content was truncated.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a> |
|
273 | 281 | </td> |
|
274 | 282 | </tr> |
|
275 | 283 | %else: |
|
276 | 284 | %if over_lines_changed_limit: |
|
277 | 285 | <tr class="cb-warning cb-collapser"> |
|
278 | 286 | <td class="cb-text" ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=4' or 'colspan=6')}> |
|
279 | 287 | ${_('This diff has been collapsed as it changes many lines, (%i lines changed)' % lines_changed)} |
|
280 | 288 | <a href="#" class="cb-expand" |
|
281 | 289 | onclick="$(this).closest('table').removeClass('cb-collapsed'); updateSticky(); return false;">${_('Show them')} |
|
282 | 290 | </a> |
|
283 | 291 | <a href="#" class="cb-collapse" |
|
284 | 292 | onclick="$(this).closest('table').addClass('cb-collapsed'); updateSticky(); return false;">${_('Hide them')} |
|
285 | 293 | </a> |
|
286 | 294 | </td> |
|
287 | 295 | </tr> |
|
288 | 296 | %endif |
|
289 | 297 | %endif |
|
290 | 298 | |
|
291 | 299 | % for hunk in filediff.hunks: |
|
292 | 300 | <tr class="cb-hunk"> |
|
293 | 301 | <td ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=3' or '')}> |
|
294 | 302 | ## TODO: dan: add ajax loading of more context here |
|
295 | 303 | ## <a href="#"> |
|
296 | 304 | <i class="icon-more"></i> |
|
297 | 305 | ## </a> |
|
298 | 306 | </td> |
|
299 | 307 | <td ${(c.user_session_attrs["diffmode"] == 'sideside' and 'colspan=5' or '')}> |
|
300 | 308 | @@ |
|
301 | 309 | -${hunk.source_start},${hunk.source_length} |
|
302 | 310 | +${hunk.target_start},${hunk.target_length} |
|
303 | 311 | ${hunk.section_header} |
|
304 | 312 | </td> |
|
305 | 313 | </tr> |
|
306 | 314 | ${render_hunk_lines(filediff, c.user_session_attrs["diffmode"], hunk, use_comments=use_comments, inline_comments=inline_comments, active_pattern_entries=active_pattern_entries)} |
|
307 | 315 | % endfor |
|
308 | 316 | |
|
309 | 317 | <% unmatched_comments = (inline_comments or {}).get(filediff.patch['filename'], {}) %> |
|
310 | 318 | |
|
311 | 319 | ## outdated comments that do not fit into currently displayed lines |
|
312 | 320 | % for lineno, comments in unmatched_comments.items(): |
|
313 | 321 | |
|
314 | 322 | %if c.user_session_attrs["diffmode"] == 'unified': |
|
315 | 323 | % if loop.index == 0: |
|
316 | 324 | <tr class="cb-hunk"> |
|
317 | 325 | <td colspan="3"></td> |
|
318 | 326 | <td> |
|
319 | 327 | <div> |
|
320 | 328 | ${_('Unmatched/outdated inline comments below')} |
|
321 | 329 | </div> |
|
322 | 330 | </td> |
|
323 | 331 | </tr> |
|
324 | 332 | % endif |
|
325 | 333 | <tr class="cb-line"> |
|
326 | 334 | <td class="cb-data cb-context"></td> |
|
327 | 335 | <td class="cb-lineno cb-context"></td> |
|
328 | 336 | <td class="cb-lineno cb-context"></td> |
|
329 | 337 | <td class="cb-content cb-context"> |
|
330 | 338 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
331 | 339 | </td> |
|
332 | 340 | </tr> |
|
333 | 341 | %elif c.user_session_attrs["diffmode"] == 'sideside': |
|
334 | 342 | % if loop.index == 0: |
|
335 | 343 | <tr class="cb-comment-info"> |
|
336 | 344 | <td colspan="2"></td> |
|
337 | 345 | <td class="cb-line"> |
|
338 | 346 | <div> |
|
339 | 347 | ${_('Unmatched/outdated inline comments below')} |
|
340 | 348 | </div> |
|
341 | 349 | </td> |
|
342 | 350 | <td colspan="2"></td> |
|
343 | 351 | <td class="cb-line"> |
|
344 | 352 | <div> |
|
345 | 353 | ${_('Unmatched/outdated comments below')} |
|
346 | 354 | </div> |
|
347 | 355 | </td> |
|
348 | 356 | </tr> |
|
349 | 357 | % endif |
|
350 | 358 | <tr class="cb-line"> |
|
351 | 359 | <td class="cb-data cb-context"></td> |
|
352 | 360 | <td class="cb-lineno cb-context"></td> |
|
353 | 361 | <td class="cb-content cb-context"> |
|
354 | 362 | % if lineno.startswith('o'): |
|
355 | 363 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
356 | 364 | % endif |
|
357 | 365 | </td> |
|
358 | 366 | |
|
359 | 367 | <td class="cb-data cb-context"></td> |
|
360 | 368 | <td class="cb-lineno cb-context"></td> |
|
361 | 369 | <td class="cb-content cb-context"> |
|
362 | 370 | % if lineno.startswith('n'): |
|
363 | 371 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
364 | 372 | % endif |
|
365 | 373 | </td> |
|
366 | 374 | </tr> |
|
367 | 375 | %endif |
|
368 | 376 | |
|
369 | 377 | % endfor |
|
370 | 378 | |
|
371 | 379 | </table> |
|
372 | 380 | </div> |
|
373 | 381 | %endfor |
|
374 | 382 | |
|
375 | 383 | ## outdated comments that are made for a file that has been deleted |
|
376 | 384 | % for filename, comments_dict in (deleted_files_comments or {}).items(): |
|
377 | 385 | |
|
378 | 386 | <% |
|
379 | 387 | display_state = 'display: none' |
|
380 | 388 | open_comments_in_file = [x for x in comments_dict['comments'] if x.outdated is False] |
|
381 | 389 | if open_comments_in_file: |
|
382 | 390 | display_state = '' |
|
383 | 391 | fid = str(id(filename)) |
|
384 | 392 | %> |
|
385 | 393 | <div class="filediffs filediff-outdated" style="${display_state}"> |
|
386 | 394 | <input ${(collapse_all and 'checked' or '')} class="filediff-collapse-state collapse-${diffset_container_id}" id="filediff-collapse-${id(filename)}" type="checkbox" onchange="updateSticky();"> |
|
387 | 395 | <div class="filediff" data-f-path="${filename}" id="a_${h.FID(fid, filename)}"> |
|
388 | 396 | <label for="filediff-collapse-${id(filename)}" class="filediff-heading"> |
|
389 | 397 | <div class="filediff-collapse-indicator icon-"></div> |
|
390 | 398 | |
|
391 | 399 | <span class="pill"> |
|
392 | 400 | ## file was deleted |
|
393 | 401 | ${filename} |
|
394 | 402 | </span> |
|
395 | 403 | <span class="pill-group pull-left" > |
|
396 | 404 | ## file op, doesn't need translation |
|
397 | 405 | <span class="pill" op="removed">unresolved comments</span> |
|
398 | 406 | </span> |
|
399 | 407 | <a class="pill filediff-anchor" href="#a_${h.FID(fid, filename)}">ΒΆ</a> |
|
400 | 408 | <span class="pill-group pull-right"> |
|
401 | 409 | <span class="pill" op="deleted"> |
|
402 | 410 | % if comments_dict['stats'] >0: |
|
403 | 411 | -${comments_dict['stats']} |
|
404 | 412 | % else: |
|
405 | 413 | ${comments_dict['stats']} |
|
406 | 414 | % endif |
|
407 | 415 | </span> |
|
408 | 416 | </span> |
|
409 | 417 | </label> |
|
410 | 418 | |
|
411 | 419 | <table class="cb cb-diff-${c.user_session_attrs["diffmode"]} code-highlight ${(over_lines_changed_limit and 'cb-collapsed' or '')}"> |
|
412 | 420 | <tr> |
|
413 | 421 | % if c.user_session_attrs["diffmode"] == 'unified': |
|
414 | 422 | <td></td> |
|
415 | 423 | %endif |
|
416 | 424 | |
|
417 | 425 | <td></td> |
|
418 | 426 | <td class="cb-text cb-${op_class(BIN_FILENODE)}" ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=4' or 'colspan=5')}> |
|
419 | 427 | <strong>${_('This file was removed from diff during updates to this pull-request.')}</strong><br/> |
|
420 | 428 | ${_('There are still outdated/unresolved comments attached to it.')} |
|
421 | 429 | </td> |
|
422 | 430 | </tr> |
|
423 | 431 | %if c.user_session_attrs["diffmode"] == 'unified': |
|
424 | 432 | <tr class="cb-line"> |
|
425 | 433 | <td class="cb-data cb-context"></td> |
|
426 | 434 | <td class="cb-lineno cb-context"></td> |
|
427 | 435 | <td class="cb-lineno cb-context"></td> |
|
428 | 436 | <td class="cb-content cb-context"> |
|
429 | 437 | ${inline_comments_container(comments_dict['comments'], active_pattern_entries=active_pattern_entries)} |
|
430 | 438 | </td> |
|
431 | 439 | </tr> |
|
432 | 440 | %elif c.user_session_attrs["diffmode"] == 'sideside': |
|
433 | 441 | <tr class="cb-line"> |
|
434 | 442 | <td class="cb-data cb-context"></td> |
|
435 | 443 | <td class="cb-lineno cb-context"></td> |
|
436 | 444 | <td class="cb-content cb-context"></td> |
|
437 | 445 | |
|
438 | 446 | <td class="cb-data cb-context"></td> |
|
439 | 447 | <td class="cb-lineno cb-context"></td> |
|
440 | 448 | <td class="cb-content cb-context"> |
|
441 | 449 | ${inline_comments_container(comments_dict['comments'], active_pattern_entries=active_pattern_entries)} |
|
442 | 450 | </td> |
|
443 | 451 | </tr> |
|
444 | 452 | %endif |
|
445 | 453 | </table> |
|
446 | 454 | </div> |
|
447 | 455 | </div> |
|
448 | 456 | % endfor |
|
449 | 457 | |
|
450 | 458 | </div> |
|
451 | 459 | </div> |
|
452 | 460 | </%def> |
|
453 | 461 | |
|
454 | 462 | <%def name="diff_ops(filediff)"> |
|
455 | 463 | <% |
|
456 | 464 | from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \ |
|
457 | 465 | MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE |
|
458 | 466 | %> |
|
459 | 467 | <span class="pill"> |
|
460 | 468 | <i class="icon-file-text"></i> |
|
461 | 469 | %if filediff.source_file_path and filediff.target_file_path: |
|
462 | 470 | %if filediff.source_file_path != filediff.target_file_path: |
|
463 | 471 | ## file was renamed, or copied |
|
464 | 472 | %if RENAMED_FILENODE in filediff.patch['stats']['ops']: |
|
465 | 473 | ${filediff.target_file_path} β¬ <del>${filediff.source_file_path}</del> |
|
466 | 474 | <% final_path = filediff.target_file_path %> |
|
467 | 475 | %elif COPIED_FILENODE in filediff.patch['stats']['ops']: |
|
468 | 476 | ${filediff.target_file_path} β¬ ${filediff.source_file_path} |
|
469 | 477 | <% final_path = filediff.target_file_path %> |
|
470 | 478 | %endif |
|
471 | 479 | %else: |
|
472 | 480 | ## file was modified |
|
473 | 481 | ${filediff.source_file_path} |
|
474 | 482 | <% final_path = filediff.source_file_path %> |
|
475 | 483 | %endif |
|
476 | 484 | %else: |
|
477 | 485 | %if filediff.source_file_path: |
|
478 | 486 | ## file was deleted |
|
479 | 487 | ${filediff.source_file_path} |
|
480 | 488 | <% final_path = filediff.source_file_path %> |
|
481 | 489 | %else: |
|
482 | 490 | ## file was added |
|
483 | 491 | ${filediff.target_file_path} |
|
484 | 492 | <% final_path = filediff.target_file_path %> |
|
485 | 493 | %endif |
|
486 | 494 | %endif |
|
487 |
<i style="color: #aaa" class=" |
|
|
495 | <i style="color: #aaa" class="on-hover-icon icon-clipboard clipboard-action" data-clipboard-text="${final_path}" title="${_('Copy file path')}" onclick="return false;"></i> | |
|
488 | 496 | </span> |
|
489 | 497 | ## anchor link |
|
490 | 498 | <a class="pill filediff-anchor" href="#a_${h.FID(filediff.raw_id, filediff.patch['filename'])}">ΒΆ</a> |
|
491 | 499 | |
|
492 | 500 | <span class="pill-group pull-right"> |
|
493 | 501 | |
|
494 | 502 | ## ops pills |
|
495 | 503 | %if filediff.limited_diff: |
|
496 | 504 | <span class="pill tooltip" op="limited" title="The stats for this diff are not complete">limited diff</span> |
|
497 | 505 | %endif |
|
498 | 506 | |
|
499 | 507 | %if NEW_FILENODE in filediff.patch['stats']['ops']: |
|
500 | 508 | <span class="pill" op="created">created</span> |
|
501 | 509 | %if filediff['target_mode'].startswith('120'): |
|
502 | 510 | <span class="pill" op="symlink">symlink</span> |
|
503 | 511 | %else: |
|
504 | 512 | <span class="pill" op="mode">${nice_mode(filediff['target_mode'])}</span> |
|
505 | 513 | %endif |
|
506 | 514 | %endif |
|
507 | 515 | |
|
508 | 516 | %if RENAMED_FILENODE in filediff.patch['stats']['ops']: |
|
509 | 517 | <span class="pill" op="renamed">renamed</span> |
|
510 | 518 | %endif |
|
511 | 519 | |
|
512 | 520 | %if COPIED_FILENODE in filediff.patch['stats']['ops']: |
|
513 | 521 | <span class="pill" op="copied">copied</span> |
|
514 | 522 | %endif |
|
515 | 523 | |
|
516 | 524 | %if DEL_FILENODE in filediff.patch['stats']['ops']: |
|
517 | 525 | <span class="pill" op="removed">removed</span> |
|
518 | 526 | %endif |
|
519 | 527 | |
|
520 | 528 | %if CHMOD_FILENODE in filediff.patch['stats']['ops']: |
|
521 | 529 | <span class="pill" op="mode"> |
|
522 | 530 | ${nice_mode(filediff['source_mode'])} β‘ ${nice_mode(filediff['target_mode'])} |
|
523 | 531 | </span> |
|
524 | 532 | %endif |
|
525 | 533 | |
|
526 | 534 | %if BIN_FILENODE in filediff.patch['stats']['ops']: |
|
527 | 535 | <span class="pill" op="binary">binary</span> |
|
528 | 536 | %if MOD_FILENODE in filediff.patch['stats']['ops']: |
|
529 | 537 | <span class="pill" op="modified">modified</span> |
|
530 | 538 | %endif |
|
531 | 539 | %endif |
|
532 | 540 | |
|
533 | 541 | <span class="pill" op="added">${('+' if filediff.patch['stats']['added'] else '')}${filediff.patch['stats']['added']}</span> |
|
534 | 542 | <span class="pill" op="deleted">${((h.safe_int(filediff.patch['stats']['deleted']) or 0) * -1)}</span> |
|
535 | 543 | |
|
536 | 544 | </span> |
|
537 | 545 | |
|
538 | 546 | </%def> |
|
539 | 547 | |
|
540 | 548 | <%def name="nice_mode(filemode)"> |
|
541 | 549 | ${(filemode.startswith('100') and filemode[3:] or filemode)} |
|
542 | 550 | </%def> |
|
543 | 551 | |
|
544 | 552 | <%def name="diff_menu(filediff, use_comments=False)"> |
|
545 | 553 | <div class="filediff-menu"> |
|
546 | 554 | |
|
547 | 555 | %if filediff.diffset.source_ref: |
|
548 | 556 | |
|
549 | 557 | ## FILE BEFORE CHANGES |
|
550 | 558 | %if filediff.operation in ['D', 'M']: |
|
551 | 559 | <a |
|
552 | 560 | class="tooltip" |
|
553 | 561 | href="${h.route_path('repo_files',repo_name=filediff.diffset.target_repo_name,commit_id=filediff.diffset.source_ref,f_path=filediff.source_file_path)}" |
|
554 | 562 | title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}" |
|
555 | 563 | > |
|
556 | 564 | ${_('Show file before')} |
|
557 | 565 | </a> | |
|
558 | 566 | %else: |
|
559 | 567 | <span |
|
560 | 568 | class="tooltip" |
|
561 | 569 | title="${h.tooltip(_('File not present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}" |
|
562 | 570 | > |
|
563 | 571 | ${_('Show file before')} |
|
564 | 572 | </span> | |
|
565 | 573 | %endif |
|
566 | 574 | |
|
567 | 575 | ## FILE AFTER CHANGES |
|
568 | 576 | %if filediff.operation in ['A', 'M']: |
|
569 | 577 | <a |
|
570 | 578 | class="tooltip" |
|
571 | 579 | href="${h.route_path('repo_files',repo_name=filediff.diffset.source_repo_name,commit_id=filediff.diffset.target_ref,f_path=filediff.target_file_path)}" |
|
572 | 580 | title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}" |
|
573 | 581 | > |
|
574 | 582 | ${_('Show file after')} |
|
575 | 583 | </a> |
|
576 | 584 | %else: |
|
577 | 585 | <span |
|
578 | 586 | class="tooltip" |
|
579 | 587 | title="${h.tooltip(_('File not present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}" |
|
580 | 588 | > |
|
581 | 589 | ${_('Show file after')} |
|
582 | 590 | </span> |
|
583 | 591 | %endif |
|
584 | 592 | |
|
585 | 593 | % if use_comments: |
|
586 | 594 | | |
|
587 | 595 | <a href="#" onclick="return Rhodecode.comments.toggleComments(this);"> |
|
588 | 596 | <span class="show-comment-button">${_('Show comments')}</span><span class="hide-comment-button">${_('Hide comments')}</span> |
|
589 | 597 | </a> |
|
590 | 598 | % endif |
|
591 | 599 | |
|
592 | 600 | %endif |
|
593 | 601 | |
|
594 | 602 | </div> |
|
595 | 603 | </%def> |
|
596 | 604 | |
|
597 | 605 | |
|
598 | 606 | <%def name="inline_comments_container(comments, active_pattern_entries=None)"> |
|
599 | 607 | |
|
600 | 608 | <div class="inline-comments"> |
|
601 | 609 | %for comment in comments: |
|
602 | 610 | ${commentblock.comment_block(comment, inline=True, active_pattern_entries=active_pattern_entries)} |
|
603 | 611 | %endfor |
|
604 | 612 | % if comments and comments[-1].outdated: |
|
605 | 613 | <span class="btn btn-secondary cb-comment-add-button comment-outdated}" style="display: none;}"> |
|
606 | 614 | ${_('Add another comment')} |
|
607 | 615 | </span> |
|
608 | 616 | % else: |
|
609 | 617 | <span onclick="return Rhodecode.comments.createComment(this)" class="btn btn-secondary cb-comment-add-button"> |
|
610 | 618 | ${_('Add another comment')} |
|
611 | 619 | </span> |
|
612 | 620 | % endif |
|
613 | 621 | |
|
614 | 622 | </div> |
|
615 | 623 | </%def> |
|
616 | 624 | |
|
617 | 625 | <%! |
|
626 | ||
|
627 | def get_inline_comments(comments, filename): | |
|
628 | if hasattr(filename, 'unicode_path'): | |
|
629 | filename = filename.unicode_path | |
|
630 | ||
|
631 | if not isinstance(filename, (unicode, str)): | |
|
632 | return None | |
|
633 | ||
|
634 | if comments and filename in comments: | |
|
635 | return comments[filename] | |
|
636 | ||
|
637 | return None | |
|
638 | ||
|
618 | 639 | def get_comments_for(diff_type, comments, filename, line_version, line_number): |
|
619 | 640 | if hasattr(filename, 'unicode_path'): |
|
620 | 641 | filename = filename.unicode_path |
|
621 | 642 | |
|
622 | 643 | if not isinstance(filename, (unicode, str)): |
|
623 | 644 | return None |
|
624 | 645 | |
|
625 | line_key = '{}{}'.format(line_version, line_number) ## e.g o37, n12 | |
|
646 | file_comments = get_inline_comments(comments, filename) | |
|
647 | if file_comments is None: | |
|
648 | return None | |
|
626 | 649 | |
|
627 | if comments and filename in comments: | |
|
628 | file_comments = comments[filename] | |
|
650 | line_key = '{}{}'.format(line_version, line_number) ## e.g o37, n12 | |
|
629 | 651 |
|
|
630 | 652 |
|
|
631 | 653 |
|
|
632 | 654 | %> |
|
633 | 655 | |
|
634 | 656 | <%def name="render_hunk_lines_sideside(filediff, hunk, use_comments=False, inline_comments=None, active_pattern_entries=None)"> |
|
635 | 657 | %for i, line in enumerate(hunk.sideside): |
|
636 | 658 | <% |
|
637 | 659 | old_line_anchor, new_line_anchor = None, None |
|
638 | 660 | |
|
639 | 661 | if line.original.lineno: |
|
640 | 662 | old_line_anchor = diff_line_anchor(filediff.raw_id, hunk.source_file_path, line.original.lineno, 'o') |
|
641 | 663 | if line.modified.lineno: |
|
642 | 664 | new_line_anchor = diff_line_anchor(filediff.raw_id, hunk.target_file_path, line.modified.lineno, 'n') |
|
643 | 665 | %> |
|
644 | 666 | |
|
645 | 667 | <tr class="cb-line"> |
|
646 | 668 | <td class="cb-data ${action_class(line.original.action)}" |
|
647 | 669 | data-line-no="${line.original.lineno}" |
|
648 | 670 | > |
|
649 | 671 | <div> |
|
650 | 672 | |
|
651 | 673 | <% line_old_comments = None %> |
|
652 | 674 | %if line.original.get_comment_args: |
|
653 | 675 | <% line_old_comments = get_comments_for('side-by-side', inline_comments, *line.original.get_comment_args) %> |
|
654 | 676 | %endif |
|
655 | 677 | %if line_old_comments: |
|
656 | 678 | <% has_outdated = any([x.outdated for x in line_old_comments]) %> |
|
657 | 679 | % if has_outdated: |
|
658 | 680 | <i title="${_('comments including outdated')}:${len(line_old_comments)}" class="icon-comment-toggle" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
659 | 681 | % else: |
|
660 | 682 | <i title="${_('comments')}: ${len(line_old_comments)}" class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
661 | 683 | % endif |
|
662 | 684 | %endif |
|
663 | 685 | </div> |
|
664 | 686 | </td> |
|
665 | 687 | <td class="cb-lineno ${action_class(line.original.action)}" |
|
666 | 688 | data-line-no="${line.original.lineno}" |
|
667 | 689 | %if old_line_anchor: |
|
668 | 690 | id="${old_line_anchor}" |
|
669 | 691 | %endif |
|
670 | 692 | > |
|
671 | 693 | %if line.original.lineno: |
|
672 | 694 | <a name="${old_line_anchor}" href="#${old_line_anchor}">${line.original.lineno}</a> |
|
673 | 695 | %endif |
|
674 | 696 | </td> |
|
675 | 697 | <td class="cb-content ${action_class(line.original.action)}" |
|
676 | 698 | data-line-no="o${line.original.lineno}" |
|
677 | 699 | > |
|
678 | 700 | %if use_comments and line.original.lineno: |
|
679 | 701 | ${render_add_comment_button()} |
|
680 | 702 | %endif |
|
681 | 703 | <span class="cb-code"><span class="cb-action ${action_class(line.original.action)}"></span>${line.original.content or '' | n}</span> |
|
682 | 704 | |
|
683 | 705 | %if use_comments and line.original.lineno and line_old_comments: |
|
684 | 706 | ${inline_comments_container(line_old_comments, active_pattern_entries=active_pattern_entries)} |
|
685 | 707 | %endif |
|
686 | 708 | |
|
687 | 709 | </td> |
|
688 | 710 | <td class="cb-data ${action_class(line.modified.action)}" |
|
689 | 711 | data-line-no="${line.modified.lineno}" |
|
690 | 712 | > |
|
691 | 713 | <div> |
|
692 | 714 | |
|
693 | 715 | %if line.modified.get_comment_args: |
|
694 | 716 | <% line_new_comments = get_comments_for('side-by-side', inline_comments, *line.modified.get_comment_args) %> |
|
695 | 717 | %else: |
|
696 | 718 | <% line_new_comments = None%> |
|
697 | 719 | %endif |
|
698 | 720 | %if line_new_comments: |
|
699 | 721 | <% has_outdated = any([x.outdated for x in line_new_comments]) %> |
|
700 | 722 | % if has_outdated: |
|
701 | 723 | <i title="${_('comments including outdated')}:${len(line_new_comments)}" class="icon-comment-toggle" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
702 | 724 | % else: |
|
703 | 725 | <i title="${_('comments')}: ${len(line_new_comments)}" class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
704 | 726 | % endif |
|
705 | 727 | %endif |
|
706 | 728 | </div> |
|
707 | 729 | </td> |
|
708 | 730 | <td class="cb-lineno ${action_class(line.modified.action)}" |
|
709 | 731 | data-line-no="${line.modified.lineno}" |
|
710 | 732 | %if new_line_anchor: |
|
711 | 733 | id="${new_line_anchor}" |
|
712 | 734 | %endif |
|
713 | 735 | > |
|
714 | 736 | %if line.modified.lineno: |
|
715 | 737 | <a name="${new_line_anchor}" href="#${new_line_anchor}">${line.modified.lineno}</a> |
|
716 | 738 | %endif |
|
717 | 739 | </td> |
|
718 | 740 | <td class="cb-content ${action_class(line.modified.action)}" |
|
719 | 741 | data-line-no="n${line.modified.lineno}" |
|
720 | 742 | > |
|
721 | 743 | %if use_comments and line.modified.lineno: |
|
722 | 744 | ${render_add_comment_button()} |
|
723 | 745 | %endif |
|
724 | 746 | <span class="cb-code"><span class="cb-action ${action_class(line.modified.action)}"></span>${line.modified.content or '' | n}</span> |
|
725 | 747 | %if use_comments and line.modified.lineno and line_new_comments: |
|
726 | 748 | ${inline_comments_container(line_new_comments, active_pattern_entries=active_pattern_entries)} |
|
727 | 749 | %endif |
|
728 | 750 | </td> |
|
729 | 751 | </tr> |
|
730 | 752 | %endfor |
|
731 | 753 | </%def> |
|
732 | 754 | |
|
733 | 755 | |
|
734 | 756 | <%def name="render_hunk_lines_unified(filediff, hunk, use_comments=False, inline_comments=None, active_pattern_entries=None)"> |
|
735 | 757 | %for old_line_no, new_line_no, action, content, comments_args in hunk.unified: |
|
736 | 758 | |
|
737 | 759 | <% |
|
738 | 760 | old_line_anchor, new_line_anchor = None, None |
|
739 | 761 | if old_line_no: |
|
740 | 762 | old_line_anchor = diff_line_anchor(filediff.raw_id, hunk.source_file_path, old_line_no, 'o') |
|
741 | 763 | if new_line_no: |
|
742 | 764 | new_line_anchor = diff_line_anchor(filediff.raw_id, hunk.target_file_path, new_line_no, 'n') |
|
743 | 765 | %> |
|
744 | 766 | <tr class="cb-line"> |
|
745 | 767 | <td class="cb-data ${action_class(action)}"> |
|
746 | 768 | <div> |
|
747 | 769 | |
|
748 | 770 | %if comments_args: |
|
749 | 771 | <% comments = get_comments_for('unified', inline_comments, *comments_args) %> |
|
750 | 772 | %else: |
|
751 | 773 | <% comments = None %> |
|
752 | 774 | %endif |
|
753 | 775 | |
|
754 | 776 | % if comments: |
|
755 | 777 | <% has_outdated = any([x.outdated for x in comments]) %> |
|
756 | 778 | % if has_outdated: |
|
757 | 779 | <i title="${_('comments including outdated')}:${len(comments)}" class="icon-comment-toggle" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
758 | 780 | % else: |
|
759 | 781 | <i title="${_('comments')}: ${len(comments)}" class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
760 | 782 | % endif |
|
761 | 783 | % endif |
|
762 | 784 | </div> |
|
763 | 785 | </td> |
|
764 | 786 | <td class="cb-lineno ${action_class(action)}" |
|
765 | 787 | data-line-no="${old_line_no}" |
|
766 | 788 | %if old_line_anchor: |
|
767 | 789 | id="${old_line_anchor}" |
|
768 | 790 | %endif |
|
769 | 791 | > |
|
770 | 792 | %if old_line_anchor: |
|
771 | 793 | <a name="${old_line_anchor}" href="#${old_line_anchor}">${old_line_no}</a> |
|
772 | 794 | %endif |
|
773 | 795 | </td> |
|
774 | 796 | <td class="cb-lineno ${action_class(action)}" |
|
775 | 797 | data-line-no="${new_line_no}" |
|
776 | 798 | %if new_line_anchor: |
|
777 | 799 | id="${new_line_anchor}" |
|
778 | 800 | %endif |
|
779 | 801 | > |
|
780 | 802 | %if new_line_anchor: |
|
781 | 803 | <a name="${new_line_anchor}" href="#${new_line_anchor}">${new_line_no}</a> |
|
782 | 804 | %endif |
|
783 | 805 | </td> |
|
784 | 806 | <td class="cb-content ${action_class(action)}" |
|
785 | 807 | data-line-no="${(new_line_no and 'n' or 'o')}${(new_line_no or old_line_no)}" |
|
786 | 808 | > |
|
787 | 809 | %if use_comments: |
|
788 | 810 | ${render_add_comment_button()} |
|
789 | 811 | %endif |
|
790 | 812 | <span class="cb-code"><span class="cb-action ${action_class(action)}"></span> ${content or '' | n}</span> |
|
791 | 813 | %if use_comments and comments: |
|
792 | 814 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
793 | 815 | %endif |
|
794 | 816 | </td> |
|
795 | 817 | </tr> |
|
796 | 818 | %endfor |
|
797 | 819 | </%def> |
|
798 | 820 | |
|
799 | 821 | |
|
800 | 822 | <%def name="render_hunk_lines(filediff, diff_mode, hunk, use_comments, inline_comments, active_pattern_entries)"> |
|
801 | 823 | % if diff_mode == 'unified': |
|
802 | 824 | ${render_hunk_lines_unified(filediff, hunk, use_comments=use_comments, inline_comments=inline_comments, active_pattern_entries=active_pattern_entries)} |
|
803 | 825 | % elif diff_mode == 'sideside': |
|
804 | 826 | ${render_hunk_lines_sideside(filediff, hunk, use_comments=use_comments, inline_comments=inline_comments, active_pattern_entries=active_pattern_entries)} |
|
805 | 827 | % else: |
|
806 | 828 | <tr class="cb-line"> |
|
807 | 829 | <td>unknown diff mode</td> |
|
808 | 830 | </tr> |
|
809 | 831 | % endif |
|
810 | 832 | </%def>file changes |
|
811 | 833 | |
|
812 | 834 | |
|
813 | 835 | <%def name="render_add_comment_button()"> |
|
814 | 836 | <button class="btn btn-small btn-primary cb-comment-box-opener" onclick="return Rhodecode.comments.createComment(this)"> |
|
815 | 837 | <span><i class="icon-comment"></i></span> |
|
816 | 838 | </button> |
|
817 | 839 | </%def> |
|
818 | 840 | |
|
819 | 841 | <%def name="render_diffset_menu(diffset, range_diff_on=None)"> |
|
820 | 842 | <% diffset_container_id = h.md5(diffset.target_ref) %> |
|
821 | 843 | |
|
822 | 844 | <div id="diff-file-sticky" class="diffset-menu clearinner"> |
|
823 | 845 | ## auto adjustable |
|
824 | 846 | <div class="sidebar__inner"> |
|
825 | 847 | <div class="sidebar__bar"> |
|
826 | 848 | <div class="pull-right"> |
|
827 | 849 | <div class="btn-group"> |
|
828 | 850 | <a class="btn tooltip toggle-wide-diff" href="#toggle-wide-diff" onclick="toggleWideDiff(this); return false" title="${h.tooltip(_('Toggle wide diff'))}"> |
|
829 | 851 | <i class="icon-wide-mode"></i> |
|
830 | 852 | </a> |
|
831 | 853 | </div> |
|
832 | 854 | <div class="btn-group"> |
|
833 | 855 | |
|
834 | 856 | <a |
|
835 | 857 | class="btn ${(c.user_session_attrs["diffmode"] == 'sideside' and 'btn-active')} tooltip" |
|
836 | 858 | title="${h.tooltip(_('View diff as side by side'))}" |
|
837 | 859 | href="${h.current_route_path(request, diffmode='sideside')}"> |
|
838 | 860 | <span>${_('Side by Side')}</span> |
|
839 | 861 | </a> |
|
840 | 862 | |
|
841 | 863 | <a |
|
842 | 864 | class="btn ${(c.user_session_attrs["diffmode"] == 'unified' and 'btn-active')} tooltip" |
|
843 | 865 | title="${h.tooltip(_('View diff as unified'))}" href="${h.current_route_path(request, diffmode='unified')}"> |
|
844 | 866 | <span>${_('Unified')}</span> |
|
845 | 867 | </a> |
|
846 | 868 | |
|
847 | 869 | % if range_diff_on is True: |
|
848 | 870 | <a |
|
849 | 871 | title="${_('Turn off: Show the diff as commit range')}" |
|
850 | 872 | class="btn btn-primary" |
|
851 | 873 | href="${h.current_route_path(request, **{"range-diff":"0"})}"> |
|
852 | 874 | <span>${_('Range Diff')}</span> |
|
853 | 875 | </a> |
|
854 | 876 | % elif range_diff_on is False: |
|
855 | 877 | <a |
|
856 | 878 | title="${_('Show the diff as commit range')}" |
|
857 | 879 | class="btn" |
|
858 | 880 | href="${h.current_route_path(request, **{"range-diff":"1"})}"> |
|
859 | 881 | <span>${_('Range Diff')}</span> |
|
860 | 882 | </a> |
|
861 | 883 | % endif |
|
862 | 884 | </div> |
|
863 | 885 | <div class="btn-group"> |
|
864 | 886 | |
|
865 | 887 | <div class="pull-left"> |
|
866 | 888 | ${h.hidden('diff_menu_{}'.format(diffset_container_id))} |
|
867 | 889 | </div> |
|
868 | 890 | |
|
869 | 891 | </div> |
|
870 | 892 | </div> |
|
871 | 893 | <div class="pull-left"> |
|
872 | 894 | <div class="btn-group"> |
|
873 | 895 | <div class="pull-left"> |
|
874 | 896 | ${h.hidden('file_filter_{}'.format(diffset_container_id))} |
|
875 | 897 | </div> |
|
876 | 898 | |
|
877 | 899 | </div> |
|
878 | 900 | </div> |
|
879 | 901 | </div> |
|
880 | 902 | <div class="fpath-placeholder"> |
|
881 | 903 | <i class="icon-file-text"></i> |
|
882 | 904 | <strong class="fpath-placeholder-text"> |
|
883 | 905 | Context file: |
|
884 | 906 | </strong> |
|
885 | 907 | </div> |
|
886 | 908 | <div class="sidebar_inner_shadow"></div> |
|
887 | 909 | </div> |
|
888 | 910 | </div> |
|
889 | 911 | |
|
890 | 912 | % if diffset: |
|
891 | 913 | %if diffset.limited_diff: |
|
892 | 914 | <% file_placeholder = _ungettext('%(num)s file changed', '%(num)s files changed', diffset.changed_files) % {'num': diffset.changed_files} %> |
|
893 | 915 | %else: |
|
894 | 916 | <% file_placeholder = h.literal(_ungettext('%(num)s file changed: <span class="op-added">%(linesadd)s inserted</span>, <span class="op-deleted">%(linesdel)s deleted</span>', '%(num)s files changed: <span class="op-added">%(linesadd)s inserted</span>, <span class="op-deleted">%(linesdel)s deleted</span>', |
|
895 | 917 | diffset.changed_files) % {'num': diffset.changed_files, 'linesadd': diffset.lines_added, 'linesdel': diffset.lines_deleted}) %> |
|
896 | 918 | |
|
897 | 919 | %endif |
|
898 | 920 | ## case on range-diff placeholder needs to be updated |
|
899 | 921 | % if range_diff_on is True: |
|
900 | 922 | <% file_placeholder = _('Disabled on range diff') %> |
|
901 | 923 | % endif |
|
902 | 924 | |
|
903 | 925 | <script type="text/javascript"> |
|
904 | 926 | var feedFilesOptions = function (query, initialData) { |
|
905 | 927 | var data = {results: []}; |
|
906 | 928 | var isQuery = typeof query.term !== 'undefined'; |
|
907 | 929 | |
|
908 | 930 | var section = _gettext('Changed files'); |
|
909 | 931 | var filteredData = []; |
|
910 | 932 | |
|
911 | 933 | //filter results |
|
912 | 934 | $.each(initialData.results, function (idx, value) { |
|
913 | 935 | |
|
914 | 936 | if (!isQuery || query.term.length === 0 || value.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { |
|
915 | 937 | filteredData.push({ |
|
916 | 938 | 'id': this.id, |
|
917 | 939 | 'text': this.text, |
|
918 | 940 | "ops": this.ops, |
|
919 | 941 | }) |
|
920 | 942 | } |
|
921 | 943 | |
|
922 | 944 | }); |
|
923 | 945 | |
|
924 | 946 | data.results = filteredData; |
|
925 | 947 | |
|
926 | 948 | query.callback(data); |
|
927 | 949 | }; |
|
928 | 950 | |
|
929 | 951 | var selectionFormatter = function(data, escapeMarkup) { |
|
930 | 952 | var container = '<div class="filelist" style="padding-right:100px">{0}</div>'; |
|
931 | 953 | var tmpl = '<div><strong>{0}</strong></div>'.format(escapeMarkup(data['text'])); |
|
932 | 954 | var pill = '<div class="pill-group" style="position: absolute; top:7px; right: 0">' + |
|
933 | 955 | '<span class="pill" op="added">{0}</span>' + |
|
934 | 956 | '<span class="pill" op="deleted">{1}</span>' + |
|
935 | 957 | '</div>' |
|
936 | 958 | ; |
|
937 | 959 | var added = data['ops']['added']; |
|
938 | 960 | if (added === 0) { |
|
939 | 961 | // don't show +0 |
|
940 | 962 | added = 0; |
|
941 | 963 | } else { |
|
942 | 964 | added = '+' + added; |
|
943 | 965 | } |
|
944 | 966 | |
|
945 | 967 | var deleted = -1*data['ops']['deleted']; |
|
946 | 968 | |
|
947 | 969 | tmpl += pill.format(added, deleted); |
|
948 | 970 | return container.format(tmpl); |
|
949 | 971 | }; |
|
950 | 972 | var formatFileResult = function(result, container, query, escapeMarkup) { |
|
951 | 973 | return selectionFormatter(result, escapeMarkup); |
|
952 | 974 | }; |
|
953 | 975 | |
|
954 | 976 | var formatSelection = function (data, container) { |
|
955 | 977 | return '${file_placeholder}' |
|
956 | 978 | }; |
|
957 | 979 | |
|
958 | 980 | if (window.preloadFileFilterData === undefined) { |
|
959 | 981 | window.preloadFileFilterData = {} |
|
960 | 982 | } |
|
961 | 983 | |
|
962 | 984 | preloadFileFilterData["${diffset_container_id}"] = { |
|
963 | 985 | results: [ |
|
964 | 986 | % for filediff in diffset.files: |
|
965 | 987 | {id:"a_${h.FID(filediff.raw_id, filediff.patch['filename'])}", |
|
966 | 988 | text:"${filediff.patch['filename']}", |
|
967 | 989 | ops:${h.json.dumps(filediff.patch['stats'])|n}}${('' if loop.last else ',')} |
|
968 | 990 | % endfor |
|
969 | 991 | ] |
|
970 | 992 | }; |
|
971 | 993 | |
|
972 | 994 | var diffFileFilterId = "#file_filter_" + "${diffset_container_id}"; |
|
973 | 995 | var diffFileFilter = $(diffFileFilterId).select2({ |
|
974 | 996 | 'dropdownAutoWidth': true, |
|
975 | 997 | 'width': 'auto', |
|
976 | 998 | |
|
977 | 999 | containerCssClass: "drop-menu", |
|
978 | 1000 | dropdownCssClass: "drop-menu-dropdown", |
|
979 | 1001 | data: preloadFileFilterData["${diffset_container_id}"], |
|
980 | 1002 | query: function(query) { |
|
981 | 1003 | feedFilesOptions(query, preloadFileFilterData["${diffset_container_id}"]); |
|
982 | 1004 | }, |
|
983 | 1005 | initSelection: function(element, callback) { |
|
984 | 1006 | callback({'init': true}); |
|
985 | 1007 | }, |
|
986 | 1008 | formatResult: formatFileResult, |
|
987 | 1009 | formatSelection: formatSelection |
|
988 | 1010 | }); |
|
989 | 1011 | |
|
990 | 1012 | % if range_diff_on is True: |
|
991 | 1013 | diffFileFilter.select2("enable", false); |
|
992 | 1014 | % endif |
|
993 | 1015 | |
|
994 | 1016 | $(diffFileFilterId).on('select2-selecting', function (e) { |
|
995 | 1017 | var idSelector = e.choice.id; |
|
996 | 1018 | |
|
997 | 1019 | // expand the container if we quick-select the field |
|
998 | 1020 | $('#'+idSelector).next().prop('checked', false); |
|
999 | 1021 | // hide the mast as we later do preventDefault() |
|
1000 | 1022 | $("#select2-drop-mask").click(); |
|
1001 | 1023 | |
|
1002 | 1024 | window.location.hash = '#'+idSelector; |
|
1003 | 1025 | updateSticky(); |
|
1004 | 1026 | |
|
1005 | 1027 | e.preventDefault(); |
|
1006 | 1028 | }); |
|
1007 | 1029 | |
|
1008 | 1030 | </script> |
|
1009 | 1031 | % endif |
|
1010 | 1032 | |
|
1011 | 1033 | <script type="text/javascript"> |
|
1012 | 1034 | $(document).ready(function () { |
|
1013 | 1035 | |
|
1014 | 1036 | var contextPrefix = _gettext('Context file: '); |
|
1015 | 1037 | ## sticky sidebar |
|
1016 | 1038 | var sidebarElement = document.getElementById('diff-file-sticky'); |
|
1017 | 1039 | sidebar = new StickySidebar(sidebarElement, { |
|
1018 | 1040 | topSpacing: 0, |
|
1019 | 1041 | bottomSpacing: 0, |
|
1020 | 1042 | innerWrapperSelector: '.sidebar__inner' |
|
1021 | 1043 | }); |
|
1022 | 1044 | sidebarElement.addEventListener('affixed.static.stickySidebar', function () { |
|
1023 | 1045 | // reset our file so it's not holding new value |
|
1024 | 1046 | $('.fpath-placeholder-text').html(contextPrefix + ' - ') |
|
1025 | 1047 | }); |
|
1026 | 1048 | |
|
1027 | 1049 | updateSticky = function () { |
|
1028 | 1050 | sidebar.updateSticky(); |
|
1029 | 1051 | Waypoint.refreshAll(); |
|
1030 | 1052 | }; |
|
1031 | 1053 | |
|
1032 | 1054 | var animateText = function (fPath, anchorId) { |
|
1033 | 1055 | fPath = Select2.util.escapeMarkup(fPath); |
|
1034 | 1056 | $('.fpath-placeholder-text').html(contextPrefix + '<a href="#a_' + anchorId + '">' + fPath + '</a>') |
|
1035 | 1057 | }; |
|
1036 | 1058 | |
|
1037 | 1059 | ## dynamic file waypoints |
|
1038 | 1060 | var setFPathInfo = function(fPath, anchorId){ |
|
1039 | 1061 | animateText(fPath, anchorId) |
|
1040 | 1062 | }; |
|
1041 | 1063 | |
|
1042 | 1064 | var codeBlock = $('.filediff'); |
|
1043 | 1065 | |
|
1044 | 1066 | // forward waypoint |
|
1045 | 1067 | codeBlock.waypoint( |
|
1046 | 1068 | function(direction) { |
|
1047 | 1069 | if (direction === "down"){ |
|
1048 | 1070 | setFPathInfo($(this.element).data('fPath'), $(this.element).data('anchorId')) |
|
1049 | 1071 | } |
|
1050 | 1072 | }, { |
|
1051 | 1073 | offset: function () { |
|
1052 | 1074 | return 70; |
|
1053 | 1075 | }, |
|
1054 | 1076 | context: '.fpath-placeholder' |
|
1055 | 1077 | } |
|
1056 | 1078 | ); |
|
1057 | 1079 | |
|
1058 | 1080 | // backward waypoint |
|
1059 | 1081 | codeBlock.waypoint( |
|
1060 | 1082 | function(direction) { |
|
1061 | 1083 | if (direction === "up"){ |
|
1062 | 1084 | setFPathInfo($(this.element).data('fPath'), $(this.element).data('anchorId')) |
|
1063 | 1085 | } |
|
1064 | 1086 | }, { |
|
1065 | 1087 | offset: function () { |
|
1066 | 1088 | return -this.element.clientHeight + 90; |
|
1067 | 1089 | }, |
|
1068 | 1090 | context: '.fpath-placeholder' |
|
1069 | 1091 | } |
|
1070 | 1092 | ); |
|
1071 | 1093 | |
|
1072 | 1094 | toggleWideDiff = function (el) { |
|
1073 | 1095 | updateSticky(); |
|
1074 | 1096 | var wide = Rhodecode.comments.toggleWideMode(this); |
|
1075 | 1097 | storeUserSessionAttr('rc_user_session_attr.wide_diff_mode', wide); |
|
1076 | 1098 | if (wide === true) { |
|
1077 | 1099 | $(el).addClass('btn-active'); |
|
1078 | 1100 | } else { |
|
1079 | 1101 | $(el).removeClass('btn-active'); |
|
1080 | 1102 | } |
|
1081 | 1103 | return null; |
|
1082 | 1104 | }; |
|
1083 | 1105 | |
|
1084 | 1106 | var preloadDiffMenuData = { |
|
1085 | 1107 | results: [ |
|
1086 | 1108 | |
|
1087 | 1109 | ## Whitespace change |
|
1088 | 1110 | % if request.GET.get('ignorews', '') == '1': |
|
1089 | 1111 | { |
|
1090 | 1112 | id: 2, |
|
1091 | 1113 | text: _gettext('Show whitespace changes'), |
|
1092 | 1114 | action: function () {}, |
|
1093 | 1115 | url: "${h.current_route_path(request, ignorews=0)|n}" |
|
1094 | 1116 | }, |
|
1095 | 1117 | % else: |
|
1096 | 1118 | { |
|
1097 | 1119 | id: 2, |
|
1098 | 1120 | text: _gettext('Hide whitespace changes'), |
|
1099 | 1121 | action: function () {}, |
|
1100 | 1122 | url: "${h.current_route_path(request, ignorews=1)|n}" |
|
1101 | 1123 | }, |
|
1102 | 1124 | % endif |
|
1103 | 1125 | |
|
1104 | 1126 | ## FULL CONTEXT |
|
1105 | 1127 | % if request.GET.get('fullcontext', '') == '1': |
|
1106 | 1128 | { |
|
1107 | 1129 | id: 3, |
|
1108 | 1130 | text: _gettext('Hide full context diff'), |
|
1109 | 1131 | action: function () {}, |
|
1110 | 1132 | url: "${h.current_route_path(request, fullcontext=0)|n}" |
|
1111 | 1133 | }, |
|
1112 | 1134 | % else: |
|
1113 | 1135 | { |
|
1114 | 1136 | id: 3, |
|
1115 | 1137 | text: _gettext('Show full context diff'), |
|
1116 | 1138 | action: function () {}, |
|
1117 | 1139 | url: "${h.current_route_path(request, fullcontext=1)|n}" |
|
1118 | 1140 | }, |
|
1119 | 1141 | % endif |
|
1120 | 1142 | |
|
1121 | 1143 | ] |
|
1122 | 1144 | }; |
|
1123 | 1145 | |
|
1124 | 1146 | var diffMenuId = "#diff_menu_" + "${diffset_container_id}"; |
|
1125 | 1147 | $(diffMenuId).select2({ |
|
1126 | 1148 | minimumResultsForSearch: -1, |
|
1127 | 1149 | containerCssClass: "drop-menu-no-width", |
|
1128 | 1150 | dropdownCssClass: "drop-menu-dropdown", |
|
1129 | 1151 | dropdownAutoWidth: true, |
|
1130 | 1152 | data: preloadDiffMenuData, |
|
1131 | 1153 | placeholder: "${_('...')}", |
|
1132 | 1154 | }); |
|
1133 | 1155 | $(diffMenuId).on('select2-selecting', function (e) { |
|
1134 | 1156 | e.choice.action(); |
|
1135 | 1157 | if (e.choice.url !== null) { |
|
1136 | 1158 | window.location = e.choice.url |
|
1137 | 1159 | } |
|
1138 | 1160 | }); |
|
1139 | 1161 | toggleExpand = function (el, diffsetEl) { |
|
1140 | 1162 | var el = $(el); |
|
1141 | 1163 | if (el.hasClass('collapsed')) { |
|
1142 | 1164 | $('.filediff-collapse-state.collapse-{0}'.format(diffsetEl)).prop('checked', false); |
|
1143 | 1165 | el.removeClass('collapsed'); |
|
1144 | 1166 | el.html( |
|
1145 | 1167 | '<i class="icon-minus-squared-alt icon-no-margin"></i>' + |
|
1146 | 1168 | _gettext('Collapse all files')); |
|
1147 | 1169 | } |
|
1148 | 1170 | else { |
|
1149 | 1171 | $('.filediff-collapse-state.collapse-{0}'.format(diffsetEl)).prop('checked', true); |
|
1150 | 1172 | el.addClass('collapsed'); |
|
1151 | 1173 | el.html( |
|
1152 | 1174 | '<i class="icon-plus-squared-alt icon-no-margin"></i>' + |
|
1153 | 1175 | _gettext('Expand all files')); |
|
1154 | 1176 | } |
|
1155 | 1177 | updateSticky() |
|
1156 | 1178 | }; |
|
1157 | 1179 | |
|
1158 | 1180 | toggleCommitExpand = function (el) { |
|
1159 | 1181 | var $el = $(el); |
|
1160 | 1182 | var commits = $el.data('toggleCommitsCnt'); |
|
1161 | 1183 | var collapseMsg = _ngettext('Collapse {0} commit', 'Collapse {0} commits', commits).format(commits); |
|
1162 | 1184 | var expandMsg = _ngettext('Expand {0} commit', 'Expand {0} commits', commits).format(commits); |
|
1163 | 1185 | |
|
1164 | 1186 | if ($el.hasClass('collapsed')) { |
|
1165 | 1187 | $('.compare_select').show(); |
|
1166 | 1188 | $('.compare_select_hidden').hide(); |
|
1167 | 1189 | |
|
1168 | 1190 | $el.removeClass('collapsed'); |
|
1169 | 1191 | $el.html( |
|
1170 | 1192 | '<i class="icon-minus-squared-alt icon-no-margin"></i>' + |
|
1171 | 1193 | collapseMsg); |
|
1172 | 1194 | } |
|
1173 | 1195 | else { |
|
1174 | 1196 | $('.compare_select').hide(); |
|
1175 | 1197 | $('.compare_select_hidden').show(); |
|
1176 | 1198 | $el.addClass('collapsed'); |
|
1177 | 1199 | $el.html( |
|
1178 | 1200 | '<i class="icon-plus-squared-alt icon-no-margin"></i>' + |
|
1179 | 1201 | expandMsg); |
|
1180 | 1202 | } |
|
1181 | 1203 | updateSticky(); |
|
1182 | 1204 | }; |
|
1183 | 1205 | |
|
1184 | 1206 | // get stored diff mode and pre-enable it |
|
1185 | 1207 | if (templateContext.session_attrs.wide_diff_mode === "true") { |
|
1186 | 1208 | Rhodecode.comments.toggleWideMode(null); |
|
1187 | 1209 | $('.toggle-wide-diff').addClass('btn-active'); |
|
1188 | 1210 | updateSticky(); |
|
1189 | 1211 | } |
|
1190 | 1212 | }); |
|
1191 | 1213 | </script> |
|
1192 | 1214 | |
|
1193 | 1215 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now