From 595e25a3467829e4098cce7259d557155f678610 Mon Sep 17 00:00:00 2001 From: Henriette Dinger Date: Tue, 9 Feb 2016 14:57:16 +0100 Subject: [PATCH] Add missing flash messages --- app/controllers/boards_controller.rb | 1 + app/controllers/groups_controller.rb | 1 + app/controllers/news_controller.rb | 1 + app/controllers/projects_controller.rb | 5 ++++- app/controllers/roles_controller.rb | 1 + app/controllers/wiki_controller.rb | 14 ++++++++++++-- config/locales/en.yml | 2 ++ 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 2126ca3f84..4bc0432360 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -135,6 +135,7 @@ class BoardsController < ApplicationController def destroy @board.destroy + flash[:notice] = l(:notice_successful_delete) redirect_to_settings_in_projects end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index a50ee5c096..03e3a6ddbf 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -111,6 +111,7 @@ class GroupsController < ApplicationController @group.destroy respond_to do |format| + flash[:notice] = l(:notice_successful_delete) format.html do redirect_to(groups_url) end format.xml do head :ok end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 01be79047f..9780a9ed33 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -95,6 +95,7 @@ class NewsController < ApplicationController def destroy @news.destroy + flash[:notice] = l(:notice_successful_delete) redirect_to action: 'index', project_id: @project end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5ebfa97456..8b13423cf2 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -227,7 +227,10 @@ class ProjectsController < ApplicationController OpenProject::Notifications.send('project_deletion_imminent', project: @project_to_destroy) @project_to_destroy.destroy respond_to do |format| - format.html do redirect_to controller: '/admin', action: 'projects' end + format.html do + flash[:notice] = l(:notice_successful_delete) + redirect_to controller: '/admin', action: 'projects' + end end hide_project_in_layout diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 5063a9d37d..8c776e4e75 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -89,6 +89,7 @@ class RolesController < ApplicationController def destroy @role = Role.find(params[:id]) @role.destroy + flash[:notice] = l(:notice_successful_delete) redirect_to action: 'index' notify_changed_roles(:removed, @role) rescue diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index d1138b8e2f..d2429fe609 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -182,7 +182,11 @@ class WikiController < ApplicationController # Creates a new page or updates an existing one def update @page = @wiki.find_or_new_page(wiki_page_title) - return render_403 unless editable? + unless editable? + flash[:error] = l(:error_unable_update_wiki) + return render_403 + end + @page.content = WikiContent.new(page: @page) if @page.new_record? @content = @page.content_for_version(params[:version]) @@ -205,6 +209,7 @@ class WikiController < ApplicationController attachments = Attachment.attach_files(@page, params[:attachments]) render_attachment_warning_if_needed(@page) call_hook(:controller_wiki_edit_after_save, params: params, page: @page) + flash[:notice] = l(:notice_successful_update) redirect_to_show else render action: 'edit' @@ -278,7 +283,10 @@ class WikiController < ApplicationController # Removes a wiki page and its history # Children can be either set as root pages, removed or reassigned to another parent page def destroy - return render_403 unless editable? + unless editable? + flash[:error] = l(:error_unable_delete_wiki) + return render_403 + end @descendants_count = @page.descendants.size if @descendants_count > 0 @@ -303,8 +311,10 @@ class WikiController < ApplicationController @page.destroy if page = @wiki.find_page(@wiki.start_page) || @wiki.pages.first + flash[:notice] = l(:notice_successful_delete) redirect_to action: 'index', project_id: @project, id: page else + flash[:notice] = l(:notice_successful_delete) redirect_to project_path(@project) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 48b77ddc42..a1cc84d8f5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -764,6 +764,8 @@ en: error_unable_delete_status: "The work package status cannot be deleted since it is used by at least one work package." error_unable_delete_default_status: "Unable to delete the default work package status. Please select another default work package status before deleting the current one." error_unable_to_connect: "Unable to connect (%{value})" + error_unable_delete_wiki: "Unable to delete the wiki page." + error_unable_update_wiki: "Unable to update the wiki page." error_workflow_copy_source: "Please select a source type or role" error_workflow_copy_target: "Please select target type(s) and role(s)" error_menu_item_not_created: Menu item could not be added