##// END OF EJS Templates
ui: fixed pr count on repo settings
marcink -
r3569:9cb54b7f new-ui
parent child Browse files
Show More
@@ -1,920 +1,923 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="root.mako"/>
3 3
4 4 <%include file="/ejs_templates/templates.html"/>
5 5
6 6 <div class="outerwrapper">
7 7 <!-- HEADER -->
8 8 <div class="header">
9 9 <div id="header-inner" class="wrapper">
10 10 <div id="logo">
11 11 <div class="logo-wrapper">
12 12 <a href="${h.route_path('home')}"><img src="${h.asset('images/rhodecode-logo-white-60x60.png')}" alt="RhodeCode"/></a>
13 13 </div>
14 14 % if c.rhodecode_name:
15 15 <div class="branding">
16 16 <a href="${h.route_path('home')}">${h.branding(c.rhodecode_name)}</a>
17 17 </div>
18 18 % endif
19 19 </div>
20 20 <!-- MENU BAR NAV -->
21 21 ${self.menu_bar_nav()}
22 22 <!-- END MENU BAR NAV -->
23 23 </div>
24 24 </div>
25 25 ${self.menu_bar_subnav()}
26 26 <!-- END HEADER -->
27 27
28 28 <!-- CONTENT -->
29 29 <div id="content" class="wrapper">
30 30
31 31 <rhodecode-toast id="notifications"></rhodecode-toast>
32 32
33 33 <div class="main">
34 34 ${next.main()}
35 35 </div>
36 36 </div>
37 37 <!-- END CONTENT -->
38 38
39 39 </div>
40 40 <!-- FOOTER -->
41 41 <div id="footer">
42 42 <div id="footer-inner" class="title wrapper">
43 43 <div>
44 44 <p class="footer-link-right">
45 45 % if c.visual.show_version:
46 46 RhodeCode Enterprise ${c.rhodecode_version} ${c.rhodecode_edition}
47 47 % endif
48 48 &copy; 2010-${h.datetime.today().year}, <a href="${h.route_url('rhodecode_official')}" target="_blank">RhodeCode GmbH</a>. All rights reserved.
49 49 % if c.visual.rhodecode_support_url:
50 50 <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support')}</a>
51 51 % endif
52 52 </p>
53 53 <% sid = 'block' if request.GET.get('showrcid') else 'none' %>
54 54 <p class="server-instance" style="display:${sid}">
55 55 ## display hidden instance ID if specially defined
56 56 % if c.rhodecode_instanceid:
57 57 ${_('RhodeCode instance id: {}').format(c.rhodecode_instanceid)}
58 58 % endif
59 59 </p>
60 60 </div>
61 61 </div>
62 62 </div>
63 63
64 64 <!-- END FOOTER -->
65 65
66 66 ### MAKO DEFS ###
67 67
68 68 <%def name="menu_bar_subnav()">
69 69 </%def>
70 70
71 71 <%def name="breadcrumbs(class_='breadcrumbs')">
72 72 <div class="${class_}">
73 73 ${self.breadcrumbs_links()}
74 74 </div>
75 75 </%def>
76 76
77 77 <%def name="admin_menu(active=None)">
78 78 <div id="context-bar">
79 79 <div class="wrapper">
80 80 <ul id="context-pages" class="navigation horizontal-list">
81 81 <%
82 82 repositories=c.rhodecode_user.repositories_admin
83 83 repository_groups=c.rhodecode_user.repository_groups_admin
84 84 user_groups=c.rhodecode_user.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')()
85 85 def is_active(selected):
86 86 if selected == active:
87 87 return "active"
88 88 %>
89 89 ## super admin case
90 90 % if c.rhodecode_user.is_admin:
91 91 <li class="${is_active('audit_logs')}"><a href="${h.route_path('admin_audit_logs')}">${_('Admin audit logs')}</a></li>
92 92 <li class="${is_active('repositories')}"><a href="${h.route_path('repos')}">${_('Repositories')}</a></li>
93 93 <li class="${is_active('repository_groups')}"><a href="${h.route_path('repo_groups')}">${_('Repository groups')}</a></li>
94 94 <li class="${is_active('users')}"><a href="${h.route_path('users')}">${_('Users')}</a></li>
95 95 <li class="${is_active('user_groups')}"><a href="${h.route_path('user_groups')}">${_('User groups')}</a></li>
96 96 <li class="${is_active('permissions')}"><a href="${h.route_path('admin_permissions_application')}">${_('Permissions')}</a></li>
97 97 <li class="${is_active('authentication')}"><a href="${h.route_path('auth_home', traverse='')}">${_('Authentication')}</a></li>
98 98 <li class="${is_active('integrations')}"><a href="${h.route_path('global_integrations_home')}">${_('Integrations')}</a></li>
99 99 <li class="${is_active('defaults')}"><a href="${h.route_path('admin_defaults_repositories')}">${_('Defaults')}</a></li>
100 100 <li class="${is_active('settings')}"><a href="${h.route_path('admin_settings')}">${_('Settings')}</a></li>
101 101
102 102 ## delegated admin
103 103 % elif repositories or repository_groups or user_groups:
104 104
105 105 %if repositories:
106 106 <li class="${is_active('repositories')} local-admin-repos"><a href="${h.route_path('repos')}">${_('Repositories')}</a></li>
107 107 %endif
108 108 %if repository_groups:
109 109 <li class="${is_active('repository_groups')} local-admin-repo-groups"><a href="${h.route_path('repo_groups')}">${_('Repository groups')}</a></li>
110 110 %endif
111 111 %if user_groups:
112 112 <li class="${is_active('user_groups')} local-admin-user-groups"><a href="${h.route_path('user_groups')}">${_('User groups')}</a></li>
113 113 %endif
114 114 % endif
115 115 </ul>
116 116 </div>
117 117 <div class="clear"></div>
118 118 </div>
119 119 </%def>
120 120
121 121
122 122 <%def name="dt_info_panel(elements)">
123 123 <dl class="dl-horizontal">
124 124 %for dt, dd, title, show_items in elements:
125 125 <dt>${dt}:</dt>
126 126 <dd title="${h.tooltip(title)}">
127 127 %if callable(dd):
128 128 ## allow lazy evaluation of elements
129 129 ${dd()}
130 130 %else:
131 131 ${dd}
132 132 %endif
133 133 %if show_items:
134 134 <span class="btn-collapse" data-toggle="item-${h.md5_safe(dt)[:6]}-details">${_('Show More')} </span>
135 135 %endif
136 136 </dd>
137 137
138 138 %if show_items:
139 139 <div class="collapsable-content" data-toggle="item-${h.md5_safe(dt)[:6]}-details" style="display: none">
140 140 %for item in show_items:
141 141 <dt></dt>
142 142 <dd>${item}</dd>
143 143 %endfor
144 144 </div>
145 145 %endif
146 146
147 147 %endfor
148 148 </dl>
149 149 </%def>
150 150
151 151
152 152 <%def name="gravatar(email, size=16)">
153 153 <%
154 154 if (size > 16):
155 155 gravatar_class = 'gravatar gravatar-large'
156 156 else:
157 157 gravatar_class = 'gravatar'
158 158 %>
159 159 <%doc>
160 160 TODO: johbo: For now we serve double size images to make it smooth
161 161 for retina. This is how it worked until now. Should be replaced
162 162 with a better solution at some point.
163 163 </%doc>
164 164 <img class="${gravatar_class}" src="${h.gravatar_url(email, size * 2)}" height="${size}" width="${size}">
165 165 </%def>
166 166
167 167
168 168 <%def name="gravatar_with_user(contact, size=16, show_disabled=False)">
169 169 <% email = h.email_or_none(contact) %>
170 170 <div class="rc-user tooltip" title="${h.tooltip(h.author_string(email))}">
171 171 ${self.gravatar(email, size)}
172 172 <span class="${'user user-disabled' if show_disabled else 'user'}"> ${h.link_to_user(contact)}</span>
173 173 </div>
174 174 </%def>
175 175
176 176
177 177 <%def name="repo_page_title(repo_instance)">
178 178 <div class="title-content">
179 179 <div class="title-main">
180 180 ## SVN/HG/GIT icons
181 181 %if h.is_hg(repo_instance):
182 182 <i class="icon-hg"></i>
183 183 %endif
184 184 %if h.is_git(repo_instance):
185 185 <i class="icon-git"></i>
186 186 %endif
187 187 %if h.is_svn(repo_instance):
188 188 <i class="icon-svn"></i>
189 189 %endif
190 190
191 191 ## public/private
192 192 %if repo_instance.private:
193 193 <i class="icon-repo-private"></i>
194 194 %else:
195 195 <i class="icon-repo-public"></i>
196 196 %endif
197 197
198 198 ## repo name with group name
199 199 ${h.breadcrumb_repo_link(repo_instance)}
200 200
201 201 </div>
202 202
203 203 ## FORKED
204 204 %if repo_instance.fork:
205 205 <p>
206 206 <i class="icon-code-fork"></i> ${_('Fork of')}
207 207 ${h.link_to_if(c.has_origin_repo_read_perm,repo_instance.fork.repo_name, h.route_path('repo_summary', repo_name=repo_instance.fork.repo_name))}
208 208 </p>
209 209 %endif
210 210
211 211 ## IMPORTED FROM REMOTE
212 212 %if repo_instance.clone_uri:
213 213 <p>
214 214 <i class="icon-code-fork"></i> ${_('Clone from')}
215 215 <a href="${h.safe_str(h.hide_credentials(repo_instance.clone_uri))}">${h.hide_credentials(repo_instance.clone_uri)}</a>
216 216 </p>
217 217 %endif
218 218
219 219 ## LOCKING STATUS
220 220 %if repo_instance.locked[0]:
221 221 <p class="locking_locked">
222 222 <i class="icon-repo-lock"></i>
223 223 ${_('Repository locked by %(user)s') % {'user': h.person_by_id(repo_instance.locked[0])}}
224 224 </p>
225 225 %elif repo_instance.enable_locking:
226 226 <p class="locking_unlocked">
227 227 <i class="icon-repo-unlock"></i>
228 228 ${_('Repository not locked. Pull repository to lock it.')}
229 229 </p>
230 230 %endif
231 231
232 232 </div>
233 233 </%def>
234 234
235 235 <%def name="repo_menu(active=None)">
236 236 <%
237 237 def is_active(selected):
238 238 if selected == active:
239 239 return "active"
240 240 %>
241 241
242 242 <!--- REPO CONTEXT BAR -->
243 243 <div id="context-bar">
244 244 <div class="wrapper">
245 245
246 246 <div class="title">
247 247 ${self.repo_page_title(c.rhodecode_db_repo)}
248 248 </div>
249 249
250 250 <ul id="context-pages" class="navigation horizontal-list">
251 251 <li class="${is_active('summary')}"><a class="menulink" href="${h.route_path('repo_summary', repo_name=c.repo_name)}"><div class="menulabel">${_('Summary')}</div></a></li>
252 252 <li class="${is_active('changelog')}"><a class="menulink" href="${h.route_path('repo_changelog', repo_name=c.repo_name)}"><div class="menulabel">${_('Changelog')}</div></a></li>
253 253 <li class="${is_active('files')}"><a class="menulink" href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.rhodecode_db_repo.landing_rev[1], f_path='')}"><div class="menulabel">${_('Files')}</div></a></li>
254 254 <li class="${is_active('compare')}"><a class="menulink" href="${h.route_path('repo_compare_select',repo_name=c.repo_name)}"><div class="menulabel">${_('Compare')}</div></a></li>
255 255
256 256 ## TODO: anderson: ideally it would have a function on the scm_instance "enable_pullrequest() and enable_fork()"
257 257 %if c.rhodecode_db_repo.repo_type in ['git','hg']:
258 258 <li class="${is_active('showpullrequest')}">
259 259 <a class="menulink" href="${h.route_path('pullrequest_show_all', repo_name=c.repo_name)}" title="${h.tooltip(_('Show Pull Requests for %s') % c.repo_name)}">
260 %if c.repository_pull_requests:
261 <span class="pr_notifications">${c.repository_pull_requests}</span>
260 <div class="menulabel">
261 %if c.repository_pull_requests == 1:
262 ${c.repository_pull_requests} ${_('Pull Request')}
263 %else:
264 ${c.repository_pull_requests} ${_('Pull Requests')}
262 265 %endif
263 <div class="menulabel">${_('Pull Requests')}</div>
266 </div>
264 267 </a>
265 268 </li>
266 269 %endif
267 270
268 271 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
269 272 <li class="${is_active('settings')}"><a class="menulink" href="${h.route_path('edit_repo',repo_name=c.repo_name)}"><div class="menulabel">${_('Repository Settings')}</div></a></li>
270 273 %endif
271 274
272 275 <li class="${is_active('options')}">
273 276 <a class="menulink dropdown">
274 277 <div class="menulabel">${_('Options')} <div class="show_more"></div></div>
275 278 </a>
276 279 <ul class="submenu">
277 280
278 281 %if c.rhodecode_db_repo.fork:
279 282 <li>
280 283 <a title="${h.tooltip(_('Compare fork with %s' % c.rhodecode_db_repo.fork.repo_name))}"
281 284 href="${h.route_path('repo_compare',
282 285 repo_name=c.rhodecode_db_repo.fork.repo_name,
283 286 source_ref_type=c.rhodecode_db_repo.landing_rev[0],
284 287 source_ref=c.rhodecode_db_repo.landing_rev[1],
285 288 target_repo=c.repo_name,target_ref_type='branch' if request.GET.get('branch') else c.rhodecode_db_repo.landing_rev[0],
286 289 target_ref=request.GET.get('branch') or c.rhodecode_db_repo.landing_rev[1],
287 290 _query=dict(merge=1))}"
288 291 >
289 292 ${_('Compare fork')}
290 293 </a>
291 294 </li>
292 295 %endif
293 296
294 297 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking:
295 298 %if c.rhodecode_db_repo.locked[0]:
296 299 <li><a class="locking_del" href="${h.route_path('repo_edit_toggle_locking',repo_name=c.repo_name)}">${_('Unlock')}</a></li>
297 300 %else:
298 301 <li><a class="locking_add" href="${h.route_path('repo_edit_toggle_locking',repo_name=c.repo_name)}">${_('Lock')}</a></li>
299 302 %endif
300 303 %endif
301 304 %if c.rhodecode_user.username != h.DEFAULT_USER:
302 305 %if c.rhodecode_db_repo.repo_type in ['git','hg']:
303 306 <li><a href="${h.route_path('repo_fork_new',repo_name=c.repo_name)}">${_('Fork')}</a></li>
304 307 <li><a href="${h.route_path('pullrequest_new',repo_name=c.repo_name)}">${_('Create Pull Request')}</a></li>
305 308 %endif
306 309 %endif
307 310 </ul>
308 311 </li>
309 312 </ul>
310 313 </div>
311 314 <div class="clear"></div>
312 315 </div>
313 316 % if c.rhodecode_db_repo.archived:
314 317 <div class="alert alert-warning text-center">
315 318 <strong>${_('This repository has been archived. It is now read-only.')}</strong>
316 319 </div>
317 320 % endif
318 321 <!--- REPO END CONTEXT BAR -->
319 322
320 323 </%def>
321 324
322 325 <%def name="repo_group_page_title(repo_group_instance)">
323 326 <div class="title-content">
324 327 <div class="title-main">
325 328 ## Repository Group icon
326 329 <i class="icon-folder-close"></i>
327 330
328 331 ## repo name with group name
329 332 ${h.breadcrumb_repo_group_link(repo_group_instance)}
330 333 </div>
331 334
332 335 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
333 336 <div class="repo-group-desc">
334 337 ${dt.repo_group_desc(repo_group_instance.description_safe, repo_group_instance.personal, c.visual.stylify_metatags)}
335 338 </div>
336 339
337 340 </div>
338 341 </%def>
339 342
340 343 <%def name="repo_group_menu(active=None)">
341 344 <%
342 345 def is_active(selected):
343 346 if selected == active:
344 347 return "active"
345 348
346 349 is_admin = h.HasPermissionAny('hg.admin')('can create repos index page')
347 350
348 351 gr_name = c.repo_group.group_name if c.repo_group else None
349 352 # create repositories with write permission on group is set to true
350 353 create_on_write = h.HasPermissionAny('hg.create.write_on_repogroup.true')()
351 354 group_admin = h.HasRepoGroupPermissionAny('group.admin')(gr_name, 'group admin index page')
352 355 group_write = h.HasRepoGroupPermissionAny('group.write')(gr_name, 'can write into group index page')
353 356
354 357 %>
355 358
356 359 <!--- REPO GROUP CONTEXT BAR -->
357 360 <div id="context-bar">
358 361 <div class="wrapper">
359 362 <ul id="context-pages" class="navigation horizontal-list">
360 363 <li class="${is_active('home')}"><a class="menulink" href="${h.route_path('repo_group_home', repo_group_name=c.repo_group.group_name)}"><div class="menulabel">${_('Group Home')}</div></a></li>
361 364 % if is_admin or group_admin:
362 365 <li class="${is_active('settings')}"><a class="menulink" href="${h.route_path('edit_repo_group',repo_group_name=c.repo_group.group_name)}" title="${_('You have admin right to this group, and can edit it')}"><div class="menulabel">${_('Group Settings')}</div></a></li>
363 366 % endif
364 367
365 368 <li class="${is_active('options')}">
366 369 <a class="menulink dropdown">
367 370 <div class="menulabel">${_('Options')} <div class="show_more"></div></div>
368 371 </a>
369 372 <ul class="submenu">
370 373 %if is_admin or group_admin or (group_write and create_on_write):
371 374 <li><a href="${h.route_path('repo_new',_query=dict(parent_group=c.repo_group.group_id))}">${_('Add Repository')}</a></li>
372 375 %endif
373 376 %if is_admin or group_admin:
374 377 <li><a href="${h.route_path('repo_group_new',_query=dict(parent_group=c.repo_group.group_id))}">${_(u'Add Parent Group')}</a></li>
375 378 %endif
376 379 </ul>
377 380 </li>
378 381 </ul>
379 382 </div>
380 383 <div class="clear"></div>
381 384 </div>
382 385
383 386 <!--- REPO GROUP CONTEXT BAR -->
384 387
385 388 </%def>
386 389
387 390
388 391 <%def name="usermenu(active=False)">
389 392 ## USER MENU
390 393 <li id="quick_login_li" class="${'active' if active else ''}">
391 394 % if c.rhodecode_user.username == h.DEFAULT_USER:
392 395 <a id="quick_login_link" class="menulink childs" href="${h.route_path('login', _query={'came_from': h.current_route_path(request)})}">
393 396 ${gravatar(c.rhodecode_user.email, 20)}
394 397 <span class="user">
395 398 <span>${_('Sign in')}</span>
396 399 </span>
397 400 </a>
398 401 % else:
399 402 ## logged in user
400 403 <a id="quick_login_link" class="menulink childs">
401 404 ${gravatar(c.rhodecode_user.email, 20)}
402 405 <span class="user">
403 406 <span class="menu_link_user">${c.rhodecode_user.username}</span>
404 407 <div class="show_more"></div>
405 408 </span>
406 409 </a>
407 410 ## subnav with menu for logged in user
408 411 <div class="user-menu submenu">
409 412 <div id="quick_login">
410 413 %if c.rhodecode_user.username != h.DEFAULT_USER:
411 414 <div class="">
412 415 <div class="big_gravatar">${gravatar(c.rhodecode_user.email, 48)}</div>
413 416 <div class="full_name">${c.rhodecode_user.full_name_or_username}</div>
414 417 <div class="email">${c.rhodecode_user.email}</div>
415 418 </div>
416 419 <div class="">
417 420 <ol class="links">
418 421 <li>${h.link_to(_(u'My account'),h.route_path('my_account_profile'))}</li>
419 422 % if c.rhodecode_user.personal_repo_group:
420 423 <li>${h.link_to(_(u'My personal group'), h.route_path('repo_group_home', repo_group_name=c.rhodecode_user.personal_repo_group.group_name))}</li>
421 424 % endif
422 425 <li>${h.link_to(_(u'Pull Requests'), h.route_path('my_account_pullrequests'))}</li>
423 426 ## bookmark-items
424 427 <li class="bookmark-items">
425 428 ${_('Bookmarks')}
426 429 <div class="pull-right">
427 430 <a href="${h.route_path('my_account_bookmarks')}">${_('Manage')}</a>
428 431 </div>
429 432 </li>
430 433 % if not c.bookmark_items:
431 434 <li>
432 435 <a href="${h.route_path('my_account_bookmarks')}">${_('No Bookmarks yet.')}</a>
433 436 </li>
434 437 % endif
435 438 % for item in c.bookmark_items:
436 439 <li>
437 440 % if item.repository:
438 441 <div>
439 442 <a class="bookmark-item" href="${h.route_path('my_account_goto_bookmark', bookmark_id=item.position)}">
440 443 <code>${item.position}</code>
441 444 % if item.repository.repo_type == 'hg':
442 445 <i class="icon-hg" title="${_('Repository')}" style="font-size: 16px"></i>
443 446 % elif item.repository.repo_type == 'git':
444 447 <i class="icon-git" title="${_('Repository')}" style="font-size: 16px"></i>
445 448 % elif item.repository.repo_type == 'svn':
446 449 <i class="icon-svn" title="${_('Repository')}" style="font-size: 16px"></i>
447 450 % endif
448 451 ${(item.title or h.shorter(item.repository.repo_name, 30))}
449 452 </a>
450 453 </div>
451 454 % elif item.repository_group:
452 455 <div>
453 456 <a class="bookmark-item" href="${h.route_path('my_account_goto_bookmark', bookmark_id=item.position)}">
454 457 <code>${item.position}</code>
455 458 <i class="icon-folder-close" title="${_('Repository group')}" style="font-size: 16px"></i>
456 459 ${(item.title or h.shorter(item.repository_group.group_name, 30))}
457 460 </a>
458 461 </div>
459 462 % else:
460 463 <a class="bookmark-item" href="${h.route_path('my_account_goto_bookmark', bookmark_id=item.position)}">
461 464 <code>${item.position}</code>
462 465 ${item.title}
463 466 </a>
464 467 % endif
465 468 </li>
466 469 % endfor
467 470
468 471 <li class="logout">
469 472 ${h.secure_form(h.route_path('logout'), request=request)}
470 473 ${h.submit('log_out', _(u'Sign Out'),class_="btn btn-primary")}
471 474 ${h.end_form()}
472 475 </li>
473 476 </ol>
474 477 </div>
475 478 %endif
476 479 </div>
477 480 </div>
478 481 ## unread counter
479 482 <div class="pill_container">
480 483 <a class="menu_link_notifications ${'empty' if c.unread_notifications == 0 else ''}" href="${h.route_path('notifications_show_all')}">${c.unread_notifications}</a>
481 484 </div>
482 485 % endif
483 486 </li>
484 487 </%def>
485 488
486 489 <%def name="menu_items(active=None)">
487 490 <%
488 491 def is_active(selected):
489 492 if selected == active:
490 493 return "active"
491 494 return ""
492 495 %>
493 496
494 497 <ul id="quick" class="main_nav navigation horizontal-list">
495 498 ## notice box for important system messages
496 499 <li style="display: none">
497 500 <a class="notice-box" href="#openNotice" onclick="showNoticeBox(); return false">
498 501 <div class="menulabel-notice" >
499 502 0
500 503 </div>
501 504 </a>
502 505 </li>
503 506
504 507 ## Main filter
505 508 <li>
506 509 <div class="menulabel main_filter_box">
507 510 <div class="main_filter_input_box">
508 511 <ul class="searchItems">
509 512
510 513 % if c.template_context['search_context']['repo_id']:
511 514 <li class="searchTag searchTagFilter searchTagHidable" >
512 515 ##<a href="${h.route_path('search_repo',repo_name=c.template_context['search_context']['repo_name'])}">
513 516 <span class="tag">
514 517 This repo
515 518 <a href="#removeGoToFilter" onclick="removeGoToFilter(); return false"><i class="icon-delete"></i></a>
516 519 </span>
517 520 ##</a>
518 521 </li>
519 522 % elif c.template_context['search_context']['repo_group_id']:
520 523 <li class="searchTag searchTagFilter searchTagHidable">
521 524 ##<a href="${h.route_path('search_repo_group',repo_group_name=c.template_context['search_context']['repo_group_name'])}">
522 525 <span class="tag">
523 526 This group
524 527 <a href="#removeGoToFilter" onclick="removeGoToFilter(); return false"><i class="icon-delete"></i></a>
525 528 </span>
526 529 ##</a>
527 530 </li>
528 531 % endif
529 532
530 533 <li class="searchTagInput">
531 534 <input class="main_filter_input" id="main_filter" size="15" type="text" name="main_filter" placeholder="${_('search / go to...')}" value="" />
532 535 </li>
533 536 <li class="searchTag searchTagHelp">
534 537 <a href="#showFilterHelp" onclick="showMainFilterBox(); return false">?</a>
535 538 </li>
536 539 </ul>
537 540 </div>
538 541 </div>
539 542
540 543 <div id="main_filter_help" style="display: none">
541 544 - Use '/' key to quickly access this field.
542 545
543 546 - Enter a name of repository, or repository group for quick search.
544 547
545 548 - Prefix query to allow special search:
546 549
547 550 user:admin, to search for usernames, always global
548 551
549 552 user_group:devops, to search for user groups, always global
550 553
551 554 commit:efced4, to search for commits, scoped to repositories or groups
552 555
553 556 file:models.py, to search for file paths, scoped to repositories or groups
554 557
555 558 % if c.template_context['search_context']['repo_id']:
556 559 For advanced full text search visit: <a href="${h.route_path('search_repo',repo_name=c.template_context['search_context']['repo_name'])}">repository search</a>
557 560 % elif c.template_context['search_context']['repo_group_id']:
558 561 For advanced full text search visit: <a href="${h.route_path('search_repo_group',repo_group_name=c.template_context['search_context']['repo_group_name'])}">repository group search</a>
559 562 % else:
560 563 For advanced full text search visit: <a href="${h.route_path('search')}">global search</a>
561 564 % endif
562 565 </div>
563 566 </li>
564 567
565 568 ## ROOT MENU
566 569 <li class="${is_active('home')}">
567 570 <a class="menulink" title="${_('Home')}" href="${h.route_path('home')}">
568 571 <div class="menulabel">${_('Home')}</div>
569 572 </a>
570 573 </li>
571 574
572 575 %if c.rhodecode_user.username != h.DEFAULT_USER:
573 576 <li class="${is_active('journal')}">
574 577 <a class="menulink" title="${_('Show activity journal')}" href="${h.route_path('journal')}">
575 578 <div class="menulabel">${_('Journal')}</div>
576 579 </a>
577 580 </li>
578 581 %else:
579 582 <li class="${is_active('journal')}">
580 583 <a class="menulink" title="${_('Show Public activity journal')}" href="${h.route_path('journal_public')}">
581 584 <div class="menulabel">${_('Public journal')}</div>
582 585 </a>
583 586 </li>
584 587 %endif
585 588
586 589 <li class="${is_active('gists')}">
587 590 <a class="menulink childs" title="${_('Show Gists')}" href="${h.route_path('gists_show')}">
588 591 <div class="menulabel">${_('Gists')}</div>
589 592 </a>
590 593 </li>
591 594
592 595 <li class="${is_active('admin')}">
593 596 <a class="menulink childs" title="${_('Admin settings')}" href="${h.route_path('admin_home')}">
594 597 <div class="menulabel">${_('Admin')} </div>
595 598 </a>
596 599 </li>
597 600
598 601 ## render extra user menu
599 602 ${usermenu(active=(active=='my_account'))}
600 603
601 604 % if c.debug_style:
602 605 <li>
603 606 <a class="menulink" title="${_('Style')}" href="${h.route_path('debug_style_home')}">
604 607 <div class="menulabel">${_('[Style]')}</div>
605 608 </a>
606 609 </li>
607 610 % endif
608 611 </ul>
609 612
610 613 <script type="text/javascript">
611 614 var visualShowPublicIcon = "${c.visual.show_public_icon}" == "True";
612 615
613 616 var formatRepoResult = function(result, container, query, escapeMarkup) {
614 617 return function(data, escapeMarkup) {
615 618 if (!data.repo_id){
616 619 return data.text; // optgroup text Repositories
617 620 }
618 621
619 622 var tmpl = '';
620 623 var repoType = data['repo_type'];
621 624 var repoName = data['text'];
622 625
623 626 if(data && data.type == 'repo'){
624 627 if(repoType === 'hg'){
625 628 tmpl += '<i class="icon-hg"></i> ';
626 629 }
627 630 else if(repoType === 'git'){
628 631 tmpl += '<i class="icon-git"></i> ';
629 632 }
630 633 else if(repoType === 'svn'){
631 634 tmpl += '<i class="icon-svn"></i> ';
632 635 }
633 636 if(data['private']){
634 637 tmpl += '<i class="icon-lock" ></i> ';
635 638 }
636 639 else if(visualShowPublicIcon){
637 640 tmpl += '<i class="icon-unlock-alt"></i> ';
638 641 }
639 642 }
640 643 tmpl += escapeMarkup(repoName);
641 644 return tmpl;
642 645
643 646 }(result, escapeMarkup);
644 647 };
645 648
646 649 var formatRepoGroupResult = function(result, container, query, escapeMarkup) {
647 650 return function(data, escapeMarkup) {
648 651 if (!data.repo_group_id){
649 652 return data.text; // optgroup text Repositories
650 653 }
651 654
652 655 var tmpl = '';
653 656 var repoGroupName = data['text'];
654 657
655 658 if(data){
656 659
657 660 tmpl += '<i class="icon-folder-close"></i> ';
658 661
659 662 }
660 663 tmpl += escapeMarkup(repoGroupName);
661 664 return tmpl;
662 665
663 666 }(result, escapeMarkup);
664 667 };
665 668
666 669 var escapeRegExChars = function (value) {
667 670 return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
668 671 };
669 672
670 673 var getRepoIcon = function(repo_type) {
671 674 if (repo_type === 'hg') {
672 675 return '<i class="icon-hg"></i> ';
673 676 }
674 677 else if (repo_type === 'git') {
675 678 return '<i class="icon-git"></i> ';
676 679 }
677 680 else if (repo_type === 'svn') {
678 681 return '<i class="icon-svn"></i> ';
679 682 }
680 683 return ''
681 684 };
682 685
683 686 var autocompleteMainFilterFormatResult = function (data, value, org_formatter) {
684 687
685 688 if (value.split(':').length === 2) {
686 689 value = value.split(':')[1]
687 690 }
688 691
689 692 var searchType = data['type'];
690 693 var valueDisplay = data['value_display'];
691 694
692 695 var pattern = '(' + escapeRegExChars(value) + ')';
693 696
694 697 valueDisplay = Select2.util.escapeMarkup(valueDisplay);
695 698
696 699 // highlight match
697 700 if (searchType != 'text') {
698 701 valueDisplay = valueDisplay.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
699 702 }
700 703
701 704 var icon = '';
702 705
703 706 if (searchType === 'hint') {
704 707 icon += '<i class="icon-folder-close"></i> ';
705 708 }
706 709 // full text search
707 710 else if (searchType === 'search') {
708 711 icon += '<i class="icon-more"></i> ';
709 712 }
710 713 // repository
711 714 else if (searchType === 'repo') {
712 715
713 716 var repoIcon = getRepoIcon(data['repo_type']);
714 717 icon += repoIcon;
715 718
716 719 if (data['private']) {
717 720 icon += '<i class="icon-lock" ></i> ';
718 721 }
719 722 else if (visualShowPublicIcon) {
720 723 icon += '<i class="icon-unlock-alt"></i> ';
721 724 }
722 725 }
723 726 // repository groups
724 727 else if (searchType === 'repo_group') {
725 728 icon += '<i class="icon-folder-close"></i> ';
726 729 }
727 730 // user group
728 731 else if (searchType === 'user_group') {
729 732 icon += '<i class="icon-group"></i> ';
730 733 }
731 734 // user
732 735 else if (searchType === 'user') {
733 736 icon += '<img class="gravatar" src="{0}"/>'.format(data['icon_link']);
734 737 }
735 738 // commit
736 739 else if (searchType === 'commit') {
737 740 var repo_data = data['repo_data'];
738 741 var repoIcon = getRepoIcon(repo_data['repository_type']);
739 742 if (repoIcon) {
740 743 icon += repoIcon;
741 744 } else {
742 745 icon += '<i class="icon-tag"></i>';
743 746 }
744 747 }
745 748 // file
746 749 else if (searchType === 'file') {
747 750 var repo_data = data['repo_data'];
748 751 var repoIcon = getRepoIcon(repo_data['repository_type']);
749 752 if (repoIcon) {
750 753 icon += repoIcon;
751 754 } else {
752 755 icon += '<i class="icon-tag"></i>';
753 756 }
754 757 }
755 758 // generic text
756 759 else if (searchType === 'text') {
757 760 icon = '';
758 761 }
759 762
760 763 var tmpl = '<div class="ac-container-wrap">{0}{1}</div>';
761 764 return tmpl.format(icon, valueDisplay);
762 765 };
763 766
764 767 var handleSelect = function(element, suggestion) {
765 768 if (suggestion.type === "hint") {
766 769 // we skip action
767 770 $('#main_filter').focus();
768 771 }
769 772 else if (suggestion.type === "text") {
770 773 // we skip action
771 774 $('#main_filter').focus();
772 775
773 776 } else {
774 777 window.location = suggestion['url'];
775 778 }
776 779 };
777 780
778 781 var autocompleteMainFilterResult = function (suggestion, originalQuery, queryLowerCase) {
779 782 if (queryLowerCase.split(':').length === 2) {
780 783 queryLowerCase = queryLowerCase.split(':')[1]
781 784 }
782 785 if (suggestion.type === "text") {
783 786 // special case we don't want to "skip" display for
784 787 return true
785 788 }
786 789 return suggestion.value_display.toLowerCase().indexOf(queryLowerCase) !== -1;
787 790 };
788 791
789 792 var cleanContext = {
790 793 repo_view_type: null,
791 794
792 795 repo_id: null,
793 796 repo_name: "",
794 797
795 798 repo_group_id: null,
796 799 repo_group_name: null
797 800 };
798 801 var removeGoToFilter = function () {
799 802 $('.searchTagHidable').hide();
800 803 $('#main_filter').autocomplete(
801 804 'setOptions', {params:{search_context: cleanContext}});
802 805 };
803 806
804 807 $('#main_filter').autocomplete({
805 808 serviceUrl: pyroutes.url('goto_switcher_data'),
806 809 params: {
807 810 "search_context": templateContext.search_context
808 811 },
809 812 minChars:2,
810 813 maxHeight:400,
811 814 deferRequestBy: 300, //miliseconds
812 815 tabDisabled: true,
813 816 autoSelectFirst: false,
814 817 formatResult: autocompleteMainFilterFormatResult,
815 818 lookupFilter: autocompleteMainFilterResult,
816 819 onSelect: function (element, suggestion) {
817 820 handleSelect(element, suggestion);
818 821 return false;
819 822 },
820 823 onSearchError: function (element, query, jqXHR, textStatus, errorThrown) {
821 824 if (jqXHR !== 'abort') {
822 825 alert("Error during search.\nError code: {0}".format(textStatus));
823 826 window.location = '';
824 827 }
825 828 }
826 829 });
827 830
828 831 showMainFilterBox = function () {
829 832 $('#main_filter_help').toggle();
830 833 };
831 834
832 835 $('#main_filter').on('keydown.autocomplete', function (e) {
833 836
834 837 var BACKSPACE = 8;
835 838 var el = $(e.currentTarget);
836 839 if(e.which === BACKSPACE){
837 840 var inputVal = el.val();
838 841 if (inputVal === ""){
839 842 removeGoToFilter()
840 843 }
841 844 }
842 845 });
843 846
844 847 </script>
845 848 <script src="${h.asset('js/rhodecode/base/keyboard-bindings.js', ver=c.rhodecode_version_hash)}"></script>
846 849 </%def>
847 850
848 851 <div class="modal" id="help_kb" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
849 852 <div class="modal-dialog">
850 853 <div class="modal-content">
851 854 <div class="modal-header">
852 855 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
853 856 <h4 class="modal-title" id="myModalLabel">${_('Keyboard shortcuts')}</h4>
854 857 </div>
855 858 <div class="modal-body">
856 859 <div class="block-left">
857 860 <table class="keyboard-mappings">
858 861 <tbody>
859 862 <tr>
860 863 <th></th>
861 864 <th>${_('Site-wide shortcuts')}</th>
862 865 </tr>
863 866 <%
864 867 elems = [
865 868 ('/', 'Use quick search box'),
866 869 ('g h', 'Goto home page'),
867 870 ('g g', 'Goto my private gists page'),
868 871 ('g G', 'Goto my public gists page'),
869 872 ('g 0-9', 'Goto bookmarked items from 0-9'),
870 873 ('n r', 'New repository page'),
871 874 ('n g', 'New gist page'),
872 875 ]
873 876 %>
874 877 %for key, desc in elems:
875 878 <tr>
876 879 <td class="keys">
877 880 <span class="key tag">${key}</span>
878 881 </td>
879 882 <td>${desc}</td>
880 883 </tr>
881 884 %endfor
882 885 </tbody>
883 886 </table>
884 887 </div>
885 888 <div class="block-left">
886 889 <table class="keyboard-mappings">
887 890 <tbody>
888 891 <tr>
889 892 <th></th>
890 893 <th>${_('Repositories')}</th>
891 894 </tr>
892 895 <%
893 896 elems = [
894 897 ('g s', 'Goto summary page'),
895 898 ('g c', 'Goto changelog page'),
896 899 ('g f', 'Goto files page'),
897 900 ('g F', 'Goto files page with file search activated'),
898 901 ('g p', 'Goto pull requests page'),
899 902 ('g o', 'Goto repository settings'),
900 903 ('g O', 'Goto repository permissions settings'),
901 904 ]
902 905 %>
903 906 %for key, desc in elems:
904 907 <tr>
905 908 <td class="keys">
906 909 <span class="key tag">${key}</span>
907 910 </td>
908 911 <td>${desc}</td>
909 912 </tr>
910 913 %endfor
911 914 </tbody>
912 915 </table>
913 916 </div>
914 917 </div>
915 918 <div class="modal-footer">
916 919 </div>
917 920 </div><!-- /.modal-content -->
918 921 </div><!-- /.modal-dialog -->
919 922 </div><!-- /.modal -->
920 923
General Comments 0
You need to be logged in to leave comments. Login now