##// END OF EJS Templates
commits: use short-id for range selector
marcink -
r3774:2d2d2139 new-ui
parent child Browse files
Show More
@@ -1,329 +1,326 b''
1 1 ## -*- coding: utf-8 -*-
2 2
3 3 <%inherit file="/base/base.mako"/>
4 4
5 5 <%def name="title()">
6 6 ${_('%s Changelog') % c.repo_name}
7 7 %if c.changelog_for_path:
8 8 /${c.changelog_for_path}
9 9 %endif
10 10 %if c.rhodecode_name:
11 11 &middot; ${h.branding(c.rhodecode_name)}
12 12 %endif
13 13 </%def>
14 14
15 15 <%def name="breadcrumbs_links()">
16 16 %if c.changelog_for_path:
17 17 /${c.changelog_for_path}
18 18 %endif
19 19 </%def>
20 20
21 21 <%def name="menu_bar_nav()">
22 22 ${self.menu_items(active='repositories')}
23 23 </%def>
24 24
25 25 <%def name="menu_bar_subnav()">
26 26 ${self.repo_menu(active='commits')}
27 27 </%def>
28 28
29 29 <%def name="main()">
30 30
31 31 <div class="box">
32 32
33 33 <div class="title">
34 34 <div id="filter_changelog">
35 35 ${h.hidden('branch_filter')}
36 36 %if c.selected_name:
37 37 <div class="btn btn-default" id="clear_filter" >
38 38 ${_('Clear filter')}
39 39 </div>
40 40 %endif
41 41 </div>
42 42 <div class="pull-left obsolete-toggle">
43 43 % if h.is_hg(c.rhodecode_repo):
44 44 % if c.show_hidden:
45 45 <a class="action-link" href="${h.current_route_path(request, evolve=0)}">${_('Hide obsolete/hidden')}</a>
46 46 % else:
47 47 <a class="action-link" href="${h.current_route_path(request, evolve=1)}">${_('Show obsolete/hidden')}</a>
48 48 % endif
49 49 % else:
50 50 <span class="action-link disabled">${_('Show hidden')}</span>
51 51 % endif
52 52 </div>
53 53 <ul class="links">
54 54 <li>
55 55
56 56 %if c.rhodecode_db_repo.fork:
57 57 <span>
58 58 <a id="compare_fork_button"
59 59 title="${h.tooltip(_('Compare fork with %s' % c.rhodecode_db_repo.fork.repo_name))}"
60 60 class="btn btn-small"
61 61 href="${h.route_path('repo_compare',
62 62 repo_name=c.rhodecode_db_repo.fork.repo_name,
63 63 source_ref_type=c.rhodecode_db_repo.landing_rev[0],
64 64 source_ref=c.rhodecode_db_repo.landing_rev[1],
65 65 target_ref_type='branch' if request.GET.get('branch') else c.rhodecode_db_repo.landing_rev[0],
66 66 target_ref=request.GET.get('branch') or c.rhodecode_db_repo.landing_rev[1],
67 67 _query=dict(merge=1, target_repo=c.repo_name))}"
68 68 >
69 69 ${_('Compare fork with Parent (%s)' % c.rhodecode_db_repo.fork.repo_name)}
70 70 </a>
71 71 </span>
72 72 %endif
73 73
74 74 ## pr open link
75 75 %if h.is_hg(c.rhodecode_repo) or h.is_git(c.rhodecode_repo):
76 76 <span>
77 77 <a id="open_new_pull_request" class="btn btn-small btn-success" href="${h.route_path('pullrequest_new',repo_name=c.repo_name)}">
78 78 ${_('Open new pull request')}
79 79 </a>
80 80 </span>
81 81 %endif
82 82
83 83 </li>
84 84 </ul>
85 85 </div>
86 86
87 87 % if c.pagination:
88 88 <script type="text/javascript" src="${h.asset('js/src/plugins/jquery.commits-graph.js')}"></script>
89 89
90 90 <div class="graph-header">
91 91 ${self.breadcrumbs('breadcrumbs_light')}
92 92 </div>
93 93
94 94 <div id="graph">
95 95 <div class="graph-col-wrapper">
96 96 <div id="graph_nodes">
97 97 <div id="graph_canvas"></div>
98 98 </div>
99 99 <div id="graph_content" class="graph_full_width">
100 100
101 101 <div class="table">
102 102 <table id="changesets" class="rctable">
103 103 <tr>
104 104 ## checkbox
105 105 <th colspan="4">
106 106 ## clear selection
107 107 <div title="${_('Clear selection')}" class="btn btn-sm" id="rev_range_clear" style="display:none">
108 108 <i class="icon-cancel-circled2"></i>
109 109 </div>
110 110 <div class="btn btn-sm disabled" disabled="disabled" id="rev_range_more" style="display:none;">${_('Select second commit')}</div>
111 111 <a href="#" class="btn btn-success btn-sm" id="rev_range_container" style="display:none;"></a>
112 112 </th>
113 113
114 114 ## commit message expand arrow
115 115 <th></th>
116 116 <th>${_('Commit Message')}</th>
117 117
118 118 <th>${_('Age')}</th>
119 119 <th>${_('Author')}</th>
120 120
121 121 <th>${_('Refs')}</th>
122 122 ## comments
123 123 <th></th>
124 124 </tr>
125 125
126 126 <tbody class="commits-range">
127 127 <%include file='changelog_elements.mako'/>
128 128 </tbody>
129 129 </table>
130 130 </div>
131 131 </div>
132 132 <div class="pagination-wh pagination-left">
133 133 ${c.pagination.pager('$link_previous ~2~ $link_next')}
134 134 </div>
135 135 <div id="commit-counter" data-total=${c.total_cs} class="pull-right">
136 136 ${_ungettext('showing %d out of %d commit', 'showing %d out of %d commits', c.showing_commits) % (c.showing_commits, c.total_cs)}
137 137 </div>
138 138 </div>
139 139
140 140 <script type="text/javascript">
141 141 var cache = {};
142 142 $(function(){
143 143
144 144 // Create links to commit ranges when range checkboxes are selected
145 145 var $commitCheckboxes = $('.commit-range');
146 146 // cache elements
147 147 var $commitRangeMore = $('#rev_range_more');
148 148 var $commitRangeContainer = $('#rev_range_container');
149 149 var $commitRangeClear = $('#rev_range_clear');
150 150
151 151 var checkboxRangeSelector = function(e){
152 152 var selectedCheckboxes = [];
153 153 for (pos in $commitCheckboxes){
154 154 if($commitCheckboxes[pos].checked){
155 155 selectedCheckboxes.push($commitCheckboxes[pos]);
156 156 }
157 157 }
158 158 var open_new_pull_request = $('#open_new_pull_request');
159 159
160 160 if (open_new_pull_request) {
161 161 var selected_changes = selectedCheckboxes.length;
162 162 open_new_pull_request.hide();
163 163 if (selected_changes == 1) {
164 164 open_new_pull_request.html(_gettext('Open new pull request for selected commit'));
165 165 } else {
166 166 open_new_pull_request.html(_gettext('Open new pull request'));
167 167 }
168 168 open_new_pull_request.show();
169 169 }
170 170
171 171 if (selectedCheckboxes.length > 0) {
172 172 $('#compare_fork_button').hide();
173 173 var commitStart = $(selectedCheckboxes[selectedCheckboxes.length-1]).data();
174 174
175 175 var revStart = commitStart.commitId;
176 176
177 177 var commitEnd = $(selectedCheckboxes[0]).data();
178 178 var revEnd = commitEnd.commitId;
179 179
180 var lbl_start = 'r{0}:{1}'.format(commitStart.commitIdx, commitStart.commitId.substr(0,6));
181 var lbl_end = 'r{0}:{1}'.format(commitEnd.commitIdx, commitEnd.commitId.substr(0,6));
182
183 var lbl_start = '{0}'.format(commitStart.commitId.substr(0,6));
184 var lbl_end = '{0}'.format(commitEnd.commitId.substr(0,6));
180 var lbl_start = '{0}'.format(commitStart.commitIdx, commitStart.shortId);
181 var lbl_end = '{0}'.format(commitEnd.commitIdx, commitEnd.shortId);
185 182
186 183 var url = pyroutes.url('repo_commit', {'repo_name': '${c.repo_name}', 'commit_id': revStart+'...'+revEnd});
187 184 var link = _gettext('Show commit range {0} ... {1}').format(lbl_start, lbl_end);
188 185
189 186 if (selectedCheckboxes.length > 1) {
190 187 $commitRangeClear.show();
191 188 $commitRangeMore.hide();
192 189
193 190 $commitRangeContainer
194 191 .attr('href',url)
195 192 .html(link)
196 193 .show();
197 194
198 195
199 196 } else {
200 197 $commitRangeContainer.hide();
201 198 $commitRangeClear.show();
202 199 $commitRangeMore.show();
203 200 }
204 201
205 202 // pull-request link
206 203 if (selectedCheckboxes.length == 1){
207 204 var _url = pyroutes.url('pullrequest_new', {'repo_name': '${c.repo_name}', 'commit': revEnd});
208 205 open_new_pull_request.attr('href', _url);
209 206 } else {
210 207 var _url = pyroutes.url('pullrequest_new', {'repo_name': '${c.repo_name}'});
211 208 open_new_pull_request.attr('href', _url);
212 209 }
213 210
214 211 } else {
215 212 $commitRangeContainer.hide();
216 213 $commitRangeClear.hide();
217 214 $commitRangeMore.hide();
218 215
219 216 %if c.branch_name:
220 217 var _url = pyroutes.url('pullrequest_new', {'repo_name': '${c.repo_name}', 'branch':'${c.branch_name}'});
221 218 open_new_pull_request.attr('href', _url);
222 219 %else:
223 220 var _url = pyroutes.url('pullrequest_new', {'repo_name': '${c.repo_name}'});
224 221 open_new_pull_request.attr('href', _url);
225 222 %endif
226 223 $('#compare_fork_button').show();
227 224 }
228 225 };
229 226
230 227 $commitCheckboxes.on('click', checkboxRangeSelector);
231 228
232 229 $commitRangeClear.on('click',function(e) {
233 230 $commitCheckboxes.attr('checked', false);
234 231 checkboxRangeSelector();
235 232 e.preventDefault();
236 233 });
237 234
238 235 // make sure the buttons are consistent when navigate back and forth
239 236 checkboxRangeSelector();
240 237
241 238 var msgs = $('.message');
242 239 // get first element height
243 240 var el = $('#graph_content .container')[0];
244 241 var row_h = el.clientHeight;
245 242 for (var i=0; i < msgs.length; i++) {
246 243 var m = msgs[i];
247 244
248 245 var h = m.clientHeight;
249 246 var pad = $(m).css('padding');
250 247 if (h > row_h) {
251 248 var offset = row_h - (h+12);
252 249 $(m.nextElementSibling).css('display','block');
253 250 $(m.nextElementSibling).css('margin-top',offset+'px');
254 251 }
255 252 }
256 253
257 254 $("#clear_filter").on("click", function() {
258 255 var filter = {'repo_name': '${c.repo_name}'};
259 256 window.location = pyroutes.url('repo_commits', filter);
260 257 });
261 258
262 259 $("#branch_filter").select2({
263 260 'dropdownAutoWidth': true,
264 261 'width': 'resolve',
265 262 'placeholder': "${c.selected_name or _('Branch filter')}",
266 263 containerCssClass: "drop-menu",
267 264 dropdownCssClass: "drop-menu-dropdown",
268 265 query: function(query){
269 266 var key = 'cache';
270 267 var cached = cache[key] ;
271 268 if(cached) {
272 269 var data = {results: []};
273 270 //filter results
274 271 $.each(cached.results, function(){
275 272 var section = this.text;
276 273 var children = [];
277 274 $.each(this.children, function(){
278 275 if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
279 276 children.push({'id': this.id, 'text': this.text, 'type': this.type})
280 277 }
281 278 });
282 279 data.results.push({'text': section, 'children': children});
283 280 query.callback({results: data.results});
284 281 });
285 282 }else{
286 283 $.ajax({
287 284 url: pyroutes.url('repo_refs_changelog_data', {'repo_name': '${c.repo_name}'}),
288 285 data: {},
289 286 dataType: 'json',
290 287 type: 'GET',
291 288 success: function(data) {
292 289 cache[key] = data;
293 290 query.callback({results: data.results});
294 291 }
295 292 })
296 293 }
297 294 }
298 295 });
299 296 $('#branch_filter').on('change', function(e){
300 297 var data = $('#branch_filter').select2('data');
301 298 //type: branch_closed
302 299 var selected = data.text;
303 300 var filter = {'repo_name': '${c.repo_name}'};
304 301 if(data.type == 'branch' || data.type == 'branch_closed'){
305 302 filter["branch"] = selected;
306 303 if (data.type == 'branch_closed') {
307 304 filter["evolve"] = '1';
308 305 }
309 306 }
310 307 else if (data.type == 'book'){
311 308 filter["bookmark"] = selected;
312 309 }
313 310 window.location = pyroutes.url('repo_commits', filter);
314 311 });
315 312
316 313 commitsController = new CommitsController();
317 314 % if not c.changelog_for_path:
318 315 commitsController.reloadGraph();
319 316 % endif
320 317
321 318 });
322 319
323 320 </script>
324 321 </div>
325 322 % else:
326 323 ${_('There are no changes yet')}
327 324 % endif
328 325 </div>
329 326 </%def>
@@ -1,159 +1,159 b''
1 1 ## small box that displays changed/added/removed details fetched by AJAX
2 2 <%namespace name="base" file="/base/base.mako"/>
3 3
4 4 % if c.prev_page:
5 5 <tr>
6 6 <td colspan="10" class="load-more-commits">
7 7 <a class="prev-commits" href="#loadPrevCommits" onclick="commitsController.loadPrev(this, ${c.prev_page}, '${c.branch_name}', '${c.commit_id}', '${c.f_path}');return false">
8 8 ${_('load previous')}
9 9 </a>
10 10 </td>
11 11 </tr>
12 12 % endif
13 13
14 14 ## to speed up lookups cache some functions before the loop
15 15 <%
16 16 active_patterns = h.get_active_pattern_entries(c.repo_name)
17 17 urlify_commit_message = h.partial(h.urlify_commit_message, active_pattern_entries=active_patterns)
18 18 %>
19 19
20 20 % for cnt,commit in enumerate(c.pagination):
21 21 <tr id="sha_${commit.raw_id}" class="changelogRow container ${'tablerow%s' % (cnt%2)}">
22 22
23 23 <td class="td-checkbox">
24 ${h.checkbox(commit.raw_id,class_="commit-range", **{'data-commit-idx':commit.idx, 'data-commit-id': commit.raw_id})}
24 ${h.checkbox(commit.raw_id,class_="commit-range", **{'data-commit-idx':commit.idx, 'data-commit-id': commit.raw_id, 'data-short-id': commit.short_id})}
25 25 </td>
26 26 ##
27 27 <td class="td-graphbox">
28 28
29 29 </td>
30 30
31 31 <td class="td-status">
32 32 %if c.statuses.get(commit.raw_id):
33 33 <div class="changeset-status-ico">
34 34 %if c.statuses.get(commit.raw_id)[2]:
35 35 <a class="tooltip" title="${_('Commit status: %s\nClick to open associated pull request #%s') % (h.commit_status_lbl(c.statuses.get(commit.raw_id)[0]), c.statuses.get(commit.raw_id)[2])}" href="${h.route_path('pullrequest_show',repo_name=c.statuses.get(commit.raw_id)[3],pull_request_id=c.statuses.get(commit.raw_id)[2])}">
36 36 <div class="${'flag_status {}'.format(c.statuses.get(commit.raw_id)[0])}"></div>
37 37 </a>
38 38 %else:
39 39 <a class="tooltip" title="${_('Commit status: {}').format(h.commit_status_lbl(c.statuses.get(commit.raw_id)[0]))}" href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=commit.raw_id,_anchor='comment-%s' % c.comments[commit.raw_id][0].comment_id)}">
40 40 <div class="${'flag_status {}'.format(c.statuses.get(commit.raw_id)[0])}"></div>
41 41 </a>
42 42 %endif
43 43 </div>
44 44 %else:
45 45 <div class="tooltip flag_status not_reviewed" title="${_('Commit status: Not Reviewed')}"></div>
46 46 %endif
47 47 </td>
48 48
49 49 <td class="td-hash">
50 50 <code>
51 51
52 52 <a href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=commit.raw_id)}">
53 53 <span class="${'commit_hash obsolete' if getattr(commit, 'obsolete', None) else 'commit_hash'}">${h.show_id(commit)}</span>
54 54 </a>
55 55
56 56 <i class="tooltip icon-clipboard clipboard-action" data-clipboard-text="${commit.raw_id}" title="${_('Copy the full commit id')}"></i>
57 57
58 58 ## COMMIT PHASES
59 59
60 60 ## Draft
61 61 % if hasattr(commit, 'phase'):
62 62 % if commit.phase != 'public':
63 63 <span class="tag phase-${commit.phase} tooltip" title="${_('{} commit phase').format(commit.phase)}">${commit.phase[0].upper()}</span>
64 64 % endif
65 65 % endif
66 66
67 67 ## obsolete commits
68 68 % if hasattr(commit, 'obsolete') and commit.obsolete:
69 69 <span class="tag obsolete-${commit.obsolete} tooltip" title="${_('Obsolete Evolve State')}">O</span>
70 70 % endif
71 71
72 72 ## hidden commits
73 73 % if hasattr(commit, 'hidden') and commit.hidden:
74 74 <span class="tag obsolete-${commit.hidden} tooltip" title="${_('Hidden Evolve State')}">H</span>
75 75 % endif
76 76
77 77 </code>
78 78 </td>
79 79
80 80 <td class="td-message expand_commit" data-commit-id="${commit.raw_id}" title="${_('Expand commit message')}" onclick="commitsController.expandCommit(this, true); return false">
81 81 <i class="icon-expand-linked"></i>&nbsp;
82 82 </td>
83 83 <td class="td-description mid">
84 84 <div class="log-container truncate-wrap">
85 85 <div class="message truncate" id="c-${commit.raw_id}" data-message-raw="${commit.message}">${urlify_commit_message(commit.message, c.repo_name)}</div>
86 86 </div>
87 87 </td>
88 88
89 89 <td class="td-time">
90 90 ${h.age_component(commit.date)}
91 91 </td>
92 92 <td class="td-user">
93 93 ${base.gravatar_with_user(commit.author)}
94 94 </td>
95 95
96 96 <td class="td-tags tags-col">
97 97 <div id="t-${commit.raw_id}">
98 98
99 99 ## merge
100 100 %if commit.merge:
101 101 <span class="tag mergetag">
102 102 <i class="icon-merge"></i>${_('merge')}
103 103 </span>
104 104 %endif
105 105
106 106 ## branch
107 107 %if commit.branch:
108 108 <span class="tag branchtag" title="${h.tooltip(_('Branch %s') % commit.branch)}">
109 109 <a href="${h.route_path('repo_commits',repo_name=c.repo_name,_query=dict(branch=commit.branch))}"><i class="icon-code-fork"></i>${h.shorter(commit.branch)}</a>
110 110 </span>
111 111 %endif
112 112
113 113 ## bookmarks
114 114 %if h.is_hg(c.rhodecode_repo):
115 115 %for book in commit.bookmarks:
116 116 <span class="tag booktag" title="${h.tooltip(_('Bookmark %s') % book)}">
117 117 <a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id, _query=dict(at=book))}"><i class="icon-bookmark"></i>${h.shorter(book)}</a>
118 118 </span>
119 119 %endfor
120 120 %endif
121 121
122 122 ## tags
123 123 %for tag in commit.tags:
124 124 <span class="tag tagtag" title="${h.tooltip(_('Tag %s') % tag)}">
125 125 <a href="${h.route_path('repo_files:default_path',repo_name=c.repo_name,commit_id=commit.raw_id, _query=dict(at=tag))}"><i class="icon-tag"></i>${h.shorter(tag)}</a>
126 126 </span>
127 127 %endfor
128 128
129 129 </div>
130 130 </td>
131 131
132 132 <td class="td-comments comments-col">
133 133 <% cs_comments = c.comments.get(commit.raw_id,[]) %>
134 134 % if cs_comments:
135 135 <a title="${_('Commit has comments')}" href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=commit.raw_id,_anchor='comment-%s' % cs_comments[0].comment_id)}">
136 136 <i class="icon-comment"></i> ${len(cs_comments)}
137 137 </a>
138 138 % else:
139 139 <i class="icon-comment"></i> ${len(cs_comments)}
140 140 % endif
141 141 </td>
142 142
143 143 </tr>
144 144 % endfor
145 145
146 146 % if c.next_page:
147 147 <tr>
148 148 <td colspan="10" class="load-more-commits">
149 149 <a class="next-commits" href="#loadNextCommits" onclick="commitsController.loadNext(this, ${c.next_page}, '${c.branch_name}', '${c.commit_id}', '${c.f_path}');return false">
150 150 ${_('load next')}
151 151 </a>
152 152 </td>
153 153 </tr>
154 154 % endif
155 155 <tr class="chunk-graph-data" style="display:none"
156 156 data-graph='${c.graph_data|n}'
157 157 data-node='${c.prev_page}:${c.next_page}'
158 158 data-commits='${c.graph_commits|n}'>
159 159 </tr> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now