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