diff options
Diffstat (limited to 'app/controllers/concerns/wiki_actions.rb')
-rw-r--r-- | app/controllers/concerns/wiki_actions.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/app/controllers/concerns/wiki_actions.rb b/app/controllers/concerns/wiki_actions.rb index 5b953fe37d6..5a5b634da40 100644 --- a/app/controllers/concerns/wiki_actions.rb +++ b/app/controllers/concerns/wiki_actions.rb @@ -93,9 +93,10 @@ module WikiActions def update return render('shared/wikis/empty') unless can?(current_user, :create_wiki, container) - @page = WikiPages::UpdateService.new(container: container, current_user: current_user, params: wiki_params).execute(page) + response = WikiPages::UpdateService.new(container: container, current_user: current_user, params: wiki_params).execute(page) + @page = response.payload[:page] - if page.valid? + if response.success? redirect_to( wiki_page_path(wiki, page), notice: _('Wiki was successfully updated.') @@ -103,7 +104,7 @@ module WikiActions else render 'shared/wikis/edit' end - rescue WikiPage::PageChangedError, WikiPage::PageRenameError, Gitlab::Git::Wiki::OperationError => e + rescue WikiPage::PageChangedError, WikiPage::PageRenameError => e @error = e render 'shared/wikis/edit' end @@ -120,13 +121,8 @@ module WikiActions notice: _('Wiki was successfully updated.') ) else - flash[:alert] = response.message render 'shared/wikis/edit' end - rescue Gitlab::Git::Wiki::OperationError => e - @page = build_page(wiki_params) - @error = e - render 'shared/wikis/edit' end # rubocop:enable Gitlab/ModuleWithInstanceVariables @@ -162,14 +158,18 @@ module WikiActions # rubocop:disable Gitlab/ModuleWithInstanceVariables def destroy - WikiPages::DestroyService.new(container: container, current_user: current_user).execute(page) + return render_404 unless page - redirect_to wiki_path(wiki), - status: :found, - notice: _("Page was successfully deleted") - rescue Gitlab::Git::Wiki::OperationError => e - @error = e - render 'shared/wikis/edit' + response = WikiPages::DestroyService.new(container: container, current_user: current_user).execute(page) + + if response.success? + redirect_to wiki_path(wiki), + status: :found, + notice: _("Page was successfully deleted") + else + @error = response + render 'shared/wikis/edit' + end end # rubocop:enable Gitlab/ModuleWithInstanceVariables |