Show More
@@ -1,1218 +1,1219 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 | 256 | <% |
|
257 | 257 | file_comments = (get_inline_comments(inline_comments, filediff.patch['filename']) or {}).values() |
|
258 | 258 | total_file_comments = [_c for _c in h.itertools.chain.from_iterable(file_comments) if not _c.outdated] |
|
259 | 259 | %> |
|
260 | 260 | <div class="filediff-collapse-indicator icon-"></div> |
|
261 | 261 | <span class="pill-group pull-right" > |
|
262 | 262 | <span class="pill" op="comments"> |
|
263 | 263 | |
|
264 | 264 | <i class="icon-comment"></i> ${len(total_file_comments)} |
|
265 | 265 | </span> |
|
266 | 266 | </span> |
|
267 | 267 | ${diff_ops(filediff)} |
|
268 | 268 | |
|
269 | 269 | </label> |
|
270 | 270 | |
|
271 | 271 | ${diff_menu(filediff, use_comments=use_comments)} |
|
272 | 272 | <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 '')}"> |
|
273 | 273 | |
|
274 | 274 | ## new/deleted/empty content case |
|
275 | 275 | % if not filediff.hunks: |
|
276 | 276 | ## Comment container, on "fakes" hunk that contains all data to render comments |
|
277 | 277 | ${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)} |
|
278 | 278 | % endif |
|
279 | 279 | |
|
280 | 280 | %if filediff.limited_diff: |
|
281 | 281 | <tr class="cb-warning cb-collapser"> |
|
282 | 282 | <td class="cb-text" ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=4' or 'colspan=6')}> |
|
283 | 283 | ${_('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> |
|
284 | 284 | </td> |
|
285 | 285 | </tr> |
|
286 | 286 | %else: |
|
287 | 287 | %if over_lines_changed_limit: |
|
288 | 288 | <tr class="cb-warning cb-collapser"> |
|
289 | 289 | <td class="cb-text" ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=4' or 'colspan=6')}> |
|
290 | 290 | ${_('This diff has been collapsed as it changes many lines, (%i lines changed)' % lines_changed)} |
|
291 | 291 | <a href="#" class="cb-expand" |
|
292 | 292 | onclick="$(this).closest('table').removeClass('cb-collapsed'); updateSticky(); return false;">${_('Show them')} |
|
293 | 293 | </a> |
|
294 | 294 | <a href="#" class="cb-collapse" |
|
295 | 295 | onclick="$(this).closest('table').addClass('cb-collapsed'); updateSticky(); return false;">${_('Hide them')} |
|
296 | 296 | </a> |
|
297 | 297 | </td> |
|
298 | 298 | </tr> |
|
299 | 299 | %endif |
|
300 | 300 | %endif |
|
301 | 301 | |
|
302 | 302 | % for hunk in filediff.hunks: |
|
303 | 303 | <tr class="cb-hunk"> |
|
304 | 304 | <td ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=3' or '')}> |
|
305 | 305 | ## TODO: dan: add ajax loading of more context here |
|
306 | 306 | ## <a href="#"> |
|
307 | 307 | <i class="icon-more"></i> |
|
308 | 308 | ## </a> |
|
309 | 309 | </td> |
|
310 | 310 | <td ${(c.user_session_attrs["diffmode"] == 'sideside' and 'colspan=5' or '')}> |
|
311 | 311 | @@ |
|
312 | 312 | -${hunk.source_start},${hunk.source_length} |
|
313 | 313 | +${hunk.target_start},${hunk.target_length} |
|
314 | 314 | ${hunk.section_header} |
|
315 | 315 | </td> |
|
316 | 316 | </tr> |
|
317 | 317 | ${render_hunk_lines(filediff, c.user_session_attrs["diffmode"], hunk, use_comments=use_comments, inline_comments=inline_comments, active_pattern_entries=active_pattern_entries)} |
|
318 | 318 | % endfor |
|
319 | 319 | |
|
320 | 320 | <% unmatched_comments = (inline_comments or {}).get(filediff.patch['filename'], {}) %> |
|
321 | 321 | |
|
322 | 322 | ## outdated comments that do not fit into currently displayed lines |
|
323 | 323 | % for lineno, comments in unmatched_comments.items(): |
|
324 | 324 | |
|
325 | 325 | %if c.user_session_attrs["diffmode"] == 'unified': |
|
326 | 326 | % if loop.index == 0: |
|
327 | 327 | <tr class="cb-hunk"> |
|
328 | 328 | <td colspan="3"></td> |
|
329 | 329 | <td> |
|
330 | 330 | <div> |
|
331 | 331 | ${_('Unmatched/outdated inline comments below')} |
|
332 | 332 | </div> |
|
333 | 333 | </td> |
|
334 | 334 | </tr> |
|
335 | 335 | % endif |
|
336 | 336 | <tr class="cb-line"> |
|
337 | 337 | <td class="cb-data cb-context"></td> |
|
338 | 338 | <td class="cb-lineno cb-context"></td> |
|
339 | 339 | <td class="cb-lineno cb-context"></td> |
|
340 | 340 | <td class="cb-content cb-context"> |
|
341 | 341 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
342 | 342 | </td> |
|
343 | 343 | </tr> |
|
344 | 344 | %elif c.user_session_attrs["diffmode"] == 'sideside': |
|
345 | 345 | % if loop.index == 0: |
|
346 | 346 | <tr class="cb-comment-info"> |
|
347 | 347 | <td colspan="2"></td> |
|
348 | 348 | <td class="cb-line"> |
|
349 | 349 | <div> |
|
350 | 350 | ${_('Unmatched/outdated inline comments below')} |
|
351 | 351 | </div> |
|
352 | 352 | </td> |
|
353 | 353 | <td colspan="2"></td> |
|
354 | 354 | <td class="cb-line"> |
|
355 | 355 | <div> |
|
356 | 356 | ${_('Unmatched/outdated comments below')} |
|
357 | 357 | </div> |
|
358 | 358 | </td> |
|
359 | 359 | </tr> |
|
360 | 360 | % endif |
|
361 | 361 | <tr class="cb-line"> |
|
362 | 362 | <td class="cb-data cb-context"></td> |
|
363 | 363 | <td class="cb-lineno cb-context"></td> |
|
364 | 364 | <td class="cb-content cb-context"> |
|
365 | 365 | % if lineno.startswith('o'): |
|
366 | 366 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
367 | 367 | % endif |
|
368 | 368 | </td> |
|
369 | 369 | |
|
370 | 370 | <td class="cb-data cb-context"></td> |
|
371 | 371 | <td class="cb-lineno cb-context"></td> |
|
372 | 372 | <td class="cb-content cb-context"> |
|
373 | 373 | % if lineno.startswith('n'): |
|
374 | 374 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
375 | 375 | % endif |
|
376 | 376 | </td> |
|
377 | 377 | </tr> |
|
378 | 378 | %endif |
|
379 | 379 | |
|
380 | 380 | % endfor |
|
381 | 381 | |
|
382 | 382 | </table> |
|
383 | 383 | </div> |
|
384 | 384 | %endfor |
|
385 | 385 | |
|
386 | 386 | ## outdated comments that are made for a file that has been deleted |
|
387 | 387 | % for filename, comments_dict in (deleted_files_comments or {}).items(): |
|
388 | 388 | |
|
389 | 389 | <% |
|
390 | 390 | display_state = 'display: none' |
|
391 | 391 | open_comments_in_file = [x for x in comments_dict['comments'] if x.outdated is False] |
|
392 | 392 | if open_comments_in_file: |
|
393 | 393 | display_state = '' |
|
394 | 394 | fid = str(id(filename)) |
|
395 | 395 | %> |
|
396 | 396 | <div class="filediffs filediff-outdated" style="${display_state}"> |
|
397 | 397 | <input ${(collapse_all and 'checked' or '')} class="filediff-collapse-state collapse-${diffset_container_id}" id="filediff-collapse-${id(filename)}" type="checkbox" onchange="updateSticky();"> |
|
398 | 398 | <div class="filediff" data-f-path="${filename}" id="a_${h.FID(fid, filename)}"> |
|
399 | 399 | <label for="filediff-collapse-${id(filename)}" class="filediff-heading"> |
|
400 | 400 | <div class="filediff-collapse-indicator icon-"></div> |
|
401 | 401 | |
|
402 | 402 | <span class="pill"> |
|
403 | 403 | ## file was deleted |
|
404 | 404 | ${filename} |
|
405 | 405 | </span> |
|
406 | 406 | <span class="pill-group pull-left" > |
|
407 | 407 | ## file op, doesn't need translation |
|
408 | 408 | <span class="pill" op="removed">unresolved comments</span> |
|
409 | 409 | </span> |
|
410 | 410 | <a class="pill filediff-anchor" href="#a_${h.FID(fid, filename)}">ΒΆ</a> |
|
411 | 411 | <span class="pill-group pull-right"> |
|
412 | 412 | <span class="pill" op="deleted"> |
|
413 | 413 | % if comments_dict['stats'] >0: |
|
414 | 414 | -${comments_dict['stats']} |
|
415 | 415 | % else: |
|
416 | 416 | ${comments_dict['stats']} |
|
417 | 417 | % endif |
|
418 | 418 | </span> |
|
419 | 419 | </span> |
|
420 | 420 | </label> |
|
421 | 421 | |
|
422 | 422 | <table class="cb cb-diff-${c.user_session_attrs["diffmode"]} code-highlight ${(over_lines_changed_limit and 'cb-collapsed' or '')}"> |
|
423 | 423 | <tr> |
|
424 | 424 | % if c.user_session_attrs["diffmode"] == 'unified': |
|
425 | 425 | <td></td> |
|
426 | 426 | %endif |
|
427 | 427 | |
|
428 | 428 | <td></td> |
|
429 | 429 | <td class="cb-text cb-${op_class(BIN_FILENODE)}" ${(c.user_session_attrs["diffmode"] == 'unified' and 'colspan=4' or 'colspan=5')}> |
|
430 | 430 | <strong>${_('This file was removed from diff during updates to this pull-request.')}</strong><br/> |
|
431 | 431 | ${_('There are still outdated/unresolved comments attached to it.')} |
|
432 | 432 | </td> |
|
433 | 433 | </tr> |
|
434 | 434 | %if c.user_session_attrs["diffmode"] == 'unified': |
|
435 | 435 | <tr class="cb-line"> |
|
436 | 436 | <td class="cb-data cb-context"></td> |
|
437 | 437 | <td class="cb-lineno cb-context"></td> |
|
438 | 438 | <td class="cb-lineno cb-context"></td> |
|
439 | 439 | <td class="cb-content cb-context"> |
|
440 | 440 | ${inline_comments_container(comments_dict['comments'], active_pattern_entries=active_pattern_entries)} |
|
441 | 441 | </td> |
|
442 | 442 | </tr> |
|
443 | 443 | %elif c.user_session_attrs["diffmode"] == 'sideside': |
|
444 | 444 | <tr class="cb-line"> |
|
445 | 445 | <td class="cb-data cb-context"></td> |
|
446 | 446 | <td class="cb-lineno cb-context"></td> |
|
447 | 447 | <td class="cb-content cb-context"></td> |
|
448 | 448 | |
|
449 | 449 | <td class="cb-data cb-context"></td> |
|
450 | 450 | <td class="cb-lineno cb-context"></td> |
|
451 | 451 | <td class="cb-content cb-context"> |
|
452 | 452 | ${inline_comments_container(comments_dict['comments'], active_pattern_entries=active_pattern_entries)} |
|
453 | 453 | </td> |
|
454 | 454 | </tr> |
|
455 | 455 | %endif |
|
456 | 456 | </table> |
|
457 | 457 | </div> |
|
458 | 458 | </div> |
|
459 | 459 | % endfor |
|
460 | 460 | |
|
461 | 461 | </div> |
|
462 | 462 | </div> |
|
463 | 463 | </%def> |
|
464 | 464 | |
|
465 | 465 | <%def name="diff_ops(filediff)"> |
|
466 | 466 | <% |
|
467 | 467 | from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \ |
|
468 | 468 | MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE |
|
469 | 469 | %> |
|
470 | 470 | <span class="pill"> |
|
471 | 471 | <i class="icon-file-text"></i> |
|
472 | 472 | %if filediff.source_file_path and filediff.target_file_path: |
|
473 | 473 | %if filediff.source_file_path != filediff.target_file_path: |
|
474 | 474 | ## file was renamed, or copied |
|
475 | 475 | %if RENAMED_FILENODE in filediff.patch['stats']['ops']: |
|
476 | 476 | ${filediff.target_file_path} β¬ <del>${filediff.source_file_path}</del> |
|
477 | 477 | <% final_path = filediff.target_file_path %> |
|
478 | 478 | %elif COPIED_FILENODE in filediff.patch['stats']['ops']: |
|
479 | 479 | ${filediff.target_file_path} β¬ ${filediff.source_file_path} |
|
480 | 480 | <% final_path = filediff.target_file_path %> |
|
481 | 481 | %endif |
|
482 | 482 | %else: |
|
483 | 483 | ## file was modified |
|
484 | 484 | ${filediff.source_file_path} |
|
485 | 485 | <% final_path = filediff.source_file_path %> |
|
486 | 486 | %endif |
|
487 | 487 | %else: |
|
488 | 488 | %if filediff.source_file_path: |
|
489 | 489 | ## file was deleted |
|
490 | 490 | ${filediff.source_file_path} |
|
491 | 491 | <% final_path = filediff.source_file_path %> |
|
492 | 492 | %else: |
|
493 | 493 | ## file was added |
|
494 | 494 | ${filediff.target_file_path} |
|
495 | 495 | <% final_path = filediff.target_file_path %> |
|
496 | 496 | %endif |
|
497 | 497 | %endif |
|
498 | 498 | <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> |
|
499 | 499 | </span> |
|
500 | 500 | ## anchor link |
|
501 | 501 | <a class="pill filediff-anchor" href="#a_${h.FID(filediff.raw_id, filediff.patch['filename'])}">ΒΆ</a> |
|
502 | 502 | |
|
503 | 503 | <span class="pill-group pull-right"> |
|
504 | 504 | |
|
505 | 505 | ## ops pills |
|
506 | 506 | %if filediff.limited_diff: |
|
507 | 507 | <span class="pill tooltip" op="limited" title="The stats for this diff are not complete">limited diff</span> |
|
508 | 508 | %endif |
|
509 | 509 | |
|
510 | 510 | %if NEW_FILENODE in filediff.patch['stats']['ops']: |
|
511 | 511 | <span class="pill" op="created">created</span> |
|
512 | 512 | %if filediff['target_mode'].startswith('120'): |
|
513 | 513 | <span class="pill" op="symlink">symlink</span> |
|
514 | 514 | %else: |
|
515 | 515 | <span class="pill" op="mode">${nice_mode(filediff['target_mode'])}</span> |
|
516 | 516 | %endif |
|
517 | 517 | %endif |
|
518 | 518 | |
|
519 | 519 | %if RENAMED_FILENODE in filediff.patch['stats']['ops']: |
|
520 | 520 | <span class="pill" op="renamed">renamed</span> |
|
521 | 521 | %endif |
|
522 | 522 | |
|
523 | 523 | %if COPIED_FILENODE in filediff.patch['stats']['ops']: |
|
524 | 524 | <span class="pill" op="copied">copied</span> |
|
525 | 525 | %endif |
|
526 | 526 | |
|
527 | 527 | %if DEL_FILENODE in filediff.patch['stats']['ops']: |
|
528 | 528 | <span class="pill" op="removed">removed</span> |
|
529 | 529 | %endif |
|
530 | 530 | |
|
531 | 531 | %if CHMOD_FILENODE in filediff.patch['stats']['ops']: |
|
532 | 532 | <span class="pill" op="mode"> |
|
533 | 533 | ${nice_mode(filediff['source_mode'])} β‘ ${nice_mode(filediff['target_mode'])} |
|
534 | 534 | </span> |
|
535 | 535 | %endif |
|
536 | 536 | |
|
537 | 537 | %if BIN_FILENODE in filediff.patch['stats']['ops']: |
|
538 | 538 | <span class="pill" op="binary">binary</span> |
|
539 | 539 | %if MOD_FILENODE in filediff.patch['stats']['ops']: |
|
540 | 540 | <span class="pill" op="modified">modified</span> |
|
541 | 541 | %endif |
|
542 | 542 | %endif |
|
543 | 543 | |
|
544 | 544 | <span class="pill" op="added">${('+' if filediff.patch['stats']['added'] else '')}${filediff.patch['stats']['added']}</span> |
|
545 | 545 | <span class="pill" op="deleted">${((h.safe_int(filediff.patch['stats']['deleted']) or 0) * -1)}</span> |
|
546 | 546 | |
|
547 | 547 | </span> |
|
548 | 548 | |
|
549 | 549 | </%def> |
|
550 | 550 | |
|
551 | 551 | <%def name="nice_mode(filemode)"> |
|
552 | 552 | ${(filemode.startswith('100') and filemode[3:] or filemode)} |
|
553 | 553 | </%def> |
|
554 | 554 | |
|
555 | 555 | <%def name="diff_menu(filediff, use_comments=False)"> |
|
556 | 556 | <div class="filediff-menu"> |
|
557 | 557 | |
|
558 | 558 | %if filediff.diffset.source_ref: |
|
559 | 559 | |
|
560 | 560 | ## FILE BEFORE CHANGES |
|
561 | 561 | %if filediff.operation in ['D', 'M']: |
|
562 | 562 | <a |
|
563 | 563 | class="tooltip" |
|
564 | 564 | 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)}" |
|
565 | 565 | title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}" |
|
566 | 566 | > |
|
567 | 567 | ${_('Show file before')} |
|
568 | 568 | </a> | |
|
569 | 569 | %else: |
|
570 | 570 | <span |
|
571 | 571 | class="tooltip" |
|
572 | 572 | title="${h.tooltip(_('File not present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.source_ref[:12]})}" |
|
573 | 573 | > |
|
574 | 574 | ${_('Show file before')} |
|
575 | 575 | </span> | |
|
576 | 576 | %endif |
|
577 | 577 | |
|
578 | 578 | ## FILE AFTER CHANGES |
|
579 | 579 | %if filediff.operation in ['A', 'M']: |
|
580 | 580 | <a |
|
581 | 581 | class="tooltip" |
|
582 | 582 | 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)}" |
|
583 | 583 | title="${h.tooltip(_('Show file at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}" |
|
584 | 584 | > |
|
585 | 585 | ${_('Show file after')} |
|
586 | 586 | </a> |
|
587 | 587 | %else: |
|
588 | 588 | <span |
|
589 | 589 | class="tooltip" |
|
590 | 590 | title="${h.tooltip(_('File not present at commit: %(commit_id)s') % {'commit_id': filediff.diffset.target_ref[:12]})}" |
|
591 | 591 | > |
|
592 | 592 | ${_('Show file after')} |
|
593 | 593 | </span> |
|
594 | 594 | %endif |
|
595 | 595 | |
|
596 | 596 | % if use_comments: |
|
597 | 597 | | |
|
598 | 598 | <a href="#" onclick="return Rhodecode.comments.toggleComments(this);"> |
|
599 | 599 | <span class="show-comment-button">${_('Show comments')}</span><span class="hide-comment-button">${_('Hide comments')}</span> |
|
600 | 600 | </a> |
|
601 | 601 | % endif |
|
602 | 602 | |
|
603 | 603 | %endif |
|
604 | 604 | |
|
605 | 605 | </div> |
|
606 | 606 | </%def> |
|
607 | 607 | |
|
608 | 608 | |
|
609 | 609 | <%def name="inline_comments_container(comments, active_pattern_entries=None)"> |
|
610 | 610 | |
|
611 | 611 | <div class="inline-comments"> |
|
612 | 612 | %for comment in comments: |
|
613 | 613 | ${commentblock.comment_block(comment, inline=True, active_pattern_entries=active_pattern_entries)} |
|
614 | 614 | %endfor |
|
615 | 615 | % if comments and comments[-1].outdated: |
|
616 | 616 | <span class="btn btn-secondary cb-comment-add-button comment-outdated}" style="display: none;}"> |
|
617 | 617 | ${_('Add another comment')} |
|
618 | 618 | </span> |
|
619 | 619 | % else: |
|
620 | 620 | <span onclick="return Rhodecode.comments.createComment(this)" class="btn btn-secondary cb-comment-add-button"> |
|
621 | 621 | ${_('Add another comment')} |
|
622 | 622 | </span> |
|
623 | 623 | % endif |
|
624 | 624 | |
|
625 | 625 | </div> |
|
626 | 626 | </%def> |
|
627 | 627 | |
|
628 | 628 | <%! |
|
629 | 629 | |
|
630 | 630 | def get_inline_comments(comments, filename): |
|
631 | 631 | if hasattr(filename, 'unicode_path'): |
|
632 | 632 | filename = filename.unicode_path |
|
633 | 633 | |
|
634 | 634 | if not isinstance(filename, (unicode, str)): |
|
635 | 635 | return None |
|
636 | 636 | |
|
637 | 637 | if comments and filename in comments: |
|
638 | 638 | return comments[filename] |
|
639 | 639 | |
|
640 | 640 | return None |
|
641 | 641 | |
|
642 | 642 | def get_comments_for(diff_type, comments, filename, line_version, line_number): |
|
643 | 643 | if hasattr(filename, 'unicode_path'): |
|
644 | 644 | filename = filename.unicode_path |
|
645 | 645 | |
|
646 | 646 | if not isinstance(filename, (unicode, str)): |
|
647 | 647 | return None |
|
648 | 648 | |
|
649 | 649 | file_comments = get_inline_comments(comments, filename) |
|
650 | 650 | if file_comments is None: |
|
651 | 651 | return None |
|
652 | 652 | |
|
653 | 653 | line_key = '{}{}'.format(line_version, line_number) ## e.g o37, n12 |
|
654 | 654 | if line_key in file_comments: |
|
655 | 655 | data = file_comments.pop(line_key) |
|
656 | 656 | return data |
|
657 | 657 | %> |
|
658 | 658 | |
|
659 | 659 | <%def name="render_hunk_lines_sideside(filediff, hunk, use_comments=False, inline_comments=None, active_pattern_entries=None)"> |
|
660 | 660 | %for i, line in enumerate(hunk.sideside): |
|
661 | 661 | <% |
|
662 | 662 | old_line_anchor, new_line_anchor = None, None |
|
663 | 663 | |
|
664 | 664 | if line.original.lineno: |
|
665 | 665 | old_line_anchor = diff_line_anchor(filediff.raw_id, hunk.source_file_path, line.original.lineno, 'o') |
|
666 | 666 | if line.modified.lineno: |
|
667 | 667 | new_line_anchor = diff_line_anchor(filediff.raw_id, hunk.target_file_path, line.modified.lineno, 'n') |
|
668 | 668 | %> |
|
669 | 669 | |
|
670 | 670 | <tr class="cb-line"> |
|
671 | 671 | <td class="cb-data ${action_class(line.original.action)}" |
|
672 | 672 | data-line-no="${line.original.lineno}" |
|
673 | 673 | > |
|
674 | 674 | <div> |
|
675 | 675 | |
|
676 | 676 | <% line_old_comments = None %> |
|
677 | 677 | %if line.original.get_comment_args: |
|
678 | 678 | <% line_old_comments = get_comments_for('side-by-side', inline_comments, *line.original.get_comment_args) %> |
|
679 | 679 | %endif |
|
680 | 680 | %if line_old_comments: |
|
681 | 681 | <% has_outdated = any([x.outdated for x in line_old_comments]) %> |
|
682 | 682 | % if has_outdated: |
|
683 |
<i class="tooltip" title="${_('comments including outdated |
|
|
683 | <i class="tooltip icon-comment-toggle" title="${_('comments including outdated: {}. Click here to display them.').format(len(line_old_comments))}" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
|
684 | 684 | % else: |
|
685 |
<i class="tooltip" title="${_('comments |
|
|
685 | <i class="tooltip icon-comment" title="${_('comments: {}. Click to toggle them.').format(len(line_old_comments))}" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
|
686 | 686 | % endif |
|
687 | 687 | %endif |
|
688 | 688 | </div> |
|
689 | 689 | </td> |
|
690 | 690 | <td class="cb-lineno ${action_class(line.original.action)}" |
|
691 | 691 | data-line-no="${line.original.lineno}" |
|
692 | 692 | %if old_line_anchor: |
|
693 | 693 | id="${old_line_anchor}" |
|
694 | 694 | %endif |
|
695 | 695 | > |
|
696 | 696 | %if line.original.lineno: |
|
697 | 697 | <a name="${old_line_anchor}" href="#${old_line_anchor}">${line.original.lineno}</a> |
|
698 | 698 | %endif |
|
699 | 699 | </td> |
|
700 | 700 | <td class="cb-content ${action_class(line.original.action)}" |
|
701 | 701 | data-line-no="o${line.original.lineno}" |
|
702 | 702 | > |
|
703 | 703 | %if use_comments and line.original.lineno: |
|
704 | 704 | ${render_add_comment_button()} |
|
705 | 705 | %endif |
|
706 | 706 | <span class="cb-code"><span class="cb-action ${action_class(line.original.action)}"></span>${line.original.content or '' | n}</span> |
|
707 | 707 | |
|
708 | 708 | %if use_comments and line.original.lineno and line_old_comments: |
|
709 | 709 | ${inline_comments_container(line_old_comments, active_pattern_entries=active_pattern_entries)} |
|
710 | 710 | %endif |
|
711 | 711 | |
|
712 | 712 | </td> |
|
713 | 713 | <td class="cb-data ${action_class(line.modified.action)}" |
|
714 | 714 | data-line-no="${line.modified.lineno}" |
|
715 | 715 | > |
|
716 | 716 | <div> |
|
717 | 717 | |
|
718 | 718 | %if line.modified.get_comment_args: |
|
719 | 719 | <% line_new_comments = get_comments_for('side-by-side', inline_comments, *line.modified.get_comment_args) %> |
|
720 | 720 | %else: |
|
721 | 721 | <% line_new_comments = None%> |
|
722 | 722 | %endif |
|
723 | 723 | %if line_new_comments: |
|
724 | ||
|
724 | 725 | <% has_outdated = any([x.outdated for x in line_new_comments]) %> |
|
725 | 726 | % if has_outdated: |
|
726 |
<i class="tooltip" title="${_('comments including outdated |
|
|
727 | <i class="tooltip icon-comment-toggle" title="${_('comments including outdated: {}. Click here to display them.').format(len(line_new_comments))}" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
|
727 | 728 | % else: |
|
728 |
<i class="tooltip" title="${_('comments |
|
|
729 | <i class="tooltip icon-comment" title="${_('comments: {}. Click to toggle them.').format(len(line_new_comments))}" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
|
729 | 730 | % endif |
|
730 | 731 | %endif |
|
731 | 732 | </div> |
|
732 | 733 | </td> |
|
733 | 734 | <td class="cb-lineno ${action_class(line.modified.action)}" |
|
734 | 735 | data-line-no="${line.modified.lineno}" |
|
735 | 736 | %if new_line_anchor: |
|
736 | 737 | id="${new_line_anchor}" |
|
737 | 738 | %endif |
|
738 | 739 | > |
|
739 | 740 | %if line.modified.lineno: |
|
740 | 741 | <a name="${new_line_anchor}" href="#${new_line_anchor}">${line.modified.lineno}</a> |
|
741 | 742 | %endif |
|
742 | 743 | </td> |
|
743 | 744 | <td class="cb-content ${action_class(line.modified.action)}" |
|
744 | 745 | data-line-no="n${line.modified.lineno}" |
|
745 | 746 | > |
|
746 | 747 | %if use_comments and line.modified.lineno: |
|
747 | 748 | ${render_add_comment_button()} |
|
748 | 749 | %endif |
|
749 | 750 | <span class="cb-code"><span class="cb-action ${action_class(line.modified.action)}"></span>${line.modified.content or '' | n}</span> |
|
750 | 751 | %if use_comments and line.modified.lineno and line_new_comments: |
|
751 | 752 | ${inline_comments_container(line_new_comments, active_pattern_entries=active_pattern_entries)} |
|
752 | 753 | %endif |
|
753 | 754 | </td> |
|
754 | 755 | </tr> |
|
755 | 756 | %endfor |
|
756 | 757 | </%def> |
|
757 | 758 | |
|
758 | 759 | |
|
759 | 760 | <%def name="render_hunk_lines_unified(filediff, hunk, use_comments=False, inline_comments=None, active_pattern_entries=None)"> |
|
760 | 761 | %for old_line_no, new_line_no, action, content, comments_args in hunk.unified: |
|
761 | 762 | |
|
762 | 763 | <% |
|
763 | 764 | old_line_anchor, new_line_anchor = None, None |
|
764 | 765 | if old_line_no: |
|
765 | 766 | old_line_anchor = diff_line_anchor(filediff.raw_id, hunk.source_file_path, old_line_no, 'o') |
|
766 | 767 | if new_line_no: |
|
767 | 768 | new_line_anchor = diff_line_anchor(filediff.raw_id, hunk.target_file_path, new_line_no, 'n') |
|
768 | 769 | %> |
|
769 | 770 | <tr class="cb-line"> |
|
770 | 771 | <td class="cb-data ${action_class(action)}"> |
|
771 | 772 | <div> |
|
772 | 773 | |
|
773 | 774 | %if comments_args: |
|
774 | 775 | <% comments = get_comments_for('unified', inline_comments, *comments_args) %> |
|
775 | 776 | %else: |
|
776 | 777 | <% comments = None %> |
|
777 | 778 | %endif |
|
778 | 779 | |
|
779 | 780 | % if comments: |
|
780 | 781 | <% has_outdated = any([x.outdated for x in comments]) %> |
|
781 | 782 | % if has_outdated: |
|
782 |
<i class="tooltip" title="${_('comments including outdated |
|
|
783 | <i class="tooltip icon-comment-toggle" title="${_('comments including outdated: {}. Click here to display them.').format(len(comments))}" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
|
783 | 784 | % else: |
|
784 |
<i class="tooltip" title="${_('comments |
|
|
785 | <i class="tooltip icon-comment" title="${_('comments: {}. Click to toggle them.').format(len(comments))}" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
|
785 | 786 | % endif |
|
786 | 787 | % endif |
|
787 | 788 | </div> |
|
788 | 789 | </td> |
|
789 | 790 | <td class="cb-lineno ${action_class(action)}" |
|
790 | 791 | data-line-no="${old_line_no}" |
|
791 | 792 | %if old_line_anchor: |
|
792 | 793 | id="${old_line_anchor}" |
|
793 | 794 | %endif |
|
794 | 795 | > |
|
795 | 796 | %if old_line_anchor: |
|
796 | 797 | <a name="${old_line_anchor}" href="#${old_line_anchor}">${old_line_no}</a> |
|
797 | 798 | %endif |
|
798 | 799 | </td> |
|
799 | 800 | <td class="cb-lineno ${action_class(action)}" |
|
800 | 801 | data-line-no="${new_line_no}" |
|
801 | 802 | %if new_line_anchor: |
|
802 | 803 | id="${new_line_anchor}" |
|
803 | 804 | %endif |
|
804 | 805 | > |
|
805 | 806 | %if new_line_anchor: |
|
806 | 807 | <a name="${new_line_anchor}" href="#${new_line_anchor}">${new_line_no}</a> |
|
807 | 808 | %endif |
|
808 | 809 | </td> |
|
809 | 810 | <td class="cb-content ${action_class(action)}" |
|
810 | 811 | data-line-no="${(new_line_no and 'n' or 'o')}${(new_line_no or old_line_no)}" |
|
811 | 812 | > |
|
812 | 813 | %if use_comments: |
|
813 | 814 | ${render_add_comment_button()} |
|
814 | 815 | %endif |
|
815 | 816 | <span class="cb-code"><span class="cb-action ${action_class(action)}"></span> ${content or '' | n}</span> |
|
816 | 817 | %if use_comments and comments: |
|
817 | 818 | ${inline_comments_container(comments, active_pattern_entries=active_pattern_entries)} |
|
818 | 819 | %endif |
|
819 | 820 | </td> |
|
820 | 821 | </tr> |
|
821 | 822 | %endfor |
|
822 | 823 | </%def> |
|
823 | 824 | |
|
824 | 825 | |
|
825 | 826 | <%def name="render_hunk_lines(filediff, diff_mode, hunk, use_comments, inline_comments, active_pattern_entries)"> |
|
826 | 827 | % if diff_mode == 'unified': |
|
827 | 828 | ${render_hunk_lines_unified(filediff, hunk, use_comments=use_comments, inline_comments=inline_comments, active_pattern_entries=active_pattern_entries)} |
|
828 | 829 | % elif diff_mode == 'sideside': |
|
829 | 830 | ${render_hunk_lines_sideside(filediff, hunk, use_comments=use_comments, inline_comments=inline_comments, active_pattern_entries=active_pattern_entries)} |
|
830 | 831 | % else: |
|
831 | 832 | <tr class="cb-line"> |
|
832 | 833 | <td>unknown diff mode</td> |
|
833 | 834 | </tr> |
|
834 | 835 | % endif |
|
835 | 836 | </%def>file changes |
|
836 | 837 | |
|
837 | 838 | |
|
838 | 839 | <%def name="render_add_comment_button()"> |
|
839 | 840 | <button class="btn btn-small btn-primary cb-comment-box-opener" onclick="return Rhodecode.comments.createComment(this)"> |
|
840 | 841 | <span><i class="icon-comment"></i></span> |
|
841 | 842 | </button> |
|
842 | 843 | </%def> |
|
843 | 844 | |
|
844 | 845 | <%def name="render_diffset_menu(diffset, range_diff_on=None)"> |
|
845 | 846 | <% diffset_container_id = h.md5(diffset.target_ref) %> |
|
846 | 847 | |
|
847 | 848 | <div id="diff-file-sticky" class="diffset-menu clearinner"> |
|
848 | 849 | ## auto adjustable |
|
849 | 850 | <div class="sidebar__inner"> |
|
850 | 851 | <div class="sidebar__bar"> |
|
851 | 852 | <div class="pull-right"> |
|
852 | 853 | <div class="btn-group"> |
|
853 | 854 | <a class="btn tooltip toggle-wide-diff" href="#toggle-wide-diff" onclick="toggleWideDiff(this); return false" title="${h.tooltip(_('Toggle wide diff'))}"> |
|
854 | 855 | <i class="icon-wide-mode"></i> |
|
855 | 856 | </a> |
|
856 | 857 | </div> |
|
857 | 858 | <div class="btn-group"> |
|
858 | 859 | |
|
859 | 860 | <a |
|
860 | 861 | class="btn ${(c.user_session_attrs["diffmode"] == 'sideside' and 'btn-active')} tooltip" |
|
861 | 862 | title="${h.tooltip(_('View diff as side by side'))}" |
|
862 | 863 | href="${h.current_route_path(request, diffmode='sideside')}"> |
|
863 | 864 | <span>${_('Side by Side')}</span> |
|
864 | 865 | </a> |
|
865 | 866 | |
|
866 | 867 | <a |
|
867 | 868 | class="btn ${(c.user_session_attrs["diffmode"] == 'unified' and 'btn-active')} tooltip" |
|
868 | 869 | title="${h.tooltip(_('View diff as unified'))}" href="${h.current_route_path(request, diffmode='unified')}"> |
|
869 | 870 | <span>${_('Unified')}</span> |
|
870 | 871 | </a> |
|
871 | 872 | |
|
872 | 873 | % if range_diff_on is True: |
|
873 | 874 | <a |
|
874 | 875 | title="${_('Turn off: Show the diff as commit range')}" |
|
875 | 876 | class="btn btn-primary" |
|
876 | 877 | href="${h.current_route_path(request, **{"range-diff":"0"})}"> |
|
877 | 878 | <span>${_('Range Diff')}</span> |
|
878 | 879 | </a> |
|
879 | 880 | % elif range_diff_on is False: |
|
880 | 881 | <a |
|
881 | 882 | title="${_('Show the diff as commit range')}" |
|
882 | 883 | class="btn" |
|
883 | 884 | href="${h.current_route_path(request, **{"range-diff":"1"})}"> |
|
884 | 885 | <span>${_('Range Diff')}</span> |
|
885 | 886 | </a> |
|
886 | 887 | % endif |
|
887 | 888 | </div> |
|
888 | 889 | <div class="btn-group"> |
|
889 | 890 | |
|
890 | 891 | <div class="pull-left"> |
|
891 | 892 | ${h.hidden('diff_menu_{}'.format(diffset_container_id))} |
|
892 | 893 | </div> |
|
893 | 894 | |
|
894 | 895 | </div> |
|
895 | 896 | </div> |
|
896 | 897 | <div class="pull-left"> |
|
897 | 898 | <div class="btn-group"> |
|
898 | 899 | <div class="pull-left"> |
|
899 | 900 | ${h.hidden('file_filter_{}'.format(diffset_container_id))} |
|
900 | 901 | </div> |
|
901 | 902 | |
|
902 | 903 | </div> |
|
903 | 904 | </div> |
|
904 | 905 | </div> |
|
905 | 906 | <div class="fpath-placeholder"> |
|
906 | 907 | <i class="icon-file-text"></i> |
|
907 | 908 | <strong class="fpath-placeholder-text"> |
|
908 | 909 | Context file: |
|
909 | 910 | </strong> |
|
910 | 911 | </div> |
|
911 | 912 | <div class="sidebar_inner_shadow"></div> |
|
912 | 913 | </div> |
|
913 | 914 | </div> |
|
914 | 915 | |
|
915 | 916 | % if diffset: |
|
916 | 917 | %if diffset.limited_diff: |
|
917 | 918 | <% file_placeholder = _ungettext('%(num)s file changed', '%(num)s files changed', diffset.changed_files) % {'num': diffset.changed_files} %> |
|
918 | 919 | %else: |
|
919 | 920 | <% 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>', |
|
920 | 921 | diffset.changed_files) % {'num': diffset.changed_files, 'linesadd': diffset.lines_added, 'linesdel': diffset.lines_deleted}) %> |
|
921 | 922 | |
|
922 | 923 | %endif |
|
923 | 924 | ## case on range-diff placeholder needs to be updated |
|
924 | 925 | % if range_diff_on is True: |
|
925 | 926 | <% file_placeholder = _('Disabled on range diff') %> |
|
926 | 927 | % endif |
|
927 | 928 | |
|
928 | 929 | <script type="text/javascript"> |
|
929 | 930 | var feedFilesOptions = function (query, initialData) { |
|
930 | 931 | var data = {results: []}; |
|
931 | 932 | var isQuery = typeof query.term !== 'undefined'; |
|
932 | 933 | |
|
933 | 934 | var section = _gettext('Changed files'); |
|
934 | 935 | var filteredData = []; |
|
935 | 936 | |
|
936 | 937 | //filter results |
|
937 | 938 | $.each(initialData.results, function (idx, value) { |
|
938 | 939 | |
|
939 | 940 | if (!isQuery || query.term.length === 0 || value.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { |
|
940 | 941 | filteredData.push({ |
|
941 | 942 | 'id': this.id, |
|
942 | 943 | 'text': this.text, |
|
943 | 944 | "ops": this.ops, |
|
944 | 945 | }) |
|
945 | 946 | } |
|
946 | 947 | |
|
947 | 948 | }); |
|
948 | 949 | |
|
949 | 950 | data.results = filteredData; |
|
950 | 951 | |
|
951 | 952 | query.callback(data); |
|
952 | 953 | }; |
|
953 | 954 | |
|
954 | 955 | var selectionFormatter = function(data, escapeMarkup) { |
|
955 | 956 | var container = '<div class="filelist" style="padding-right:100px">{0}</div>'; |
|
956 | 957 | var tmpl = '<div><strong>{0}</strong></div>'.format(escapeMarkup(data['text'])); |
|
957 | 958 | var pill = '<div class="pill-group" style="position: absolute; top:7px; right: 0">' + |
|
958 | 959 | '<span class="pill" op="added">{0}</span>' + |
|
959 | 960 | '<span class="pill" op="deleted">{1}</span>' + |
|
960 | 961 | '</div>' |
|
961 | 962 | ; |
|
962 | 963 | var added = data['ops']['added']; |
|
963 | 964 | if (added === 0) { |
|
964 | 965 | // don't show +0 |
|
965 | 966 | added = 0; |
|
966 | 967 | } else { |
|
967 | 968 | added = '+' + added; |
|
968 | 969 | } |
|
969 | 970 | |
|
970 | 971 | var deleted = -1*data['ops']['deleted']; |
|
971 | 972 | |
|
972 | 973 | tmpl += pill.format(added, deleted); |
|
973 | 974 | return container.format(tmpl); |
|
974 | 975 | }; |
|
975 | 976 | var formatFileResult = function(result, container, query, escapeMarkup) { |
|
976 | 977 | return selectionFormatter(result, escapeMarkup); |
|
977 | 978 | }; |
|
978 | 979 | |
|
979 | 980 | var formatSelection = function (data, container) { |
|
980 | 981 | return '${file_placeholder}' |
|
981 | 982 | }; |
|
982 | 983 | |
|
983 | 984 | if (window.preloadFileFilterData === undefined) { |
|
984 | 985 | window.preloadFileFilterData = {} |
|
985 | 986 | } |
|
986 | 987 | |
|
987 | 988 | preloadFileFilterData["${diffset_container_id}"] = { |
|
988 | 989 | results: [ |
|
989 | 990 | % for filediff in diffset.files: |
|
990 | 991 | {id:"a_${h.FID(filediff.raw_id, filediff.patch['filename'])}", |
|
991 | 992 | text:"${filediff.patch['filename']}", |
|
992 | 993 | ops:${h.json.dumps(filediff.patch['stats'])|n}}${('' if loop.last else ',')} |
|
993 | 994 | % endfor |
|
994 | 995 | ] |
|
995 | 996 | }; |
|
996 | 997 | |
|
997 | 998 | var diffFileFilterId = "#file_filter_" + "${diffset_container_id}"; |
|
998 | 999 | var diffFileFilter = $(diffFileFilterId).select2({ |
|
999 | 1000 | 'dropdownAutoWidth': true, |
|
1000 | 1001 | 'width': 'auto', |
|
1001 | 1002 | |
|
1002 | 1003 | containerCssClass: "drop-menu", |
|
1003 | 1004 | dropdownCssClass: "drop-menu-dropdown", |
|
1004 | 1005 | data: preloadFileFilterData["${diffset_container_id}"], |
|
1005 | 1006 | query: function(query) { |
|
1006 | 1007 | feedFilesOptions(query, preloadFileFilterData["${diffset_container_id}"]); |
|
1007 | 1008 | }, |
|
1008 | 1009 | initSelection: function(element, callback) { |
|
1009 | 1010 | callback({'init': true}); |
|
1010 | 1011 | }, |
|
1011 | 1012 | formatResult: formatFileResult, |
|
1012 | 1013 | formatSelection: formatSelection |
|
1013 | 1014 | }); |
|
1014 | 1015 | |
|
1015 | 1016 | % if range_diff_on is True: |
|
1016 | 1017 | diffFileFilter.select2("enable", false); |
|
1017 | 1018 | % endif |
|
1018 | 1019 | |
|
1019 | 1020 | $(diffFileFilterId).on('select2-selecting', function (e) { |
|
1020 | 1021 | var idSelector = e.choice.id; |
|
1021 | 1022 | |
|
1022 | 1023 | // expand the container if we quick-select the field |
|
1023 | 1024 | $('#'+idSelector).next().prop('checked', false); |
|
1024 | 1025 | // hide the mast as we later do preventDefault() |
|
1025 | 1026 | $("#select2-drop-mask").click(); |
|
1026 | 1027 | |
|
1027 | 1028 | window.location.hash = '#'+idSelector; |
|
1028 | 1029 | updateSticky(); |
|
1029 | 1030 | |
|
1030 | 1031 | e.preventDefault(); |
|
1031 | 1032 | }); |
|
1032 | 1033 | |
|
1033 | 1034 | </script> |
|
1034 | 1035 | % endif |
|
1035 | 1036 | |
|
1036 | 1037 | <script type="text/javascript"> |
|
1037 | 1038 | $(document).ready(function () { |
|
1038 | 1039 | |
|
1039 | 1040 | var contextPrefix = _gettext('Context file: '); |
|
1040 | 1041 | ## sticky sidebar |
|
1041 | 1042 | var sidebarElement = document.getElementById('diff-file-sticky'); |
|
1042 | 1043 | sidebar = new StickySidebar(sidebarElement, { |
|
1043 | 1044 | topSpacing: 0, |
|
1044 | 1045 | bottomSpacing: 0, |
|
1045 | 1046 | innerWrapperSelector: '.sidebar__inner' |
|
1046 | 1047 | }); |
|
1047 | 1048 | sidebarElement.addEventListener('affixed.static.stickySidebar', function () { |
|
1048 | 1049 | // reset our file so it's not holding new value |
|
1049 | 1050 | $('.fpath-placeholder-text').html(contextPrefix + ' - ') |
|
1050 | 1051 | }); |
|
1051 | 1052 | |
|
1052 | 1053 | updateSticky = function () { |
|
1053 | 1054 | sidebar.updateSticky(); |
|
1054 | 1055 | Waypoint.refreshAll(); |
|
1055 | 1056 | }; |
|
1056 | 1057 | |
|
1057 | 1058 | var animateText = function (fPath, anchorId) { |
|
1058 | 1059 | fPath = Select2.util.escapeMarkup(fPath); |
|
1059 | 1060 | $('.fpath-placeholder-text').html(contextPrefix + '<a href="#a_' + anchorId + '">' + fPath + '</a>') |
|
1060 | 1061 | }; |
|
1061 | 1062 | |
|
1062 | 1063 | ## dynamic file waypoints |
|
1063 | 1064 | var setFPathInfo = function(fPath, anchorId){ |
|
1064 | 1065 | animateText(fPath, anchorId) |
|
1065 | 1066 | }; |
|
1066 | 1067 | |
|
1067 | 1068 | var codeBlock = $('.filediff'); |
|
1068 | 1069 | |
|
1069 | 1070 | // forward waypoint |
|
1070 | 1071 | codeBlock.waypoint( |
|
1071 | 1072 | function(direction) { |
|
1072 | 1073 | if (direction === "down"){ |
|
1073 | 1074 | setFPathInfo($(this.element).data('fPath'), $(this.element).data('anchorId')) |
|
1074 | 1075 | } |
|
1075 | 1076 | }, { |
|
1076 | 1077 | offset: function () { |
|
1077 | 1078 | return 70; |
|
1078 | 1079 | }, |
|
1079 | 1080 | context: '.fpath-placeholder' |
|
1080 | 1081 | } |
|
1081 | 1082 | ); |
|
1082 | 1083 | |
|
1083 | 1084 | // backward waypoint |
|
1084 | 1085 | codeBlock.waypoint( |
|
1085 | 1086 | function(direction) { |
|
1086 | 1087 | if (direction === "up"){ |
|
1087 | 1088 | setFPathInfo($(this.element).data('fPath'), $(this.element).data('anchorId')) |
|
1088 | 1089 | } |
|
1089 | 1090 | }, { |
|
1090 | 1091 | offset: function () { |
|
1091 | 1092 | return -this.element.clientHeight + 90; |
|
1092 | 1093 | }, |
|
1093 | 1094 | context: '.fpath-placeholder' |
|
1094 | 1095 | } |
|
1095 | 1096 | ); |
|
1096 | 1097 | |
|
1097 | 1098 | toggleWideDiff = function (el) { |
|
1098 | 1099 | updateSticky(); |
|
1099 | 1100 | var wide = Rhodecode.comments.toggleWideMode(this); |
|
1100 | 1101 | storeUserSessionAttr('rc_user_session_attr.wide_diff_mode', wide); |
|
1101 | 1102 | if (wide === true) { |
|
1102 | 1103 | $(el).addClass('btn-active'); |
|
1103 | 1104 | } else { |
|
1104 | 1105 | $(el).removeClass('btn-active'); |
|
1105 | 1106 | } |
|
1106 | 1107 | return null; |
|
1107 | 1108 | }; |
|
1108 | 1109 | |
|
1109 | 1110 | var preloadDiffMenuData = { |
|
1110 | 1111 | results: [ |
|
1111 | 1112 | |
|
1112 | 1113 | ## Whitespace change |
|
1113 | 1114 | % if request.GET.get('ignorews', '') == '1': |
|
1114 | 1115 | { |
|
1115 | 1116 | id: 2, |
|
1116 | 1117 | text: _gettext('Show whitespace changes'), |
|
1117 | 1118 | action: function () {}, |
|
1118 | 1119 | url: "${h.current_route_path(request, ignorews=0)|n}" |
|
1119 | 1120 | }, |
|
1120 | 1121 | % else: |
|
1121 | 1122 | { |
|
1122 | 1123 | id: 2, |
|
1123 | 1124 | text: _gettext('Hide whitespace changes'), |
|
1124 | 1125 | action: function () {}, |
|
1125 | 1126 | url: "${h.current_route_path(request, ignorews=1)|n}" |
|
1126 | 1127 | }, |
|
1127 | 1128 | % endif |
|
1128 | 1129 | |
|
1129 | 1130 | ## FULL CONTEXT |
|
1130 | 1131 | % if request.GET.get('fullcontext', '') == '1': |
|
1131 | 1132 | { |
|
1132 | 1133 | id: 3, |
|
1133 | 1134 | text: _gettext('Hide full context diff'), |
|
1134 | 1135 | action: function () {}, |
|
1135 | 1136 | url: "${h.current_route_path(request, fullcontext=0)|n}" |
|
1136 | 1137 | }, |
|
1137 | 1138 | % else: |
|
1138 | 1139 | { |
|
1139 | 1140 | id: 3, |
|
1140 | 1141 | text: _gettext('Show full context diff'), |
|
1141 | 1142 | action: function () {}, |
|
1142 | 1143 | url: "${h.current_route_path(request, fullcontext=1)|n}" |
|
1143 | 1144 | }, |
|
1144 | 1145 | % endif |
|
1145 | 1146 | |
|
1146 | 1147 | ] |
|
1147 | 1148 | }; |
|
1148 | 1149 | |
|
1149 | 1150 | var diffMenuId = "#diff_menu_" + "${diffset_container_id}"; |
|
1150 | 1151 | $(diffMenuId).select2({ |
|
1151 | 1152 | minimumResultsForSearch: -1, |
|
1152 | 1153 | containerCssClass: "drop-menu-no-width", |
|
1153 | 1154 | dropdownCssClass: "drop-menu-dropdown", |
|
1154 | 1155 | dropdownAutoWidth: true, |
|
1155 | 1156 | data: preloadDiffMenuData, |
|
1156 | 1157 | placeholder: "${_('...')}", |
|
1157 | 1158 | }); |
|
1158 | 1159 | $(diffMenuId).on('select2-selecting', function (e) { |
|
1159 | 1160 | e.choice.action(); |
|
1160 | 1161 | if (e.choice.url !== null) { |
|
1161 | 1162 | window.location = e.choice.url |
|
1162 | 1163 | } |
|
1163 | 1164 | }); |
|
1164 | 1165 | toggleExpand = function (el, diffsetEl) { |
|
1165 | 1166 | var el = $(el); |
|
1166 | 1167 | if (el.hasClass('collapsed')) { |
|
1167 | 1168 | $('.filediff-collapse-state.collapse-{0}'.format(diffsetEl)).prop('checked', false); |
|
1168 | 1169 | el.removeClass('collapsed'); |
|
1169 | 1170 | el.html( |
|
1170 | 1171 | '<i class="icon-minus-squared-alt icon-no-margin"></i>' + |
|
1171 | 1172 | _gettext('Collapse all files')); |
|
1172 | 1173 | } |
|
1173 | 1174 | else { |
|
1174 | 1175 | $('.filediff-collapse-state.collapse-{0}'.format(diffsetEl)).prop('checked', true); |
|
1175 | 1176 | el.addClass('collapsed'); |
|
1176 | 1177 | el.html( |
|
1177 | 1178 | '<i class="icon-plus-squared-alt icon-no-margin"></i>' + |
|
1178 | 1179 | _gettext('Expand all files')); |
|
1179 | 1180 | } |
|
1180 | 1181 | updateSticky() |
|
1181 | 1182 | }; |
|
1182 | 1183 | |
|
1183 | 1184 | toggleCommitExpand = function (el) { |
|
1184 | 1185 | var $el = $(el); |
|
1185 | 1186 | var commits = $el.data('toggleCommitsCnt'); |
|
1186 | 1187 | var collapseMsg = _ngettext('Collapse {0} commit', 'Collapse {0} commits', commits).format(commits); |
|
1187 | 1188 | var expandMsg = _ngettext('Expand {0} commit', 'Expand {0} commits', commits).format(commits); |
|
1188 | 1189 | |
|
1189 | 1190 | if ($el.hasClass('collapsed')) { |
|
1190 | 1191 | $('.compare_select').show(); |
|
1191 | 1192 | $('.compare_select_hidden').hide(); |
|
1192 | 1193 | |
|
1193 | 1194 | $el.removeClass('collapsed'); |
|
1194 | 1195 | $el.html( |
|
1195 | 1196 | '<i class="icon-minus-squared-alt icon-no-margin"></i>' + |
|
1196 | 1197 | collapseMsg); |
|
1197 | 1198 | } |
|
1198 | 1199 | else { |
|
1199 | 1200 | $('.compare_select').hide(); |
|
1200 | 1201 | $('.compare_select_hidden').show(); |
|
1201 | 1202 | $el.addClass('collapsed'); |
|
1202 | 1203 | $el.html( |
|
1203 | 1204 | '<i class="icon-plus-squared-alt icon-no-margin"></i>' + |
|
1204 | 1205 | expandMsg); |
|
1205 | 1206 | } |
|
1206 | 1207 | updateSticky(); |
|
1207 | 1208 | }; |
|
1208 | 1209 | |
|
1209 | 1210 | // get stored diff mode and pre-enable it |
|
1210 | 1211 | if (templateContext.session_attrs.wide_diff_mode === "true") { |
|
1211 | 1212 | Rhodecode.comments.toggleWideMode(null); |
|
1212 | 1213 | $('.toggle-wide-diff').addClass('btn-active'); |
|
1213 | 1214 | updateSticky(); |
|
1214 | 1215 | } |
|
1215 | 1216 | }); |
|
1216 | 1217 | </script> |
|
1217 | 1218 | |
|
1218 | 1219 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now