mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-07 22:53:45 -06:00
Fix the about menu option, only display menus if they have items on them,
and add a management menu for future use.
This commit is contained in:
parent
7179b79b8c
commit
bedaa52693
@ -16,7 +16,8 @@ import config
|
||||
def get_help_menu_items():
|
||||
"""Return a (set) of dicts of help menu items, with name, priority, URL and
|
||||
onclick code."""
|
||||
return [{'name': 'About %s' % (config.APP_NAME),
|
||||
return [{'name': 'mnu_about',
|
||||
'label': 'About %s' % (config.APP_NAME),
|
||||
'priority': 999,
|
||||
'url': "#",
|
||||
'onclick': "about_show()"}]
|
||||
|
@ -17,33 +17,40 @@
|
||||
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
<li class="dropdown">
|
||||
{% if file_items is defined and file_items|count > 0 %}<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">File <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">{% for file_item in file_items %}
|
||||
<li><a id="{{ file_item.name }}" href="{{ file_item.url }}" onclick="{{ file_item.onclick|safe }}">{{ file_item.label }}</a></li>{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
</li>{% endif %}
|
||||
|
||||
<li class="dropdown">
|
||||
{% if edit_items is defined and edit_items|count > 0 %}<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Edit <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">{% for edit_item in edit_items %}
|
||||
<li><a id="{{ edit_item.name }}" href="{{ edit_item.url }}" onclick="{{ edit_item.onclick|safe }}">{{ edit_item.label }}</a></li>{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
</li>{% endif %}
|
||||
|
||||
<li class="dropdown">
|
||||
{% if tools_items is defined and tools_items|count > 0 %}<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Tools <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">{% for tools_item in tools_items %}
|
||||
<li><a id="{{ tools_item.name }}" href="{{ tools_item.url }}" onclick="{{ tools_item.onclick|safe }}">{{ tools_item.label }}</a></li>{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
</li>{% endif %}
|
||||
|
||||
<li class="dropdown">
|
||||
{% if management_items is defined and management_items|count > 0 %}<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Management <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">{% for management_item in management_items %}
|
||||
<li><a id="{{ management_item.name }}" href="{{ management_item.url }}" onclick="{{ management_item.onclick|safe }}">{{ management_item.label }}</a></li>{% endfor %}
|
||||
</ul>
|
||||
</li>{% endif %}
|
||||
|
||||
{% if help_items is defined and help_items|count > 0 %}<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">{% for help_item in help_items %}
|
||||
<li><a id="{{ help_item.name }}" href="{{ help_item.url }}" onclick="{{ help_item.onclick|safe }}">{{ help_item.label }}</a></li>{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
</li>{% endif %}
|
||||
|
||||
</ul>
|
||||
{% if config.SERVER_MODE %}
|
||||
|
@ -42,6 +42,7 @@ def index():
|
||||
file_items = [ ]
|
||||
edit_items = [ ]
|
||||
tools_items = [ ]
|
||||
management_items = [ ]
|
||||
help_items = [ ]
|
||||
stylesheets = [ ]
|
||||
scripts = [ ]
|
||||
@ -78,7 +79,11 @@ def index():
|
||||
# Get the tools menu items
|
||||
if 'hooks' in dir(module) and 'get_tools_menu_items' in dir(module.hooks):
|
||||
tools_items.extend(module.hooks.get_tools_menu_items())
|
||||
|
||||
|
||||
# Get the management menu items
|
||||
if 'hooks' in dir(module) and 'get_management_menu_items' in dir(module.hooks):
|
||||
management_items.extend(module.hooks.get_management_menu_items())
|
||||
|
||||
# Get the help menu items
|
||||
if 'hooks' in dir(module) and 'get_help_menu_items' in dir(module.hooks):
|
||||
help_items.extend(module.hooks.get_help_menu_items())
|
||||
@ -94,6 +99,7 @@ def index():
|
||||
file_items = sorted(file_items, key=lambda k: k['priority'])
|
||||
edit_items = sorted(edit_items, key=lambda k: k['priority'])
|
||||
tools_items = sorted(tools_items, key=lambda k: k['priority'])
|
||||
management_items = sorted(management_items, key=lambda k: k['priority'])
|
||||
help_items = sorted(help_items, key=lambda k: k['priority'])
|
||||
|
||||
return render_template(MODULE_NAME + '/index.html',
|
||||
@ -101,6 +107,7 @@ def index():
|
||||
file_items=file_items,
|
||||
edit_items=edit_items,
|
||||
tools_items=tools_items,
|
||||
management_items=management_items,
|
||||
help_items=help_items,
|
||||
stylesheets = stylesheets,
|
||||
scripts = scripts)
|
||||
|
Loading…
Reference in New Issue
Block a user