From f63986f47d9465a488ea9457b9149fba7fe4e1e7 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 15 Oct 2015 22:04:09 +0100 Subject: [PATCH] If explorer nav menu is empty, take user directly to the explorer view --- .../static_src/wagtailadmin/js/explorer-menu.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wagtail/wagtailadmin/static_src/wagtailadmin/js/explorer-menu.js b/wagtail/wagtailadmin/static_src/wagtailadmin/js/explorer-menu.js index 0211a07ec8..7b837b0830 100644 --- a/wagtail/wagtailadmin/static_src/wagtailadmin/js/explorer-menu.js +++ b/wagtail/wagtailadmin/static_src/wagtailadmin/js/explorer-menu.js @@ -18,6 +18,15 @@ $(function() { $explorer.load($this.data('explorer-menu-url'), function() { $this.removeClass('icon-spinner'); + if ($explorer.find('.dl-menu li').length === 0) { + /* + AJAX fetch returned an empty dl-menu UL, i.e. no pages exist whatsoever. + Take the user directly to the page explorer view, since we aren't giving + them anything to click on to get there... + */ + document.location.href = $this.attr('href'); + } + $explorer.addClass('dl-menuwrapper').dlmenu({ animationClasses: { classin: 'dl-animate-in-2',