Commit 60d9b7a34adeb94f051cb7a10cd720ce54e874d8
1 parent
57f6e57b
Exists in
master
and in
34 other branches
Improve menu links from plugins
-Use OrderedDict to use the config order -If only one link, don't make dropdown menu Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Alexandre Barbosa <alexandreab@live.com>
Showing
2 changed files
with
16 additions
and
7 deletions
Show diff stats
colab/proxy/templates/proxy/menu_template.html
1 | 1 | {% for title, links in menu_links.items %} |
2 | -<li class="dropdown"> | |
3 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ title }} <b class="caret"></b></a> | |
4 | - <ul class="dropdown-menu"> | |
2 | + {% if links|length == 1 %} | |
5 | 3 | {% for text, link in links %} |
6 | - <li><a href="{{ link }}">{{ text }}</a></li> | |
4 | + <li> | |
5 | + <a href="{{ link }}">{{ title }}</a> | |
6 | + </li> | |
7 | 7 | {% endfor %} |
8 | - </ul> | |
9 | -</li> | |
8 | + {% else %} | |
9 | + <li class="dropdown"> | |
10 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ title }} <b class="caret"></b></a> | |
11 | + <ul class="dropdown-menu"> | |
12 | + {% for text, link in links %} | |
13 | + <li><a href="{{ link }}">{{ text }}</a></li> | |
14 | + {% endfor %} | |
15 | + </ul> | |
16 | + </li> | |
17 | + {% endif %} | |
10 | 18 | {% endfor %} | ... | ... |
colab/proxy/templatetags/proxy.py
1 | +from collections import OrderedDict | |
1 | 2 | |
2 | 3 | from django.core.urlresolvers import reverse |
3 | 4 | from django import template |
... | ... | @@ -19,7 +20,7 @@ def proxy_menu(context): |
19 | 20 | if menu_from_cache: |
20 | 21 | return menu_from_cache |
21 | 22 | |
22 | - menu_links = {} | |
23 | + menu_links = OrderedDict() | |
23 | 24 | proxied_apps = context.get('proxy', {}) |
24 | 25 | |
25 | 26 | for app_name, app in proxied_apps.items(): | ... | ... |