##// END OF EJS Templates
diffs: add button to browse files at current commit
super-admin -
r4839:ad0bb35b default
parent child Browse files
Show More
@@ -1,430 +1,435 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2
2
3 <%inherit file="/base/base.mako"/>
3 <%inherit file="/base/base.mako"/>
4 <%namespace name="base" file="/base/base.mako"/>
4 <%namespace name="base" file="/base/base.mako"/>
5 <%namespace name="diff_block" file="/changeset/diff_block.mako"/>
5 <%namespace name="diff_block" file="/changeset/diff_block.mako"/>
6 <%namespace name="file_base" file="/files/base.mako"/>
6 <%namespace name="file_base" file="/files/base.mako"/>
7 <%namespace name="sidebar" file="/base/sidebar.mako"/>
7 <%namespace name="sidebar" file="/base/sidebar.mako"/>
8
8
9
9
10 <%def name="title()">
10 <%def name="title()">
11 ${_('{} Commit').format(c.repo_name)} - ${h.show_id(c.commit)}
11 ${_('{} Commit').format(c.repo_name)} - ${h.show_id(c.commit)}
12 %if c.rhodecode_name:
12 %if c.rhodecode_name:
13 &middot; ${h.branding(c.rhodecode_name)}
13 &middot; ${h.branding(c.rhodecode_name)}
14 %endif
14 %endif
15 </%def>
15 </%def>
16
16
17 <%def name="menu_bar_nav()">
17 <%def name="menu_bar_nav()">
18 ${self.menu_items(active='repositories')}
18 ${self.menu_items(active='repositories')}
19 </%def>
19 </%def>
20
20
21 <%def name="menu_bar_subnav()">
21 <%def name="menu_bar_subnav()">
22 ${self.repo_menu(active='commits')}
22 ${self.repo_menu(active='commits')}
23 </%def>
23 </%def>
24
24
25 <%def name="main()">
25 <%def name="main()">
26 <script type="text/javascript">
26 <script type="text/javascript">
27 templateContext.commit_data.commit_id = "${c.commit.raw_id}";
27 templateContext.commit_data.commit_id = "${c.commit.raw_id}";
28 </script>
28 </script>
29
29
30 <div class="box">
30 <div class="box">
31
31
32 <div class="summary">
32 <div class="summary">
33
33
34 <div class="fieldset">
34 <div class="fieldset">
35 <div class="left-content">
35 <div class="left-content">
36 <%
36 <%
37 rc_user = h.discover_user(c.commit.author_email)
37 rc_user = h.discover_user(c.commit.author_email)
38 %>
38 %>
39 <div class="left-content-avatar">
39 <div class="left-content-avatar">
40 ${base.gravatar(c.commit.author_email, 30, tooltip=(True if rc_user else False), user=rc_user)}
40 ${base.gravatar(c.commit.author_email, 30, tooltip=(True if rc_user else False), user=rc_user)}
41 </div>
41 </div>
42
42
43 <div class="left-content-message">
43 <div class="left-content-message">
44 <div class="fieldset collapsable-content no-hide" data-toggle="summary-details">
44 <div class="fieldset collapsable-content no-hide" data-toggle="summary-details">
45 <div class="commit truncate-wrap">${h.urlify_commit_message(h.chop_at_smart(c.commit.message, '\n', suffix_if_chopped='...'), c.repo_name)}</div>
45 <div class="commit truncate-wrap">${h.urlify_commit_message(h.chop_at_smart(c.commit.message, '\n', suffix_if_chopped='...'), c.repo_name)}</div>
46 </div>
46 </div>
47
47
48 <div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none">
48 <div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none">
49 <div class="commit">${h.urlify_commit_message(c.commit.message,c.repo_name)}</div>
49 <div class="commit">${h.urlify_commit_message(c.commit.message,c.repo_name)}</div>
50 </div>
50 </div>
51
51
52 <div class="fieldset" data-toggle="summary-details">
52 <div class="fieldset" data-toggle="summary-details">
53 <div class="">
53 <div class="">
54 <table>
54 <table>
55 <tr class="file_author">
55 <tr class="file_author">
56
56
57 <td>
57 <td>
58 <span class="user commit-author">${h.link_to_user(rc_user or c.commit.author)}</span>
58 <span class="user commit-author">${h.link_to_user(rc_user or c.commit.author)}</span>
59 <span class="commit-date">- ${h.age_component(c.commit.date)}</span>
59 <span class="commit-date">- ${h.age_component(c.commit.date)}</span>
60 </td>
60 </td>
61
61
62 <td>
62 <td>
63 ## second cell for consistency with files
63 ## second cell for consistency with files
64 </td>
64 </td>
65 </tr>
65 </tr>
66 </table>
66 </table>
67 </div>
67 </div>
68 </div>
68 </div>
69
69
70 </div>
70 </div>
71 </div>
71 </div>
72
72
73 <div class="right-content">
73 <div class="right-content">
74
74
75 <div data-toggle="summary-details">
75 <div data-toggle="summary-details">
76 <div class="tags tags-main">
76 <div class="tags tags-main">
77 <code><a href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">${h.show_id(c.commit)}</a></code>
77 <code><a href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">${h.show_id(c.commit)}</a></code>
78 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.commit.raw_id}" title="${_('Copy the full commit id')}"></i>
78 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${c.commit.raw_id}" title="${_('Copy the full commit id')}"></i>
79 ${file_base.refs(c.commit)}
79 ${file_base.refs(c.commit)}
80
80
81
81 ## phase
82 ## phase
82 % if hasattr(c.commit, 'phase') and getattr(c.commit, 'phase') != 'public':
83 % if hasattr(c.commit, 'phase') and getattr(c.commit, 'phase') != 'public':
83 <span class="tag phase-${c.commit.phase} tooltip" title="${_('Commit phase')}">
84 <span class="tag phase-${c.commit.phase} tooltip" title="${_('Commit phase')}">
84 <i class="icon-info"></i>${c.commit.phase}
85 <i class="icon-info"></i>${c.commit.phase}
85 </span>
86 </span>
86 % endif
87 % endif
87
88
88 ## obsolete commits
89 ## obsolete commits
89 % if getattr(c.commit, 'obsolete', False):
90 % if getattr(c.commit, 'obsolete', False):
90 <span class="tag obsolete-${c.commit.obsolete} tooltip" title="${_('Evolve State')}">
91 <span class="tag obsolete-${c.commit.obsolete} tooltip" title="${_('Evolve State')}">
91 ${_('obsolete')}
92 ${_('obsolete')}
92 </span>
93 </span>
93 % endif
94 % endif
94
95
95 ## hidden commits
96 ## hidden commits
96 % if getattr(c.commit, 'hidden', False):
97 % if getattr(c.commit, 'hidden', False):
97 <span class="tag hidden-${c.commit.hidden} tooltip" title="${_('Evolve State')}">
98 <span class="tag hidden-${c.commit.hidden} tooltip" title="${_('Evolve State')}">
98 ${_('hidden')}
99 ${_('hidden')}
99 </span>
100 </span>
100 % endif
101 % endif
101 </div>
102 </div>
102
103
103 <span id="parent_link" class="tag tagtag">
104 <span id="parent_link" class="tag tagtag">
104 <a href="#parentCommit" title="${_('Parent Commit')}"><i class="icon-left icon-no-margin"></i>${_('parent')}</a>
105 <a href="#parentCommit" title="${_('Parent Commit')}"><i class="icon-left icon-no-margin"></i>${_('parent')}</a>
105 </span>
106 </span>
106
107
107 <span id="child_link" class="tag tagtag">
108 <span id="child_link" class="tag tagtag">
108 <a href="#childCommit" title="${_('Child Commit')}">${_('child')}<i class="icon-right icon-no-margin"></i></a>
109 <a href="#childCommit" title="${_('Child Commit')}">${_('child')}<i class="icon-right icon-no-margin"></i></a>
109 </span>
110 </span>
111 <span class="tag tooltip" title="${_('Browse files at this commit')}">
112 <i class="icon-code"></i>
113 <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}">${_('Browse files')}</a>
114 </span>
110
115
111 </div>
116 </div>
112
117
113 </div>
118 </div>
114 </div>
119 </div>
115
120
116 <div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none;">
121 <div class="fieldset collapsable-content" data-toggle="summary-details" style="display: none;">
117 <div class="left-label-summary">
122 <div class="left-label-summary">
118 <p>${_('Diff options')}:</p>
123 <p>${_('Diff options')}:</p>
119 <div class="right-label-summary">
124 <div class="right-label-summary">
120 <div class="diff-actions">
125 <div class="diff-actions">
121 <a href="${h.route_path('repo_commit_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
126 <a href="${h.route_path('repo_commit_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
122 ${_('Raw Diff')}
127 ${_('Raw Diff')}
123 </a>
128 </a>
124 |
129 |
125 <a href="${h.route_path('repo_commit_patch',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
130 <a href="${h.route_path('repo_commit_patch',repo_name=c.repo_name,commit_id=c.commit.raw_id)}">
126 ${_('Patch Diff')}
131 ${_('Patch Diff')}
127 </a>
132 </a>
128 |
133 |
129 <a href="${h.route_path('repo_commit_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,_query=dict(diff='download'))}">
134 <a href="${h.route_path('repo_commit_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,_query=dict(diff='download'))}">
130 ${_('Download Diff')}
135 ${_('Download Diff')}
131 </a>
136 </a>
132 </div>
137 </div>
133 </div>
138 </div>
134 </div>
139 </div>
135 </div>
140 </div>
136
141
137 <div class="clear-fix"></div>
142 <div class="clear-fix"></div>
138
143
139 <div class="btn-collapse" data-toggle="summary-details">
144 <div class="btn-collapse" data-toggle="summary-details">
140 ${_('Show More')}
145 ${_('Show More')}
141 </div>
146 </div>
142
147
143 </div>
148 </div>
144
149
145 <div class="cs_files">
150 <div class="cs_files">
146 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
151 <%namespace name="cbdiffs" file="/codeblocks/diffs.mako"/>
147 ${cbdiffs.render_diffset_menu(c.changes[c.commit.raw_id], commit=c.commit)}
152 ${cbdiffs.render_diffset_menu(c.changes[c.commit.raw_id], commit=c.commit)}
148 ${cbdiffs.render_diffset(
153 ${cbdiffs.render_diffset(
149 c.changes[c.commit.raw_id], commit=c.commit, use_comments=True,
154 c.changes[c.commit.raw_id], commit=c.commit, use_comments=True,
150 inline_comments=c.inline_comments,
155 inline_comments=c.inline_comments,
151 show_todos=False)}
156 show_todos=False)}
152 </div>
157 </div>
153
158
154 ## template for inline comment form
159 ## template for inline comment form
155 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
160 <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
156
161
157 ## comments heading with count
162 ## comments heading with count
158 <div class="comments-heading">
163 <div class="comments-heading">
159 <i class="icon-comment"></i>
164 <i class="icon-comment"></i>
160 ${_('General Comments')} ${len(c.comments)}
165 ${_('General Comments')} ${len(c.comments)}
161 </div>
166 </div>
162
167
163 ## render comments
168 ## render comments
164 ${comment.generate_comments(c.comments)}
169 ${comment.generate_comments(c.comments)}
165
170
166 ## main comment form and it status
171 ## main comment form and it status
167 ${comment.comments(h.route_path('repo_commit_comment_create', repo_name=c.repo_name, commit_id=c.commit.raw_id),
172 ${comment.comments(h.route_path('repo_commit_comment_create', repo_name=c.repo_name, commit_id=c.commit.raw_id),
168 h.commit_status(c.rhodecode_db_repo, c.commit.raw_id))}
173 h.commit_status(c.rhodecode_db_repo, c.commit.raw_id))}
169 </div>
174 </div>
170
175
171 ### NAV SIDEBAR
176 ### NAV SIDEBAR
172 <aside class="right-sidebar right-sidebar-expanded" id="commit-nav-sticky" style="display: none">
177 <aside class="right-sidebar right-sidebar-expanded" id="commit-nav-sticky" style="display: none">
173 <div class="sidenav navbar__inner" >
178 <div class="sidenav navbar__inner" >
174 ## TOGGLE
179 ## TOGGLE
175 <div class="sidebar-toggle" onclick="toggleSidebar(); return false">
180 <div class="sidebar-toggle" onclick="toggleSidebar(); return false">
176 <a href="#toggleSidebar" class="grey-link-action">
181 <a href="#toggleSidebar" class="grey-link-action">
177
182
178 </a>
183 </a>
179 </div>
184 </div>
180
185
181 ## CONTENT
186 ## CONTENT
182 <div class="sidebar-content">
187 <div class="sidebar-content">
183
188
184 ## RULES SUMMARY/RULES
189 ## RULES SUMMARY/RULES
185 <div class="sidebar-element clear-both">
190 <div class="sidebar-element clear-both">
186 <% vote_title = _ungettext(
191 <% vote_title = _ungettext(
187 'Status calculated based on votes from {} reviewer',
192 'Status calculated based on votes from {} reviewer',
188 'Status calculated based on votes from {} reviewers', c.reviewers_count).format(c.reviewers_count)
193 'Status calculated based on votes from {} reviewers', c.reviewers_count).format(c.reviewers_count)
189 %>
194 %>
190
195
191 <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${vote_title}">
196 <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${vote_title}">
192 <i class="icon-circle review-status-${c.commit_review_status}"></i>
197 <i class="icon-circle review-status-${c.commit_review_status}"></i>
193 ${c.reviewers_count}
198 ${c.reviewers_count}
194 </div>
199 </div>
195 </div>
200 </div>
196
201
197 ## REVIEWERS
202 ## REVIEWERS
198 <div class="right-sidebar-expanded-state pr-details-title">
203 <div class="right-sidebar-expanded-state pr-details-title">
199 <span class="tooltip sidebar-heading" title="${vote_title}">
204 <span class="tooltip sidebar-heading" title="${vote_title}">
200 <i class="icon-circle review-status-${c.commit_review_status}"></i>
205 <i class="icon-circle review-status-${c.commit_review_status}"></i>
201 ${_('Reviewers')}
206 ${_('Reviewers')}
202 </span>
207 </span>
203 </div>
208 </div>
204
209
205 <div id="reviewers" class="right-sidebar-expanded-state pr-details-content reviewers">
210 <div id="reviewers" class="right-sidebar-expanded-state pr-details-content reviewers">
206
211
207 <table id="review_members" class="group_members">
212 <table id="review_members" class="group_members">
208 ## This content is loaded via JS and ReviewersPanel
213 ## This content is loaded via JS and ReviewersPanel
209 </table>
214 </table>
210
215
211 </div>
216 </div>
212
217
213 ## TODOs
218 ## TODOs
214 <div class="sidebar-element clear-both">
219 <div class="sidebar-element clear-both">
215 <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="TODOs">
220 <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="TODOs">
216 <i class="icon-flag-filled"></i>
221 <i class="icon-flag-filled"></i>
217 <span id="todos-count">${len(c.unresolved_comments)}</span>
222 <span id="todos-count">${len(c.unresolved_comments)}</span>
218 </div>
223 </div>
219
224
220 <div class="right-sidebar-expanded-state pr-details-title">
225 <div class="right-sidebar-expanded-state pr-details-title">
221 ## Only show unresolved, that is only what matters
226 ## Only show unresolved, that is only what matters
222 <span class="sidebar-heading noselect" onclick="refreshTODOs(); return false">
227 <span class="sidebar-heading noselect" onclick="refreshTODOs(); return false">
223 <i class="icon-flag-filled"></i>
228 <i class="icon-flag-filled"></i>
224 TODOs
229 TODOs
225 </span>
230 </span>
226
231
227 % if c.resolved_comments:
232 % if c.resolved_comments:
228 <span class="block-right action_button last-item noselect" onclick="$('.unresolved-todo-text').toggle(); return toggleElement(this, '.resolved-todo');" data-toggle-on="Show resolved" data-toggle-off="Hide resolved">Show resolved</span>
233 <span class="block-right action_button last-item noselect" onclick="$('.unresolved-todo-text').toggle(); return toggleElement(this, '.resolved-todo');" data-toggle-on="Show resolved" data-toggle-off="Hide resolved">Show resolved</span>
229 % else:
234 % else:
230 <span class="block-right last-item noselect">Show resolved</span>
235 <span class="block-right last-item noselect">Show resolved</span>
231 % endif
236 % endif
232
237
233 </div>
238 </div>
234
239
235 <div class="right-sidebar-expanded-state pr-details-content">
240 <div class="right-sidebar-expanded-state pr-details-content">
236 % if c.unresolved_comments + c.resolved_comments:
241 % if c.unresolved_comments + c.resolved_comments:
237 ${sidebar.comments_table(c.unresolved_comments + c.resolved_comments, len(c.unresolved_comments), todo_comments=True, is_pr=False)}
242 ${sidebar.comments_table(c.unresolved_comments + c.resolved_comments, len(c.unresolved_comments), todo_comments=True, is_pr=False)}
238 % else:
243 % else:
239 <table>
244 <table>
240 <tr>
245 <tr>
241 <td>
246 <td>
242 ${_('No TODOs yet')}
247 ${_('No TODOs yet')}
243 </td>
248 </td>
244 </tr>
249 </tr>
245 </table>
250 </table>
246 % endif
251 % endif
247 </div>
252 </div>
248 </div>
253 </div>
249
254
250 ## COMMENTS
255 ## COMMENTS
251 <div class="sidebar-element clear-both">
256 <div class="sidebar-element clear-both">
252 <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${_('Comments')}">
257 <div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${_('Comments')}">
253 <i class="icon-comment" style="color: #949494"></i>
258 <i class="icon-comment" style="color: #949494"></i>
254 <span id="comments-count">${len(c.inline_comments_flat+c.comments)}</span>
259 <span id="comments-count">${len(c.inline_comments_flat+c.comments)}</span>
255 <span class="display-none" id="general-comments-count">${len(c.comments)}</span>
260 <span class="display-none" id="general-comments-count">${len(c.comments)}</span>
256 <span class="display-none" id="inline-comments-count">${len(c.inline_comments_flat)}</span>
261 <span class="display-none" id="inline-comments-count">${len(c.inline_comments_flat)}</span>
257 </div>
262 </div>
258
263
259 <div class="right-sidebar-expanded-state pr-details-title">
264 <div class="right-sidebar-expanded-state pr-details-title">
260 <span class="sidebar-heading noselect" onclick="refreshComments(); return false">
265 <span class="sidebar-heading noselect" onclick="refreshComments(); return false">
261 <i class="icon-comment" style="color: #949494"></i>
266 <i class="icon-comment" style="color: #949494"></i>
262 ${_('Comments')}
267 ${_('Comments')}
263 </span>
268 </span>
264
269
265 </div>
270 </div>
266
271
267 <div class="right-sidebar-expanded-state pr-details-content">
272 <div class="right-sidebar-expanded-state pr-details-content">
268 % if c.inline_comments_flat + c.comments:
273 % if c.inline_comments_flat + c.comments:
269 ${sidebar.comments_table(c.inline_comments_flat + c.comments, len(c.inline_comments_flat+c.comments), is_pr=False)}
274 ${sidebar.comments_table(c.inline_comments_flat + c.comments, len(c.inline_comments_flat+c.comments), is_pr=False)}
270 % else:
275 % else:
271 <table>
276 <table>
272 <tr>
277 <tr>
273 <td>
278 <td>
274 ${_('No Comments yet')}
279 ${_('No Comments yet')}
275 </td>
280 </td>
276 </tr>
281 </tr>
277 </table>
282 </table>
278 % endif
283 % endif
279 </div>
284 </div>
280
285
281 </div>
286 </div>
282
287
283 </div>
288 </div>
284
289
285 </div>
290 </div>
286 </aside>
291 </aside>
287
292
288 ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS
293 ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS
289 <script type="text/javascript">
294 <script type="text/javascript">
290 window.setReviewersData = ${c.commit_set_reviewers_data_json | n};
295 window.setReviewersData = ${c.commit_set_reviewers_data_json | n};
291
296
292 $(document).ready(function () {
297 $(document).ready(function () {
293 var boxmax = parseInt($('#trimmed_message_box').css('max-height'), 10);
298 var boxmax = parseInt($('#trimmed_message_box').css('max-height'), 10);
294
299
295 if ($('#trimmed_message_box').height() === boxmax) {
300 if ($('#trimmed_message_box').height() === boxmax) {
296 $('#message_expand').show();
301 $('#message_expand').show();
297 }
302 }
298
303
299 $('#message_expand').on('click', function (e) {
304 $('#message_expand').on('click', function (e) {
300 $('#trimmed_message_box').css('max-height', 'none');
305 $('#trimmed_message_box').css('max-height', 'none');
301 $(this).hide();
306 $(this).hide();
302 });
307 });
303
308
304 $('.show-inline-comments').on('click', function (e) {
309 $('.show-inline-comments').on('click', function (e) {
305 var boxid = $(this).attr('data-comment-id');
310 var boxid = $(this).attr('data-comment-id');
306 var button = $(this);
311 var button = $(this);
307
312
308 if (button.hasClass("comments-visible")) {
313 if (button.hasClass("comments-visible")) {
309 $('#{0} .inline-comments'.format(boxid)).each(function (index) {
314 $('#{0} .inline-comments'.format(boxid)).each(function (index) {
310 $(this).hide();
315 $(this).hide();
311 });
316 });
312 button.removeClass("comments-visible");
317 button.removeClass("comments-visible");
313 } else {
318 } else {
314 $('#{0} .inline-comments'.format(boxid)).each(function (index) {
319 $('#{0} .inline-comments'.format(boxid)).each(function (index) {
315 $(this).show();
320 $(this).show();
316 });
321 });
317 button.addClass("comments-visible");
322 button.addClass("comments-visible");
318 }
323 }
319 });
324 });
320
325
321 // next links
326 // next links
322 $('#child_link').on('click', function (e) {
327 $('#child_link').on('click', function (e) {
323 // fetch via ajax what is going to be the next link, if we have
328 // fetch via ajax what is going to be the next link, if we have
324 // >1 links show them to user to choose
329 // >1 links show them to user to choose
325 if (!$('#child_link').hasClass('disabled')) {
330 if (!$('#child_link').hasClass('disabled')) {
326 $.ajax({
331 $.ajax({
327 url: '${h.route_path('repo_commit_children',repo_name=c.repo_name, commit_id=c.commit.raw_id)}',
332 url: '${h.route_path('repo_commit_children',repo_name=c.repo_name, commit_id=c.commit.raw_id)}',
328 success: function (data) {
333 success: function (data) {
329 if (data.results.length === 0) {
334 if (data.results.length === 0) {
330 $('#child_link').html("${_('No Child Commits')}").addClass('disabled');
335 $('#child_link').html("${_('No Child Commits')}").addClass('disabled');
331 }
336 }
332 if (data.results.length === 1) {
337 if (data.results.length === 1) {
333 var commit = data.results[0];
338 var commit = data.results[0];
334 window.location = pyroutes.url('repo_commit', {
339 window.location = pyroutes.url('repo_commit', {
335 'repo_name': '${c.repo_name}',
340 'repo_name': '${c.repo_name}',
336 'commit_id': commit.raw_id
341 'commit_id': commit.raw_id
337 });
342 });
338 } else if (data.results.length === 2) {
343 } else if (data.results.length === 2) {
339 $('#child_link').addClass('disabled');
344 $('#child_link').addClass('disabled');
340 $('#child_link').addClass('double');
345 $('#child_link').addClass('double');
341
346
342 var _html = '';
347 var _html = '';
343 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a> '
348 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a> '
344 .replace('__branch__', data.results[0].branch)
349 .replace('__branch__', data.results[0].branch)
345 .replace('__rev__', 'r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0, 6)))
350 .replace('__rev__', 'r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0, 6)))
346 .replace('__title__', data.results[0].message)
351 .replace('__title__', data.results[0].message)
347 .replace('__url__', pyroutes.url('repo_commit', {
352 .replace('__url__', pyroutes.url('repo_commit', {
348 'repo_name': '${c.repo_name}',
353 'repo_name': '${c.repo_name}',
349 'commit_id': data.results[0].raw_id
354 'commit_id': data.results[0].raw_id
350 }));
355 }));
351 _html += ' | ';
356 _html += ' | ';
352 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a> '
357 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a> '
353 .replace('__branch__', data.results[1].branch)
358 .replace('__branch__', data.results[1].branch)
354 .replace('__rev__', 'r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0, 6)))
359 .replace('__rev__', 'r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0, 6)))
355 .replace('__title__', data.results[1].message)
360 .replace('__title__', data.results[1].message)
356 .replace('__url__', pyroutes.url('repo_commit', {
361 .replace('__url__', pyroutes.url('repo_commit', {
357 'repo_name': '${c.repo_name}',
362 'repo_name': '${c.repo_name}',
358 'commit_id': data.results[1].raw_id
363 'commit_id': data.results[1].raw_id
359 }));
364 }));
360 $('#child_link').html(_html);
365 $('#child_link').html(_html);
361 }
366 }
362 }
367 }
363 });
368 });
364 e.preventDefault();
369 e.preventDefault();
365 }
370 }
366 });
371 });
367
372
368 // prev links
373 // prev links
369 $('#parent_link').on('click', function (e) {
374 $('#parent_link').on('click', function (e) {
370 // fetch via ajax what is going to be the next link, if we have
375 // fetch via ajax what is going to be the next link, if we have
371 // >1 links show them to user to choose
376 // >1 links show them to user to choose
372 if (!$('#parent_link').hasClass('disabled')) {
377 if (!$('#parent_link').hasClass('disabled')) {
373 $.ajax({
378 $.ajax({
374 url: '${h.route_path("repo_commit_parents",repo_name=c.repo_name, commit_id=c.commit.raw_id)}',
379 url: '${h.route_path("repo_commit_parents",repo_name=c.repo_name, commit_id=c.commit.raw_id)}',
375 success: function (data) {
380 success: function (data) {
376 if (data.results.length === 0) {
381 if (data.results.length === 0) {
377 $('#parent_link').html('${_('No Parent Commits')}').addClass('disabled');
382 $('#parent_link').html('${_('No Parent Commits')}').addClass('disabled');
378 }
383 }
379 if (data.results.length === 1) {
384 if (data.results.length === 1) {
380 var commit = data.results[0];
385 var commit = data.results[0];
381 window.location = pyroutes.url('repo_commit', {
386 window.location = pyroutes.url('repo_commit', {
382 'repo_name': '${c.repo_name}',
387 'repo_name': '${c.repo_name}',
383 'commit_id': commit.raw_id
388 'commit_id': commit.raw_id
384 });
389 });
385 } else if (data.results.length === 2) {
390 } else if (data.results.length === 2) {
386 $('#parent_link').addClass('disabled');
391 $('#parent_link').addClass('disabled');
387 $('#parent_link').addClass('double');
392 $('#parent_link').addClass('double');
388
393
389 var _html = '';
394 var _html = '';
390 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a>'
395 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a>'
391 .replace('__branch__', data.results[0].branch)
396 .replace('__branch__', data.results[0].branch)
392 .replace('__rev__', 'r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0, 6)))
397 .replace('__rev__', 'r{0}:{1}'.format(data.results[0].revision, data.results[0].raw_id.substr(0, 6)))
393 .replace('__title__', data.results[0].message)
398 .replace('__title__', data.results[0].message)
394 .replace('__url__', pyroutes.url('repo_commit', {
399 .replace('__url__', pyroutes.url('repo_commit', {
395 'repo_name': '${c.repo_name}',
400 'repo_name': '${c.repo_name}',
396 'commit_id': data.results[0].raw_id
401 'commit_id': data.results[0].raw_id
397 }));
402 }));
398 _html += ' | ';
403 _html += ' | ';
399 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a>'
404 _html += '<a title="__title__" href="__url__"><span class="tag branchtag"><i class="icon-code-fork"></i>__branch__</span> __rev__</a>'
400 .replace('__branch__', data.results[1].branch)
405 .replace('__branch__', data.results[1].branch)
401 .replace('__rev__', 'r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0, 6)))
406 .replace('__rev__', 'r{0}:{1}'.format(data.results[1].revision, data.results[1].raw_id.substr(0, 6)))
402 .replace('__title__', data.results[1].message)
407 .replace('__title__', data.results[1].message)
403 .replace('__url__', pyroutes.url('repo_commit', {
408 .replace('__url__', pyroutes.url('repo_commit', {
404 'repo_name': '${c.repo_name}',
409 'repo_name': '${c.repo_name}',
405 'commit_id': data.results[1].raw_id
410 'commit_id': data.results[1].raw_id
406 }));
411 }));
407 $('#parent_link').html(_html);
412 $('#parent_link').html(_html);
408 }
413 }
409 }
414 }
410 });
415 });
411 e.preventDefault();
416 e.preventDefault();
412 }
417 }
413 });
418 });
414
419
415 // browse tree @ revision
420 // browse tree @ revision
416 $('#files_link').on('click', function (e) {
421 $('#files_link').on('click', function (e) {
417 window.location = '${h.route_path('repo_files:default_path',repo_name=c.repo_name, commit_id=c.commit.raw_id)}';
422 window.location = '${h.route_path('repo_files:default_path',repo_name=c.repo_name, commit_id=c.commit.raw_id)}';
418 e.preventDefault();
423 e.preventDefault();
419 });
424 });
420
425
421 reviewersController = new ReviewersController();
426 reviewersController = new ReviewersController();
422 ReviewersPanel.init(reviewersController, null, setReviewersData);
427 ReviewersPanel.init(reviewersController, null, setReviewersData);
423
428
424 var channel = '${c.commit_broadcast_channel}';
429 var channel = '${c.commit_broadcast_channel}';
425 new ReviewerPresenceController(channel)
430 new ReviewerPresenceController(channel)
426
431
427 })
432 })
428 </script>
433 </script>
429
434
430 </%def>
435 </%def>
General Comments 0
You need to be logged in to leave comments. Login now