summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-22 18:11:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-22 18:11:55 +0000
commit346ea4d53c1adf8b2e2d6eafbadc528eef5fd83a (patch)
treee8fedb430eb1888e4ba6af5f5fa79bc729a3e406 /app
parentf20364cefca2eebc958ce34fba46feeae9fdf59a (diff)
downloadgitlab-ce-346ea4d53c1adf8b2e2d6eafbadc528eef5fd83a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/concerns/wiki_actions.rb6
-rw-r--r--app/models/wiki.rb9
-rw-r--r--app/views/shared/empty_states/_wikis.html.haml3
-rw-r--r--app/views/shared/wikis/empty.html.haml10
4 files changed, 24 insertions, 4 deletions
diff --git a/app/controllers/concerns/wiki_actions.rb b/app/controllers/concerns/wiki_actions.rb
index 08604a15e8a..a007abacacc 100644
--- a/app/controllers/concerns/wiki_actions.rb
+++ b/app/controllers/concerns/wiki_actions.rb
@@ -55,6 +55,12 @@ module WikiActions
render 'shared/wikis/git_error'
end
+
+ rescue_from Gitlab::Git::Repository::NoRepository do
+ @error = _('Could not access the Wiki Repository at this time.')
+
+ render 'shared/wikis/empty'
+ end
end
def new
diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index da8be7304e8..39d22ea0e07 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -6,6 +6,7 @@ class Wiki
include Repositories::CanHousekeepRepository
include Gitlab::Utils::StrongMemoize
include GlobalID::Identification
+ include Gitlab::Git::WrapsGitalyErrors
extend ActiveModel::Naming
@@ -185,6 +186,8 @@ class Wiki
def has_home_page?
!!find_page(HOMEPAGE)
+ rescue StandardError
+ false
end
def empty?
@@ -413,7 +416,7 @@ class Wiki
end
def capture_git_error(action, &block)
- yield block
+ wrapped_gitaly_errors(&block)
rescue Gitlab::Git::Index::IndexError,
Gitlab::Git::CommitError,
Gitlab::Git::PreReceiveError,
@@ -491,7 +494,9 @@ class Wiki
escaped_path = RE2::Regexp.escape(sluggified_title(title))
path_regexp = Gitlab::EncodingHelper.encode_utf8_no_detect("(?i)^#{escaped_path}\\.(#{file_extension_regexp})$")
- matched_files = repository.search_files_by_regexp(path_regexp, version, limit: 1)
+ matched_files = capture_git_error(:find) do
+ repository.search_files_by_regexp(path_regexp, version, limit: 1)
+ end
return if matched_files.blank?
Gitlab::EncodingHelper.encode_utf8_no_detect(matched_files.first)
diff --git a/app/views/shared/empty_states/_wikis.html.haml b/app/views/shared/empty_states/_wikis.html.haml
index 8304a2f18a0..57f1c9d381e 100644
--- a/app/views/shared/empty_states/_wikis.html.haml
+++ b/app/views/shared/empty_states/_wikis.html.haml
@@ -1,7 +1,8 @@
- layout_path = 'shared/empty_states/wikis_layout'
- messages = wiki_empty_state_messages(@wiki)
+- hide_create = local_assigns[:hide_create]
-- if can?(current_user, :create_wiki, @wiki.container)
+- if !hide_create && can?(current_user, :create_wiki, @wiki.container)
- create_path = wiki_page_path(@wiki, params[:id], view: 'create')
- create_link = link_to s_('WikiEmpty|Create your first page'), create_path, class: 'btn gl-button btn-confirm', title: s_('WikiEmpty|Create your first page'), data: { qa_selector: 'create_first_page_link' }
diff --git a/app/views/shared/wikis/empty.html.haml b/app/views/shared/wikis/empty.html.haml
index c52ead74b4c..d30a37aaa3e 100644
--- a/app/views/shared/wikis/empty.html.haml
+++ b/app/views/shared/wikis/empty.html.haml
@@ -2,4 +2,12 @@
- @right_sidebar = false
- add_page_specific_style 'page_bundles/wiki'
-= render 'shared/empty_states/wikis'
+- if @error.present?
+ = render Pajamas::AlertComponent.new(alert_options: { id: 'error_explanation', class: 'gl-mb-3'},
+ dismissible: false,
+ variant: :danger) do |c|
+ = c.body do
+ %ul.gl-pl-4
+ = @error
+
+= render 'shared/empty_states/wikis', hide_create: @error.present?