Repository: wagtail/wagtail

Issue:
Not possible to use hooks to add menu items to the "More" section
The "More" section of the admin menu is still hard coded and needs a way to use hooks to add menu items here.

This is currently the only thing preventing redirects and editors picks from being optional modules



Discussion:
It is possible to add items dynamically under More, by defining a URL name beginning with wagtailadmin_tab_ - https://github.com/torchbox/verdant-rca/blob/master/django-verdant/donations/urls.py is an example. (@balazs-endresz came up with this approach before I added the hooks system.)

Personally I'd prefer to ditch the 'more' dropdown entirely - it feels like a token gesture towards fixing the 'menu too long' problem without actually improving the user experience. (I'd argue that it's actually _less_ friendly than a big long menu: if an inexperienced user is even slightly unsure which of the visible options is the one they want, they're going to have to expand the 'more' dropdown just to eliminate the other possibilities.)

Seems like the options are:
1) Ditch the more section
2) Make more section configurable with hooks
3) Keep it the way it is

Let me know what you all think.

I'm not really happy with our current solution visually for the 'more' menu
so i'd be reasonably happy with the idea of dropping it for now. However,
we may need some sort of change again if it went past 12 menu items.

If we drop it, we need to factor in the fact that the account icon block is
sticky at the bottom and the menu will go behind (see image), this isn't
very clear visually at the moment. We could make the account icon block
take less vertical space too.

Olly

[image: Inline images 1]

On 27 May 2014 10:50, Karl Hobley notifications@github.com wrote:

> Seems like the options are:
> 1) Ditch the more section
> 2) Make more section configurable with hooks
> 3) Keep it the way it is
> 
> Let me know what you all think.
> 
> ## 
> 
> Reply to this email directly or view it on GitHubhttps://github.com/torchbox/wagtail/issues/228#issuecomment-44255217
> .

## 

Olly Willans
Director

Torchbox Ltd | Southill Park | Charlbury | OX7 3EW

Direct: +44 (0)1608 811 921
Office: +44 (0)1608 811 870
Email: olly.willans@torchbox.com
http://torchbox.com

Let's go for option 1, then, for now.

On 27 May 2014 11:03, Olly Willans notifications@github.com wrote:

> I'm not really happy with our current solution visually for the 'more' menu
> so i'd be reasonably happy with the idea of dropping it for now. However,
> we may need some sort of change again if it went past 12 menu items.
> 
> If we drop it, we need to factor in the fact that the account icon block is
> sticky at the bottom and the menu will go behind (see image), this isn't
> very clear visually at the moment. We could make the account icon block
> take less vertical space too.
> 
> Olly
> 
> [image: Inline images 1]
> 
> On 27 May 2014 10:50, Karl Hobley notifications@github.com wrote:
> 
> > Seems like the options are:
> > 1) Ditch the more section
> > 2) Make more section configurable with hooks
> > 3) Keep it the way it is
> > 
> > Let me know what you all think.
> > 
> > ## 
> > 
> > Reply to this email directly or view it on GitHub<
> > https://github.com/torchbox/wagtail/issues/228#issuecomment-44255217>
> > .
> 
> ## 
> 
> Olly Willans
> Director
> 
> Torchbox Ltd | Southill Park | Charlbury | OX7 3EW
> 
> Direct: +44 (0)1608 811 921
> Office: +44 (0)1608 811 870
> Email: olly.willans@torchbox.com
> http://torchbox.com
> 
> ## 
> 
> Reply to this email directly or view it on GitHubhttps://github.com/torchbox/wagtail/issues/228#issuecomment-44256419
> .

## 

tom dyson
+44 (0)1608 811870
http://torchbox.com
http://wagtail.io


Resolving patch:
diff --git a/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py b/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py
--- a/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py
+++ b/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py
@@ -26,17 +26,6 @@ def explorer_subnav(nodes):
     }
 
 
-@register.assignment_tag
-def get_wagtailadmin_tab_urls():
-    resolver = urlresolvers.get_resolver(None)
-    return [
-        (key, value[2].get("title", key))
-        for key, value
-        in resolver.reverse_dict.items()
-        if isinstance(key, basestring) and key.startswith('wagtailadmin_tab_')
-    ]
-
-
 @register.inclusion_tag('wagtailadmin/shared/main_nav.html', takes_context=True)
 def main_nav(context):
     menu_items = [
diff --git a/wagtail/wagtailredirects/wagtail_hooks.py b/wagtail/wagtailredirects/wagtail_hooks.py
--- a/wagtail/wagtailredirects/wagtail_hooks.py
+++ b/wagtail/wagtailredirects/wagtail_hooks.py
@@ -1,11 +1,24 @@
+from django.core import urlresolvers
 from django.conf.urls import include, url
+from django.utils.translation import ugettext_lazy as _
 
 from wagtail.wagtailadmin import hooks
 from wagtail.wagtailredirects import urls
 
+from wagtail.wagtailadmin.menu import MenuItem
+
 
 def register_admin_urls():
     return [
         url(r'^redirects/', include(urls)),
     ]
 hooks.register('register_admin_urls', register_admin_urls)
+
+
+def construct_main_menu(request, menu_items):
+    # TEMPORARY: Only show if the user is a superuser
+    if request.user.is_superuser:
+        menu_items.append(
+            MenuItem(_('Redirects'), urlresolvers.reverse('wagtailredirects_index'), classnames='icon icon-redirect', order=800)
+        )
+hooks.register('construct_main_menu', construct_main_menu)
diff --git a/wagtail/wagtailsearch/wagtail_hooks.py b/wagtail/wagtailsearch/wagtail_hooks.py
--- a/wagtail/wagtailsearch/wagtail_hooks.py
+++ b/wagtail/wagtailsearch/wagtail_hooks.py
@@ -1,11 +1,24 @@
+from django.core import urlresolvers
 from django.conf.urls import include, url
+from django.utils.translation import ugettext_lazy as _
 
 from wagtail.wagtailadmin import hooks
 from wagtail.wagtailsearch.urls import admin as admin_urls
 
+from wagtail.wagtailadmin.menu import MenuItem
+
 
 def register_admin_urls():
     return [
         url(r'^search/', include(admin_urls)),
     ]
 hooks.register('register_admin_urls', register_admin_urls)
+
+
+def construct_main_menu(request, menu_items):
+    # TEMPORARY: Only show if the user is a superuser
+    if request.user.is_superuser:
+        menu_items.append(
+            MenuItem(_('Editors picks'), urlresolvers.reverse('wagtailsearch_editorspicks_index'), classnames='icon icon-pick', order=900)
+        )
+hooks.register('construct_main_menu', construct_main_menu)


Test patch: