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