From: Tomas Sedovic <tsedovic(a)redhat.com>
This fixes
https://bugzilla.redhat.com/show_bug.cgi?id=693447
When the user attempted to delete a template that could not be deleted
(because it had instances associated with it), no error message was shown and
nothing happened.
This adds a feedback to the delete template action.
---
.../image_factory/templates_controller.rb | 15 ++++++++++++---
src/config/locales/en.yml | 11 +++++++++--
src/config/navigation.rb | 2 +-
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/app/controllers/image_factory/templates_controller.rb
b/src/app/controllers/image_factory/templates_controller.rb
index 88e075d..dc7ba71 100644
--- a/src/app/controllers/image_factory/templates_controller.rb
+++ b/src/app/controllers/image_factory/templates_controller.rb
@@ -185,13 +185,22 @@ class ImageFactory::TemplatesController < ApplicationController
end
def multi_destroy
+ destroyed = []
+ failed = []
Template.find(params[:selected]).each do |template|
- if check_privilege(Privilege::MODIFY, template)
- template.destroy
+ if check_privilege(Privilege::MODIFY, template) and template.destroy
+ destroyed << template.name
else
- flash[:error] = "You don't have a permission to delete."
+ failed << template.name
end
end
+
+ unless destroyed.empty?
+ flash[:notice] = t('templates.index.deleted', :count =>
destroyed.length, :list => destroyed.join(', '))
+ end
+ unless failed.empty?
+ flash[:error] = t('templates.index.not_deleted', :count =>
failed.length, :list => failed.join(', '))
+ end
redirect_to image_factory_templates_url
end
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 9cfe221..b8455bc 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -2,7 +2,6 @@ en:
dashboard: Dashboard
instances: Instances
users: Users
- templates: Templates
settings: Settings
about: About
configure: Configure
@@ -72,7 +71,6 @@ en:
instances: Instances
searches: Searches
image_factory: Image Factory
- templates: Templates
assemblies: Assemblies
template_collections: Template Collections
administration: Administration
@@ -95,6 +93,15 @@ en:
index:
deleted: "Deleted the following Pool Families: %{list}."
not_deleted: "Could not delete the following Pool Families: %{list}."
+ templates:
+ templates: Templates
+ index:
+ deleted:
+ one: "Template %{list} was deleted."
+ other: "Templates %{list} were deleted."
+ not_deleted:
+ one: "Template %{list} was not deleted."
+ other: "Templates %{list} were not deleted."
deployables:
index:
deployables: Deployables
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
index 21e1236..074f905 100644
--- a/src/config/navigation.rb
+++ b/src/config/navigation.rb
@@ -7,7 +7,7 @@ SimpleNavigation::Configuration.run do |navigation|
second_level.item :instances, t(:instances), resources_instances_path
end
first_level.item :image_factory, t(:image_factory), image_factory_templates_path,
:highlights_on => /\/image_factory/ do |second_level|
- second_level.item :templates, t(:templates), image_factory_templates_path
+ second_level.item :templates, t('templates.templates'),
image_factory_templates_path
second_level.item :assemblies, t(:assemblies), image_factory_assemblies_path
second_level.item :deployables, t('deployables.index.deployables'),
image_factory_deployables_path
second_level.item :image_imports, t(:image_imports),
new_image_factory_image_import_path