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