diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-24 22:48:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-24 22:48:25 +0300 |
commit | 62a9b70c609243218f68691efb1b9731ed5c9bc4 (patch) | |
tree | 5373e56fa9e3556304ce2f722ca4bcd0921b65f2 /app | |
parent | 43130a8389c6f3e3c392be8503d3187e34baf71d (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/wikis_controller.rb | 2 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 8 | ||||
-rw-r--r-- | app/views/projects/wikis/_sidebar.html.haml | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 90ff798077a..714aa42e52e 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -144,7 +144,7 @@ class Projects::WikisController < Projects::ApplicationController @sidebar_page = @project_wiki.find_sidebar(params[:version_id]) unless @sidebar_page # Fallback to default sidebar - @sidebar_wiki_entries = WikiPage.group_by_directory(@project_wiki.list_pages(limit: 15)) + @sidebar_wiki_entries, @sidebar_limited = @project_wiki.sidebar_entries end rescue ProjectWiki::CouldNotCreateWikiError flash[:notice] = _("Could not create Wiki Repository at this time. Please try again later.") diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 708b45cf5f0..dcef01c0c1f 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -114,6 +114,14 @@ class ProjectWiki end end + def sidebar_entries(limit: Gitlab::WikiPages::MAX_SIDEBAR_PAGES, **options) + pages = list_pages(**options.merge(limit: limit + 1)) + limited = pages.size > limit + pages = pages.first(limit) if limited + + [WikiPage.group_by_directory(pages), limited] + end + # Finds a page within the repository based on a tile # or slug. # diff --git a/app/views/projects/wikis/_sidebar.html.haml b/app/views/projects/wikis/_sidebar.html.haml index 0f2938686cc..2b8da83b126 100644 --- a/app/views/projects/wikis/_sidebar.html.haml +++ b/app/views/projects/wikis/_sidebar.html.haml @@ -17,6 +17,6 @@ %ul.wiki-pages = render @sidebar_wiki_entries, context: 'sidebar' .block.w-100 - - if @sidebar_wiki_entries&.length.to_i >= 15 + - if @sidebar_limited = link_to project_wikis_pages_path(@project), class: 'btn btn-block' do = s_("Wiki|View All Pages") |