From 2fc57217707632fd36199facd0df1d9f26a9d27e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Vilain Date: Tue, 9 Jul 2013 09:29:41 +0200 Subject: [PATCH] SONAR-4466 Fixed several display and labels issues --- .../main/resources/org/sonar/l10n/core.properties | 12 +++++++----- .../InternalPermissionTemplateService.java | 5 +++-- .../controllers/permission_templates_controller.rb | 2 +- .../app/views/permission_templates/index.html.erb | 4 ++-- .../InternalPermissionTemplateServiceTest.java | 8 ++++++++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 5f59adfa5af..ca77fe4f6ca 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -2247,16 +2247,18 @@ projects_role.codeviewer.desc=Ability to view the source code of the project. # PERMISSION TEMPLATES # #------------------------------------------------------------------------------ -permission_templates=Permission templates -permission_templates.page=Permission templates +permission_templates=Permission Templates +permission_templates.page=Permission Templates permission_template.new_template=New permission template -permission_template.create_template=Create permission template +permission_template.create_template=Create permission_template.delete_confirm_title=Delete permission template permission_template.do_you_want_to_delete_template=Are you sure that you want to delete this permission template? -permission_template.delete_template=Delete permission template +permission_template.delete_template=Delete permission_template.edit_template=Edit permission template +permission_template.update_template=Update permission_template.edit_permissions=Edit permissions -permission_template.update_permissions=Apply template changes +permission_template.update_permissions=Save +permission_template.no_results=No template to display #------------------------------------------------------------------------------ diff --git a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java index db518e31d63..306771b55ee 100644 --- a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java +++ b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java @@ -21,6 +21,7 @@ package org.sonar.server.permission; import com.google.common.collect.Lists; +import org.h2.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.ServerComponent; @@ -136,8 +137,8 @@ public class InternalPermissionTemplateService implements ServerComponent { } private void validateTemplateName(Long templateId, String templateName) { - if(templateName == null) { - String errorMsg = "The name field is mandatory"; + if(StringUtils.isNullOrEmpty(templateName)) { + String errorMsg = "Name can't be blank"; LOG.error(errorMsg); throw new BadRequestException(errorMsg); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/permission_templates_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/permission_templates_controller.rb index 299f3a9bad1..edc8624ef29 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/permission_templates_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/permission_templates_controller.rb @@ -140,7 +140,7 @@ class PermissionTemplatesController < ApplicationController def edit_form @permission_template = Internal.permission_templates.selectPermissionTemplate(params[:name]) render :partial => 'permission_templates/permission_template_form', - :locals => {:form_action => 'edit', :message_title => 'edit_template', :message_submit => 'edit_template'} + :locals => {:form_action => 'edit', :message_title => 'edit_template', :message_submit => 'update_template'} end # diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb index 187766f23a1..2a7ba3eeee5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb @@ -40,7 +40,7 @@ <% if @permission_templates.empty? %> - <%= message('no_results') %> + <%= message('permission_template.no_results') %> <% end %> <% @permission_templates.each do |permission_template| %> @@ -90,7 +90,7 @@ <%= link_to message('delete'), {:action => :delete_form, :name => permission_template.name}, - :id => "delete-template-#{u permission_template.name}", :class => 'open-modal link-action' %> + :id => "delete-template-#{u permission_template.name}", :class => 'open-modal link-action link-red' %> <% diff --git a/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java b/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java index 4d765bf4682..1ea834643af 100644 --- a/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java @@ -79,6 +79,14 @@ public class InternalPermissionTemplateServiceTest { permissionTemplateService.createPermissionTemplate(DEFAULT_NAME, DEFAULT_DESC); } + @Test + public void should_reject_empty_name_on_creation() throws Exception { + expected.expect(BadRequestException.class); + expected.expectMessage("Name can't be blank"); + + permissionTemplateService.createPermissionTemplate("", DEFAULT_DESC); + } + @Test public void should_delete_permission_template() throws Exception { when(permissionDao.selectTemplateByName(DEFAULT_NAME)).thenReturn(DEFAULT_TEMPLATE); -- 2.39.5