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