diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-07-06 22:21:08 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-07-07 00:19:10 +0300 |
commit | d195db17e9ff62c3dbfb8ba03dacadf965b1fb8b (patch) | |
tree | 58157f1909c4f04306d10be5b842f99a79f9b809 /app/models | |
parent | bb918a2fd98136c232baa34104c357f3716f8842 (diff) |
Don't show auxiliary blob viewer for README when there is no wiki
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/blob_viewer/readme.rb | 6 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/app/models/blob_viewer/readme.rb b/app/models/blob_viewer/readme.rb index 75c373a03bb..4604a9934a0 100644 --- a/app/models/blob_viewer/readme.rb +++ b/app/models/blob_viewer/readme.rb @@ -10,5 +10,11 @@ module BlobViewer def visible_to?(current_user) can?(current_user, :read_wiki, project) end + + def render_error + return if project.has_external_wiki? || (project.wiki_enabled? && project.wiki.has_home_page?) + + :no_wiki + end end end diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index beaadbbd1ab..dfca0031af8 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -63,6 +63,10 @@ class ProjectWiki !!repository.exists? end + def has_home_page? + !!find_page('home') + end + # Returns an Array of Gitlab WikiPage instances or an # empty Array if this Wiki has no pages. def pages |