diff options
Diffstat (limited to 'sonar-server/src')
159 files changed, 2771 insertions, 1450 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java index 542a58b6fa7..cc7722acad8 100644 --- a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java +++ b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java @@ -21,6 +21,8 @@ package org.sonar.server.filters; import com.google.common.collect.Lists; import com.google.common.collect.Sets; + +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.resources.Qualifiers; @@ -67,7 +69,7 @@ public class Filter { } else { this.rootSnapshotId = rootSnapshotId; } - this.baseSnapshotPath = snapshotPath; + this.baseSnapshotPath = StringUtils.defaultString(snapshotPath, ""); //With Oracle the path can be null (see SONAR-2582) this.isViewContext = isViewContext; return this; } @@ -77,7 +79,7 @@ public class Filter { } public boolean hasBaseSnapshot() { - return rootSnapshotId != null && baseSnapshotId != null && baseSnapshotPath != null; + return baseSnapshotId != null; } public Integer getBaseSnapshotId() { diff --git a/sonar-server/src/main/java/org/sonar/server/notifications/NotificationService.java b/sonar-server/src/main/java/org/sonar/server/notifications/NotificationService.java new file mode 100644 index 00000000000..ae4f45f507a --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/notifications/NotificationService.java @@ -0,0 +1,166 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.server.notifications; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.configuration.Configuration; +import org.sonar.api.ServerComponent; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; +import org.sonar.api.notifications.NotificationDispatcher; +import org.sonar.api.utils.Logs; +import org.sonar.api.utils.TimeProfiler; +import org.sonar.core.notifications.DefaultNotificationManager; +import org.sonar.jpa.entity.NotificationQueueElement; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.SetMultimap; +import com.google.common.collect.Sets; + +/** + * @since 2.10 + */ +public class NotificationService implements ServerComponent { + + private static final TimeProfiler TIME_PROFILER = new TimeProfiler(Logs.INFO).setLevelToDebug(); + + private static final String DELAY = "sonar.notifications.delay"; + private static final long DELAY_DEFAULT = 60; + + private ScheduledExecutorService executorService; + private long delay; + + private DefaultNotificationManager manager; + private NotificationChannel[] channels; + private NotificationDispatcher[] dispatchers; + + private boolean stopping = false; + + /** + * Default constructor when no channels. + */ + public NotificationService(Configuration configuration, DefaultNotificationManager manager, NotificationDispatcher[] dispatchers) { + this(configuration, manager, dispatchers, new NotificationChannel[0]); + Logs.INFO.warn("There is no channels - all notifications would be ignored!"); + } + + public NotificationService(Configuration configuration, DefaultNotificationManager manager, NotificationDispatcher[] dispatchers, NotificationChannel[] channels) { + delay = configuration.getLong(DELAY, DELAY_DEFAULT); + this.manager = manager; + this.channels = channels; + this.dispatchers = dispatchers; + } + + public void start() { + executorService = Executors.newSingleThreadScheduledExecutor(); + executorService.scheduleWithFixedDelay(new Runnable() { + public void run() { + processQueue(); + } + }, 0, delay, TimeUnit.SECONDS); + Logs.INFO.info("Notification service started (delay {} sec.)", delay); + } + + public void stop() { + try { + stopping = true; + executorService.awaitTermination(5, TimeUnit.SECONDS); + executorService.shutdown(); + } catch (InterruptedException e) { + Logs.INFO.error("Error during stop of notification service", e); + } + Logs.INFO.info("Notification service stopped"); + } + + /** + * Visibility has been relaxed for tests. + */ + void processQueue() { + TIME_PROFILER.start("Processing notifications queue"); + NotificationQueueElement queueElement = manager.getFromQueue(); + while (queueElement != null) { + deliver(queueElement.getNotification()); + if (stopping) { + break; + } + queueElement = manager.getFromQueue(); + } + TIME_PROFILER.stop(); + } + + /** + * Visibility has been relaxed for tests. + */ + void deliver(Notification notification) { + Logs.INFO.debug("Delivering notification " + notification); + SetMultimap<String, NotificationChannel> recipients = HashMultimap.create(); + for (NotificationChannel channel : channels) { + for (NotificationDispatcher dispatcher : dispatchers) { + final Set<String> possibleRecipients = Sets.newHashSet(); + NotificationDispatcher.Context context = new NotificationDispatcher.Context() { + public void addUser(String username) { + if (username != null) { + possibleRecipients.add(username); + } + } + }; + try { + dispatcher.dispatch(notification, context); + } catch (Exception e) { // catch all exceptions in order to dispatch using other dispatchers + Logs.INFO.warn("Unable to dispatch notification " + notification + " using " + dispatcher, e); + } + for (String username : possibleRecipients) { + if (manager.isEnabled(username, channel.getKey(), dispatcher.getKey())) { + recipients.put(username, channel); + } + } + } + } + for (Map.Entry<String, Collection<NotificationChannel>> entry : recipients.asMap().entrySet()) { + String username = entry.getKey(); + Collection<NotificationChannel> userChannels = entry.getValue(); + Logs.INFO.debug("For user {} via {}", username, userChannels); + for (NotificationChannel channel : userChannels) { + try { + channel.deliver(notification, username); + } catch (Exception e) { // catch all exceptions in order to deliver via other channels + Logs.INFO.warn("Unable to deliver notification " + notification + " for user " + username + " via " + channel, e); + } + } + } + } + + public List<NotificationDispatcher> getDispatchers() { + return Arrays.asList(dispatchers); + } + + public List<NotificationChannel> getChannels() { + return Arrays.asList(channels); + } + +} diff --git a/sonar-server/src/main/java/org/sonar/server/notifications/reviews/ReviewsNotificationManager.java b/sonar-server/src/main/java/org/sonar/server/notifications/reviews/ReviewsNotificationManager.java new file mode 100644 index 00000000000..80240c7bee7 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/notifications/reviews/ReviewsNotificationManager.java @@ -0,0 +1,72 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.server.notifications.reviews; + +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; +import org.sonar.api.ServerComponent; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationManager; + +import com.google.common.collect.Sets; + +/** + * @since 2.10 + */ +public class ReviewsNotificationManager implements ServerComponent { + + private NotificationManager notificationManager; + + public ReviewsNotificationManager(NotificationManager notificationManager) { + this.notificationManager = notificationManager; + } + + /** + * @param reviewId reviewId id of review, which was modified + * @param author author of change (username) + * @param oldValues map of old values + * @param newValues map of new values + */ + public void notifyChanged(Long reviewId, String author, Map<String, String> oldValues, Map<String, String> newValues) { + Notification notification = new Notification("review-changed") + .setFieldValue("reviewId", String.valueOf(reviewId)) + .setFieldValue("project", newValues.get("project")) + .setFieldValue("resource", newValues.get("resource")) + .setFieldValue("title", newValues.get("title")) + .setFieldValue("author", author) + .setFieldValue("creator", newValues.get("creator")) + .setFieldValue("assignee", newValues.get("assignee")); + Set<String> fields = Sets.newHashSet(); + fields.addAll(oldValues.keySet()); + fields.addAll(newValues.keySet()); + for (String field : fields) { + String oldValue = oldValues.get(field); + String newValue = newValues.get(field); + if ( !StringUtils.equals(oldValue, newValue)) { + notification.setFieldValue("new." + field, newValue); + notification.setFieldValue("old." + field, oldValue); + } + } + notificationManager.scheduleForSending(notification); + } + +} diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 3f3ee2f382c..6835c7f69dd 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -40,7 +40,14 @@ import org.sonar.api.utils.TimeProfiler; import org.sonar.core.components.DefaultMetricFinder; import org.sonar.core.components.DefaultModelFinder; import org.sonar.core.components.DefaultRuleFinder; -import org.sonar.jpa.dao.*; +import org.sonar.core.components.DefaultUserFinder; +import org.sonar.core.i18n.I18nManager; +import org.sonar.core.i18n.RuleI18nManager; +import org.sonar.core.notifications.DefaultNotificationManager; +import org.sonar.jpa.dao.DaoFacade; +import org.sonar.jpa.dao.MeasuresDao; +import org.sonar.jpa.dao.ProfilesDao; +import org.sonar.jpa.dao.RulesDao; import org.sonar.jpa.session.DatabaseSessionFactory; import org.sonar.jpa.session.DatabaseSessionProvider; import org.sonar.jpa.session.ThreadLocalDatabaseSessionFactory; @@ -52,9 +59,12 @@ import org.sonar.server.database.EmbeddedDatabaseFactory; import org.sonar.server.database.JndiDatabaseConnector; import org.sonar.server.filters.FilterExecutor; import org.sonar.server.mavendeployer.MavenRepository; +import org.sonar.server.notifications.NotificationService; +import org.sonar.server.notifications.reviews.ReviewsNotificationManager; import org.sonar.server.plugins.*; import org.sonar.server.qualitymodel.DefaultModelManager; -import org.sonar.server.rules.*; +import org.sonar.server.rules.ProfilesConsole; +import org.sonar.server.rules.RulesConsole; import org.sonar.server.startup.*; import org.sonar.server.ui.AuthenticatorFactory; import org.sonar.server.ui.CodeColorizers; @@ -162,11 +172,9 @@ public final class Platform { servicesContainer.as(Characteristics.NO_CACHE).addComponent(MeasuresDao.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(org.sonar.api.database.daos.MeasuresDao.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(ProfilesDao.class); - servicesContainer.as(Characteristics.NO_CACHE).addComponent(AsyncMeasuresDao.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(DaoFacade.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(DefaultRulesManager.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(ProfilesManager.class); - servicesContainer.as(Characteristics.NO_CACHE).addComponent(AsyncMeasuresService.class); servicesContainer.as(Characteristics.NO_CACHE).addComponent(Backup.class); servicesContainer.as(Characteristics.CACHE).addComponent(AuthenticatorFactory.class); servicesContainer.as(Characteristics.CACHE).addComponent(ServerLifecycleNotifier.class); @@ -180,6 +188,14 @@ public final class Platform { servicesContainer.as(Characteristics.CACHE).addComponent(ProfilesConsole.class); servicesContainer.as(Characteristics.CACHE).addComponent(RulesConsole.class); servicesContainer.as(Characteristics.CACHE).addComponent(JRubyI18n.class); + servicesContainer.as(Characteristics.CACHE).addComponent(DefaultUserFinder.class); + servicesContainer.as(Characteristics.CACHE).addComponent(I18nManager.class); + servicesContainer.as(Characteristics.CACHE).addComponent(RuleI18nManager.class); + + // Notifications + servicesContainer.as(Characteristics.CACHE).addComponent(NotificationService.class); + servicesContainer.as(Characteristics.CACHE).addComponent(DefaultNotificationManager.class); + servicesContainer.as(Characteristics.CACHE).addComponent(ReviewsNotificationManager.class); servicesContainer.start(); } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 7e1e99c67cc..df520e59ad2 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -32,7 +32,7 @@ import org.sonar.api.rules.RulePriority; import org.sonar.api.rules.RuleRepository; import org.sonar.api.utils.ValidationMessages; import org.sonar.api.web.*; -import org.sonar.jpa.dao.AsyncMeasuresService; +import org.sonar.core.i18n.RuleI18nManager; import org.sonar.jpa.dialect.Dialect; import org.sonar.jpa.session.DatabaseConnector; import org.sonar.markdown.Markdown; @@ -42,6 +42,7 @@ import org.sonar.server.configuration.ProfilesManager; import org.sonar.server.filters.Filter; import org.sonar.server.filters.FilterExecutor; import org.sonar.server.filters.FilterResult; +import org.sonar.server.notifications.reviews.ReviewsNotificationManager; import org.sonar.server.platform.Platform; import org.sonar.server.plugins.*; import org.sonar.server.rules.ProfilesConsole; @@ -261,22 +262,10 @@ public final class JRubyFacade { return getContainer().getComponent(Backup.class); } - public void registerAsyncMeasure(long asyncMeasureId) { - getAsyncMeasuresService().registerMeasure(asyncMeasureId); - } - - public void deleteAsyncMeasure(long asyncMeasureId) { - getAsyncMeasuresService().deleteMeasure(asyncMeasureId); - } - private ProfilesManager getProfilesManager() { return getContainer().getComponent(ProfilesManager.class); } - private AsyncMeasuresService getAsyncMeasuresService() { - return getContainer().getComponent(AsyncMeasuresService.class); - } - public void reloadConfiguration() { getContainer().getComponent(CoreConfiguration.class).reload(); } @@ -314,13 +303,45 @@ public final class JRubyFacade { return component; } - public String getI18nMessage(String rubyLocale, String key, String defaultValue, Object... parameters) { + public String getMessage(String rubyLocale, String key, String defaultValue, Object... parameters) { if (i18n == null) { i18n = getContainer().getComponent(JRubyI18n.class); } return i18n.message(rubyLocale, key, defaultValue, parameters); } + public String getRuleName(String rubyLocale, String repositoryKey, String key) { + if (i18n == null) { + i18n = getContainer().getComponent(JRubyI18n.class); + } + return i18n.getRuleName(rubyLocale, repositoryKey, key); + } + + public String getRuleDescription(String rubyLocale, String repositoryKey, String key) { + if (i18n == null) { + i18n = getContainer().getComponent(JRubyI18n.class); + } + return i18n.getRuleDescription(rubyLocale, repositoryKey, key); + } + + public String getRuleParamDescription(String rubyLocale, String repositoryKey, String key, String paramKey) { + if (i18n == null) { + i18n = getContainer().getComponent(JRubyI18n.class); + } + return i18n.getRuleParamDescription(rubyLocale, repositoryKey, key, paramKey); + } + + public List<RuleI18nManager.RuleKey> searchRuleName(String rubyLocale, String searchText) { + if (i18n == null) { + i18n = getContainer().getComponent(JRubyI18n.class); + } + return i18n.searchRuleName(rubyLocale, searchText); + } + + public ReviewsNotificationManager getReviewsNotificationManager() { + return getContainer().getComponent(ReviewsNotificationManager.class); + } + public PicoContainer getContainer() { return Platform.getInstance().getContainer(); } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java index 72a1d0e39a0..077556d67b3 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java @@ -23,7 +23,9 @@ import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.sonar.api.ServerComponent; import org.sonar.api.i18n.I18n; +import org.sonar.core.i18n.RuleI18nManager; +import java.util.List; import java.util.Locale; import java.util.Map; @@ -33,10 +35,12 @@ import java.util.Map; public final class JRubyI18n implements ServerComponent { private I18n i18n; - private Map<String,Locale> localesByRubyKey = Maps.newHashMap(); + private Map<String, Locale> localesByRubyKey = Maps.newHashMap(); + private RuleI18nManager ruleI18nManager; - public JRubyI18n(I18n i18n) { + public JRubyI18n(I18n i18n, RuleI18nManager ruleI18nManager) { this.i18n = i18n; + this.ruleI18nManager = ruleI18nManager; } Locale getLocale(String rubyKey) { @@ -55,7 +59,7 @@ public final class JRubyI18n implements ServerComponent { static Locale toLocale(String rubyKey) { Locale locale; String[] fields = StringUtils.split(rubyKey, "-"); - if (fields.length==1) { + if (fields.length == 1) { locale = new Locale(fields[0]); } else { locale = new Locale(fields[0], fields[1]); @@ -66,4 +70,20 @@ public final class JRubyI18n implements ServerComponent { public String message(String rubyLocale, String key, String defaultValue, Object... parameters) { return i18n.message(getLocale(rubyLocale), key, defaultValue, parameters); } + + public String getRuleName(String rubyLocale, String repositoryKey, String key) { + return ruleI18nManager.getName(repositoryKey, key, toLocale(rubyLocale)); + } + + public String getRuleDescription(String rubyLocale, String repositoryKey, String key) { + return ruleI18nManager.getDescription(repositoryKey, key, toLocale(rubyLocale)); + } + + public String getRuleParamDescription(String rubyLocale, String repositoryKey, String ruleKey, String paramKey) { + return ruleI18nManager.getParamDescription(repositoryKey, ruleKey, paramKey, toLocale(rubyLocale)); + } + + public List<RuleI18nManager.RuleKey> searchRuleName(String rubyLocale, String searchText) { + return ruleI18nManager.searchNames(searchText, toLocale(rubyLocale)); + } } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/SonarRackFilter.java b/sonar-server/src/main/java/org/sonar/server/ui/SonarRackFilter.java deleted file mode 100644 index e29fd9cd442..00000000000 --- a/sonar-server/src/main/java/org/sonar/server/ui/SonarRackFilter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.server.ui; - -import org.apache.commons.lang.StringUtils; -import org.jruby.rack.RackFilter; - -import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; - -public class SonarRackFilter extends RackFilter { - - private Set<String> exclusions; - - @Override - public void init(FilterConfig config) throws ServletException { - super.init(config); - String[] exclusionsStr = StringUtils.split(config.getInitParameter("exclusions"), ','); - exclusions = new HashSet<String>(Arrays.asList(exclusionsStr)); - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - HttpServletRequest httpRequest = (HttpServletRequest)request; - String requestURI = httpRequest.getRequestURI(); - int extIndex = requestURI.lastIndexOf('.'); - String fileExtension = extIndex != -1 ? requestURI.substring(extIndex + 1, requestURI.length()) : null; - if (fileExtension == null || !exclusions.contains(fileExtension)) { - super.doFilter(request, response, chain); - } else { - chain.doFilter(request, response); - } - } - -} diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb index 340ce2bfc3a..807b9bb79d6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/account_controller.rb @@ -24,7 +24,13 @@ class AccountController < ApplicationController before_filter :login_required def index - + notification_service = java_facade.getCoreComponentByClassname('org.sonar.server.notifications.NotificationService') + @channels = notification_service.getChannels() + @dispatchers = notification_service.getDispatchers() + @notifications = {} + for property in Property.find(:all, :conditions => ['prop_key like ? AND user_id = ?', 'notification.%', current_user.id]) + @notifications[property.key.sub('notification.', '')] = true + end end def change_password @@ -47,4 +53,12 @@ class AccountController < ApplicationController end redirect_to :controller => 'account', :action => 'index' end + + def update_notifications + notifications = params[:notifications] + Property.delete_all(['prop_key like ? AND user_id = ?', 'notification.%', current_user.id]) + notifications.each_key { |key| current_user.set_property(:prop_key => 'notification.' + key, :text_value => 'true') } unless notifications.nil? + redirect_to :action => 'index' + end + end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb index 19bc6c75c92..577e19659de 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/alerts_controller.rb @@ -86,7 +86,7 @@ class AlertsController < ApplicationController respond_to do |format| if @alert.save - flash[:notice] = 'Alert is created.' + flash[:notice] = message('alert.alert_created') format.html { redirect_to :action => 'index', :id=>@profile.id } format.js { render :update do |page| page.redirect_to :action => 'index', :id=>@profile.id @@ -116,7 +116,7 @@ class AlertsController < ApplicationController respond_to do |format| if alert.update_attributes(params[:alert]) - flash[:notice] = 'Alert is updated.' + flash[:notice] = message('alert.alert_updated') format.html { redirect_to :action => 'index', :id=>@profile.id } format.xml { head :ok } format.js { render :update do |page| page.redirect_to :action => 'index', :id=>@profile.id end} @@ -140,7 +140,7 @@ class AlertsController < ApplicationController @profile = Profile.find(params[:profile_id]) @alert = @profile.alerts.find(params[:id]) @alert.destroy - flash[:notice] = 'Alert is deleted.' + flash[:notice] = message('alert.alert_deleted') respond_to do |format| format.html { redirect_to(:action => 'index', :id=>@profile.id) } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb index 594635c62a1..f1e0100884c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb @@ -20,42 +20,93 @@ require 'json' require 'time' class Api::ApiController < ApplicationController - - protected - + + class ApiException < Exception + attr_reader :code, :msg + + def initialize(code, msg) + @code = code + @msg = msg + end + end + + rescue_from ApiException do |exception| + render_error(exception.msg, exception.code) + end + + rescue_from ActiveRecord::RecordInvalid do |exception| + render_error(exception.message, 400) + end + + rescue_from ActiveRecord::RecordNotFound do |exception| + render_error(exception.message, 404) + end + + protected + def text_not_supported "Not supported" end - + def xml_not_supported xml = Builder::XmlMarkup.new(:indent => 0) xml.instruct! xml.not_supported end - + def json_not_supported JSON({:not_supported => true}) end - + def jsonp(json) - text=( (json.is_a? String) ? json : JSON(json)) - + text=((json.is_a? String) ? json : JSON(json)) + if params['callback'] - params['callback'] + '(' + text + ');' + params['callback'] + '(' + text + ');' else text end end - + + # deprecated. Use Api::Utils.format_datetime + def format_datetime(datetime) + Api::Utils.format_datetime(datetime) + end + + # deprecated. Use Api::Utils.parse_datetime + def parse_datetime(datetime_string, default_is_now=true) + Api::Utils.parse_datetime(datetime_string, default_is_now) + end + + def load_resource(resource_key, role=nil) + resource=Project.by_key(resource_key) + not_found("Resource not found: #{resource_key}") if resource.nil? + access_denied if role && !has_role?(role, resource) + resource + end + + + + #---------------------------------------------------------------------------- + # ERRORS + #---------------------------------------------------------------------------- + def not_found(message) + raise ApiException.new(404, message) + end + + def bad_request(message) + raise ApiException.new(400, message) + end + def access_denied - render_error('Unauthorized', 401) + raise ApiException.new(401, 'Unauthorized') end - + def render_error(msg, http_status=400) - respond_to do |format| - format.json{ render :json => error_to_json(msg, http_status), :status => http_status } - format.xml{ render :xml => error_to_xml(msg, http_status), :status => http_status} - format.text{ render :text => msg, :status => http_status } + respond_to do |format| + format.json { render :json => error_to_json(msg, http_status), :status => http_status } + format.xml { render :xml => error_to_xml(msg, http_status), :status => http_status } + format.text { render :text => msg, :status => http_status } end end @@ -68,7 +119,7 @@ class Api::ApiController < ApplicationController def error_to_xml(msg, error_code=nil) xml = Builder::XmlMarkup.new(:indent => 0) - xml.error do + xml.error do xml.code(error_code) if error_code xml.msg(msg) if msg end @@ -78,23 +129,5 @@ class Api::ApiController < ApplicationController render_error(msg, 200) end - # deprecated. Use Api::Utils.format_datetime - def format_datetime(datetime) - Api::Utils.format_datetime(datetime) - end - - # deprecated. Use Api::Utils.parse_datetime - def parse_datetime(datetime_string, default_is_now=true) - Api::Utils.parse_datetime(datetime_string, default_is_now) - end - - class ApiException < Exception - attr_reader :code, :msg - def initialize(code, msg) - @code = code - @msg = msg - end - end - end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb index afc773baa48..8f842296cb4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb @@ -43,6 +43,7 @@ class Api::EventsController < Api::ApiController conditions<<'resource_id IS NULL' end + from=nil if params[:fromDateTime] from=parse_datetime(params[:fromDateTime], false) elsif params[:fromDate] @@ -53,6 +54,7 @@ class Api::EventsController < Api::ApiController values[:from]=from end + to=nil if params[:toDateTime] to=parse_datetime(params[:toDateTime], false) elsif params[:toDate] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb new file mode 100644 index 00000000000..6e3d13734c5 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb @@ -0,0 +1,115 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +require 'json' + +class Api::ManualMeasuresController < Api::ApiController + + # + # GET /api/manual_measures?resource=<resource>&metric=<optional metric> + # + def index + resource=load_resource(params[:resource], :user) + + metric=nil + if params[:metric].present? + metric=Metric.by_key(params[:metric]) + bad_request("Unknown metric: #{params[:metric]}") if metric.nil? + end + + result = resource.manual_measures + if metric + result = result.select{|m| m.metric_id==metric.id} + end + + respond_to do |format| + format.json { render :json => jsonp(manual_measures_to_json(resource, result)) } + format.xml { render :xml => xml_not_supported } + end + end + + # + # POST /api/manual_measures?resource=<resource>&metric=<metric>&val=<optional decimal value>&text=<optional text> + # Create or update measure. + # + def create + resource=load_resource(params[:resource], :admin) + + metric=Metric.by_key(params[:metric]) + bad_request("Unknown metric: #{params[:metric]}") if metric.nil? + + value=params[:val] + bad_request("Not a numeric value: #{value}") if value && !Api::Utils.is_number?(value) + + measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', resource.id, metric.id]) + if measure.nil? + measure=ManualMeasure.new(:resource => resource, :user_login => current_user.login, :metric_id => metric.id) + end + + measure.value = value + measure.text_value = params[:text] + measure.description = params[:desc] + measure.save! + + respond_to do |format| + format.json { render :json => jsonp(manual_measures_to_json(resource, [measure])) } + format.xml { render :xml => xml_not_supported } + end + end + + + # + # DELETE /api/manual_measures?resource=<resource>&metric=<metric> + # + def destroy + resource=load_resource(params[:resource], :admin) + + metric=Metric.by_key(params[:metric]) + bad_request("Unknown metric: #{params[:metric]}") if metric.nil? + + count = ManualMeasure.delete_all(['resource_id=? and metric_id=?', resource.id, metric.id]) + + render_success "Deleted #{count} measures" + end + + private + + def manual_measures_to_json(resource, manual_measures) + json = [] + manual_measures.each do |m| + json<<manual_measure_to_json(resource, m) + end + json + end + + def manual_measure_to_json(resource, manual_measure) + hash={:id => manual_measure.id, :metric => manual_measure.metric.key, :resource => resource.key} + hash[:val]=manual_measure.value if manual_measure.value + hash[:text]=manual_measure.text_value if manual_measure.text_value + hash[:desc]=manual_measure.description if manual_measure.description + hash[:created_at]=format_datetime(manual_measure.created_at) + hash[:updated_at]=format_datetime(manual_measure.updated_at) if manual_measure.updated_at + if manual_measure.user + hash[:login]=manual_measure.user_login + hash[:username]=manual_measure.user.name + end + hash + end +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index dd852589a53..bfbef413a76 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -88,11 +88,11 @@ class Api::ResourcesController < Api::ApiController load_measures=true if params['metrics']!='true' - metrics=Metric.by_keys(params[:metrics].split(',')) - measures_conditions <<'project_measures.metric_id IN (:metrics)' + metrics = Metric.by_keys(params[:metrics].split(',')) + measures_conditions << 'project_measures.metric_id IN (:metrics)' measures_values[:metrics]=metrics.select{|m| m.id} if metrics.size==1 - measures_limit = [params[:limit].to_i,500].min if params[:limit] + measures_limit = (params[:limit] ? [params[:limit].to_i,500].min : 500) measures_order = "project_measures.value #{'DESC' if metrics.first.direction<0}" end end @@ -112,9 +112,10 @@ class Api::ResourcesController < Api::ApiController measures_by_sid[measure.snapshot_id]<<measure end - if measures_limit && !measures.empty? + if measures_limit snapshots_conditions << 'snapshots.id IN (:sids)' - snapshots_values[:sids]=measures_by_sid.keys + # Derby does not support empty lists, that's why a fake value is set + snapshots_values[:sids] = (measures_by_sid.empty? ? [-1] : measures_by_sid.keys) end # load coding rules diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb index b75d8a1048b..be8d1ddcfbd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb @@ -99,7 +99,7 @@ class Api::ReviewsController < Api::ApiController review.set_false_positive(true, :user => current_user, :text => comment, :violation_id => violation_id) elsif resolution == 'FIXED' review.create_comment(:user => current_user, :text => comment) - review.resolve + review.resolve(current_user) else raise "Incorrect resolution." end @@ -176,7 +176,7 @@ class Api::ReviewsController < Api::ApiController user = find_user(assignee) raise "Assignee not found." unless user end - review.reassign(user) + review.reassign(current_user, user) end render_reviews([review], params[:output] == 'HTML') rescue ApiException => e @@ -215,7 +215,7 @@ class Api::ReviewsController < Api::ApiController review.set_false_positive(true, :user => current_user, :text => comment) elsif resolution == 'FIXED' review.create_comment(:user => current_user, :text => comment) unless comment.blank? - review.resolve + review.resolve(current_user) else raise "Incorrect resolution." end @@ -253,7 +253,7 @@ class Api::ReviewsController < Api::ApiController raise "Comment must be provided." unless comment && !comment.blank? review.set_false_positive(false, :user => current_user, :text => comment) else - review.reopen + review.reopen(current_user) review.create_comment(:user => current_user, :text => comment) unless comment.blank? end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb index af52d5bf243..9e8ff5e686b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb @@ -94,4 +94,10 @@ class ApplicationController < ActionController::Base return access_denied end end + + # i18n + def message(key, options={}) + Api::Utils.message(key, options) + end + end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb index f70f303af8b..8a68161aaeb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb @@ -105,7 +105,6 @@ class ComponentsController < ApplicationController 'rule_id' => nil, 'rule_priority' => nil, 'characteristic_id' => nil})) - measures.concat(AsyncMeasureSnapshot.search(page_sids, mids)) end measures else diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/email_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/email_configuration_controller.rb new file mode 100644 index 00000000000..5982b704372 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/email_configuration_controller.rb @@ -0,0 +1,69 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# +class EmailConfigurationController < ApplicationController + + SECTION=Navigation::SECTION_CONFIGURATION + before_filter :admin_required + + def index + @smtp_host = Property.value(configuration::SMTP_HOST, nil, configuration::SMTP_HOST_DEFAULT) + @smtp_port = Property.value(configuration::SMTP_PORT, nil, configuration::SMTP_PORT_DEFAULT) + @smtp_secure_connection = Property.value(configuration::SMTP_SECURE_CONNECTION, nil, configuration::SMTP_SECURE_CONNECTION) + @smtp_username = Property.value(configuration::SMTP_USERNAME, nil, configuration::SMTP_USERNAME_DEFAULT) + @smtp_password = Property.value(configuration::SMTP_PASSWORD, nil, configuration::SMTP_PASSWORD_DEFAULT) + @email_from = Property.value(configuration::FROM, nil, configuration::FROM_DEFAULT) + @email_prefix = Property.value(configuration::PREFIX, nil, configuration::PREFIX_DEFAULT) + end + + def save + Property.set(configuration::SMTP_HOST, params[:smtp_host]) + Property.set(configuration::SMTP_PORT, params[:smtp_port]) + Property.set(configuration::SMTP_SECURE_CONNECTION, params[:smtp_secure_connection]) + Property.set(configuration::SMTP_USERNAME, params[:smtp_username]) + Property.set(configuration::SMTP_PASSWORD, params[:smtp_password]) + Property.set(configuration::FROM, params[:email_from]) + Property.set(configuration::PREFIX, params[:email_prefix]) + redirect_to :action => 'index' + end + + def send_test_email + to_address = params[:to_address] + subject = params[:subject] + message = params[:message] + if to_address.blank? + flash[:error] = message('email_configuration.test.to_address_required') + else + begin + java_facade.getComponentByClassname('emailnotifications', 'org.sonar.plugins.emailnotifications.EmailNotificationChannel').sendTestEmail(to_address, subject, message) + flash[:notice] = message('email_configuration.test.email_was_sent_to_x', :params => [to_address]) + rescue Exception => e + flash[:error] = e.message + end + end + redirect_to :action => 'index' + end + + private + + def configuration + java_facade.getComponentByClassname('emailnotifications', 'org.sonar.plugins.emailnotifications.EmailConfiguration').class + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb new file mode 100644 index 00000000000..b7d85bac951 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb @@ -0,0 +1,79 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# +class ManualMeasuresController < ApplicationController + + SECTION=Navigation::SECTION_RESOURCE + before_filter :load_resource + verify :method => :post, :only => [:save, :delete], :redirect_to => {:action => :index} + helper MetricsHelper + + def index + load_measures() + end + + def new + if params[:metric].present? + @metric=Metric.by_key(params[:metric]) + @measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', @resource.id, @metric.id]) || ManualMeasure.new + else + @metric=nil + @measure=nil + end + end + + def save + @metric=Metric.by_key(params[:metric]) + @measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', @resource.id, @metric.id]) + if @measure.nil? + @measure=ManualMeasure.new(:resource => @resource, :user_login => current_user.login, :metric_id => @metric.id) + end + @measure.typed_value=params[:val] + @measure.description=params[:desc] + if @measure.valid? + @measure.save + if (params[:redirect_to_new]=='true') + redirect_to :action => 'new', :id => params[:id] + else + redirect_to :action => 'index', :id => params[:id], :metric => params[:metric] + end + else + render :action => :new, :metric => @metric.id, :id => params[:id] + end + end + + def delete + metric=Metric.by_key(params[:metric]) + ManualMeasure.destroy_all(['resource_id=? and metric_id=?', @resource.id, metric.id]) + redirect_to :action => 'index', :id => params[:id], :metric => params[:metric] + end + + private + + def load_resource + @resource=Project.by_key(params[:id]) + return redirect_to home_path unless @resource + return access_denied unless has_role?(:admin, @resource) + @snapshot=@resource.last_snapshot + end + + def load_measures + @measures=ManualMeasure.find(:all, :conditions => ['resource_id=?', @resource.id]).select { |m| m.metric.enabled } + end +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb index d206ed13d0b..435943a7b61 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/metrics_controller.rb @@ -26,10 +26,10 @@ class MetricsController < ApplicationController def index @metrics = Metric.all.select {|metric| metric.user_managed?} - @domains = Metric.all.map {|metric| metric.domain}.compact.uniq.sort + @domains = Metric.all.map {|metric| metric.domain(false)}.compact.uniq.sort if params['id'] @metric=Metric.find(params['id'].to_i) - params['domain']=@metric.domain + params['domain']=@metric.domain(false) else @metric=Metric.new end @@ -44,8 +44,8 @@ class MetricsController < ApplicationController end metric.attributes=params[:metric] - if metric.short_name - metric.name = metric.short_name.downcase.gsub(/\s/, '_')[0..59] + if metric.short_name(false) + metric.name = metric.short_name(false).downcase.gsub(/\s/, '_')[0..59] end unless params[:newdomain].blank? metric.domain = params[:newdomain] @@ -67,13 +67,12 @@ class MetricsController < ApplicationController rescue flash[:error] = metric.errors.full_messages.join("<br/>\n") end - redirect_to :action => 'index', :domain => metric.domain + redirect_to :action => 'index', :domain => metric.domain(false) end def delete_from_web metric = Metric.by_id(params[:id].to_i) if params[:id] && params[:id].size > 0 if metric - AsyncMeasureSnapshot.delete_all("metric_id = #{metric.id}") del_count = Metric.delete(params[:id].to_i) flash[:notice] = 'Successfully deleted.' if del_count == 1 flash[:error] = 'Unable to delete this metric.' if del_count != 1 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index 7cab30c34d5..07083be7d88 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -56,11 +56,11 @@ class ProfilesController < ApplicationController profile_name=params[:name] language=params[:language] if profile_name.blank?|| language.blank? - flash[:warning]='Please type a profile name.' + flash[:warning]=message('quality_profiles.please_type_profile_name') else profile=Profile.find_by_name_and_language(profile_name, language) if profile - flash[:error]="This profile already exists: #{profile_name}" + flash[:error]=message('quality_profiles.profile_x_already_exists', :params => profile_name) else profile = Profile.create(:name => profile_name, :language => language, :default_profile => false, :enabled => true) @@ -75,7 +75,7 @@ class ProfilesController < ApplicationController end end if ok - flash[:notice]= "Profile '#{profile.name}' created. Set it as default or link it to a project to use it for next measures." + flash[:notice]=message('quality_profiles.profile_x_created', :params => profile.name) else profile.reload profile.destroy @@ -95,7 +95,7 @@ class ProfilesController < ApplicationController @profile = Profile.find(params[:id]) if @profile && @profile.deletable? java_facade.deleteProfile(@profile.id) - flash[:notice]="Profile '#{@profile.name}' is deleted." + flash[:notice]=message('quality_profiles.profile_x_deleted', :params => @profile.name) end redirect_to(:controller => 'profiles', :action => 'index') end @@ -109,7 +109,7 @@ class ProfilesController < ApplicationController def set_as_default profile = Profile.find(params[:id]) profile.set_as_default - flash[:notice]="Default profile is '#{profile.name}'." + flash[:notice]=message('quality_profiles.default_profile_is_x', :params => profile.name) redirect_to :action => 'index' end @@ -127,7 +127,7 @@ class ProfilesController < ApplicationController validation_errors = profile.validate_copy(name) if validation_errors.empty? java_facade.copyProfile(profile.id, name) - flash[:notice]= "Profile '#{name}' is created but not activated." + flash[:notice]= message('quality_profiles.profile_x_not_activated', :params => name) else flash[:error] = validation_errors.full_messages.first end @@ -158,7 +158,7 @@ class ProfilesController < ApplicationController # def restore if params[:backup].blank? - flash[:warning]='Please upload a backup file.' + flash[:warning]=message('quality_profiles.please_upload_backup_file') else messages=java_facade.restoreProfile(read_file_param(params[:backup])) flash_validation_messages(messages) @@ -194,7 +194,7 @@ class ProfilesController < ApplicationController @profile = Profile.find(params[:id]) profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?) and enabled=?', @profile.language, @profile.id, @profile.name, true], :order => 'name') - @select_parent = [['None', nil]] + profiles.collect{ |profile| [profile.name, profile.name] } + @select_parent = [[message('none'), nil]] + profiles.collect{ |profile| [profile.name, profile.name] } end # @@ -225,7 +225,7 @@ class ProfilesController < ApplicationController end @changes = ActiveRuleChange.find(:all, :conditions => ['profile_id=? and ?<profile_version and profile_version<=?', @profile.id, @since_version, @to_version], :order => 'id desc') - @select_versions = versions.map {|u| [ (u.profile_version == last_version ? "last " : "" ) + "version " + u.profile_version.to_s + " (" + l(u.change_date) + ")", u.profile_version]} | [["no version", 0]]; + @select_versions = versions.map {|u| [ message(u.profile_version == last_version ? 'quality_profiles.last_version_x_with_date' : 'quality_profiles.version_x_with_date', :params => [u.profile_version.to_s, l(u.change_date)]) ]} | [[message('quality_profiles.no_version'), 0]]; end end @@ -285,7 +285,7 @@ class ProfilesController < ApplicationController projects=Project.find(params[:projects] || []) @profile.projects=projects - flash[:notice]="Profile '#{@profile.name}' associated to #{projects.size} projects." + flash[:notice]=message('quality_profiles.profile_x_associated_to_x_projects', :params => [@profile.name, projects.size]) redirect_to :action => 'projects', :id => @profile.id end @@ -301,11 +301,11 @@ class ProfilesController < ApplicationController name = params['rename_' + profile.id.to_s] if name.blank? - flash[:warning]='Profile name can not be blank.' + flash[:warning]=message('quality_profiles.profile_name_cant_be_blank') else existing=Profile.find(:first, :conditions => {:name => name, :language => profile.language, :enabled => true}) if existing - flash[:warning]='This profile name already exists.' + flash[:warning]=message('quality_profiles.profile_name_already_exists') elsif !profile.provided? java_facade.renameProfile(profile.id, name) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index 00760a18bf8..79ae8f0ed59 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -18,8 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # class ProjectController < ApplicationController - verify :method => :post, :only => [ :set_links, :add_review, :set_exclusions, :delete_exclusions ], :redirect_to => { :action => :index } - verify :method => :delete, :only => [ :delete, :delete_review ], :redirect_to => { :action => :index } + verify :method => :post, :only => [ :set_links, :set_exclusions, :delete_exclusions ], :redirect_to => { :action => :index } + verify :method => :delete, :only => [ :delete ], :redirect_to => { :action => :index } SECTION=Navigation::SECTION_RESOURCE @@ -27,73 +27,6 @@ class ProjectController < ApplicationController redirect_to :overwrite_params => {:controller => :dashboard, :action => 'index'} end - def show_reviews - @snapshot = Snapshot.find(params[:sid].to_i) - render :partial => 'dashboard_reviews' - end - - def edit_review - @snapshot = Snapshot.find(params[:sid].to_i) - return access_denied unless has_role?(:admin, @snapshot) - - @review = ProjectMeasure.new(:measure_date => @snapshot.created_at, :value => 0) - @review_types = Metric.review_types - render :partial => 'dashboard_edit_review' - end - - def add_review - @snapshot=Snapshot.find(params[:sid].to_i) - return access_denied unless has_role?(:admin, @snapshot) - - measure = ProjectMeasure.new(params[:review]) - measure.project = @snapshot.project - - if measure.metric.nil? - flash[:error] = 'Please select a metric' - redirect_to :action => 'index', :id => measure.project_id - return - end - - if measure.measure_date <= @snapshot.created_at.to_date - if measure.metric.val_type==Metric::VALUE_TYPE_STRING - measure.text_value=params['review']['value'] - measure.value=0 - end - measure.url=params[:url] if params[:url] - measure.description=params[:description] if params[:description] - begin - measure.save! - java_facade.registerAsyncMeasure(measure.id.to_i) - flash[:notice] = 'Measure added' - rescue - flash[:error] = measure.errors.full_messages.join("<br/>") - end - - else - flash[:error] = "The date should not be after #{l(@snapshot.created_at.to_date)}" - end - - if request.xhr? - render :update do |page| - page.redirect_to :action => 'index', :id => measure.project_id - end - else - redirect_to :action => 'index', :id => measure.project_id - end - end - - def delete_review - measure = ProjectMeasure.find(params[:id].to_i) - if measure && measure.review? - return access_denied unless has_role?(:admin, measure.project) - - java_facade.deleteAsyncMeasure(measure.id.to_i) - redirect_to :action => 'index', :id => measure.project_id - else - redirect_to_default - end - end - def delete if params[:id] @project = Project.by_key(params[:id]) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb index 92103a56846..c8be6bd2837 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb @@ -73,8 +73,7 @@ class ReviewsController < ApplicationController end assignee = findUserByLogin(params[:assignee_login]) unless params[:assignee_login].blank? - @review.assignee = assignee - @review.save + @review.reassign(current_user, assignee) render :partial => 'reviews/view' end @@ -96,12 +95,14 @@ class ReviewsController < ApplicationController return end - if params[:comment_id] - @review.edit_comment(params[:comment_id].to_i, params[:text]) - else - @review.create_comment(:user => current_user, :text => params[:text]) + unless params[:text].blank? + if params[:comment_id] + @review.edit_comment(current_user, params[:comment_id].to_i, params[:text]) + else + @review.create_comment(:user => current_user, :text => params[:text]) + end end - + render :partial => "reviews/view" end @@ -121,7 +122,7 @@ class ReviewsController < ApplicationController unless params[:comment].blank? @review.set_false_positive(params[:false_positive]=='true', :user => current_user, :text => params[:comment]) end - + render :partial => "reviews/view" end @@ -134,7 +135,7 @@ class ReviewsController < ApplicationController end if @review - @review.delete_comment(params[:comment_id].to_i) + @review.delete_comment(current_user, params[:comment_id].to_i) end render :partial => "reviews/view" end @@ -146,12 +147,12 @@ class ReviewsController < ApplicationController render :text => "<b>Cannot create the comment</b> : access denied." return end - + if @review.isResolved? - @review.reopen + @review.reopen(current_user) else # for the moment, if a review is not open, it can only be "RESOLVED" - @review.resolve + @review.resolve(current_user) end render :partial => "reviews/view" @@ -186,8 +187,7 @@ class ReviewsController < ApplicationController violation.build_review(:user_id => current_user.id) assignee = findUserByLogin(params[:assignee_login]) unless params[:assignee_login].blank? - violation.review.assignee = assignee - violation.review.save! + violation.review.reassign(current_user, assignee) violation.save render :partial => "resource/violation", :locals => { :violation => violation } @@ -244,10 +244,12 @@ class ReviewsController < ApplicationController :user => current_user) end - if params[:comment_id] - violation.review.edit_comment(params[:comment_id].to_i, params[:text]) - else - violation.review.create_comment(:user => current_user, :text => params[:text]) + unless params[:text].blank? + if params[:comment_id] + violation.review.edit_comment(current_user, params[:comment_id].to_i, params[:text]) + else + violation.review.create_comment(:user => current_user, :text => params[:text]) + end end render :partial => "resource/violation", :locals => { :violation => violation } @@ -262,7 +264,7 @@ class ReviewsController < ApplicationController end sanitize_violation(violation) if violation.review - violation.review.delete_comment(params[:comment_id].to_i) + violation.review.delete_comment(current_user, params[:comment_id].to_i) end render :partial => "resource/violation", :locals => { :violation => violation } end @@ -279,10 +281,10 @@ class ReviewsController < ApplicationController if violation.review review = violation.review if review.isResolved? - review.reopen + review.reopen(current_user) else # for the moment, if a review is not open, it can only be "RESOLVED" - review.resolve + review.resolve(current_user) end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb index d4d028f2c60..8acf512a336 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb @@ -53,8 +53,8 @@ class RulesConfigurationController < ApplicationController @select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()]}.sort @select_priority = ANY_SELECTION + RULE_PRIORITIES - @select_status = [['Any',''], ["Active", STATUS_ACTIVE], ["Inactive", STATUS_INACTIVE]] - @select_inheritance = [['Any',''], ["Not inherited", 'NOT'], ["Inherited", 'INHERITED'], ["Overrides", 'OVERRIDES']] + @select_status = [[message('any'),''], [message('active'), STATUS_ACTIVE], [message('inactive'), STATUS_INACTIVE]] + @select_inheritance = [[message('any'),''], [message('rules_configuration.not_inherited'), 'NOT'], [message('rules_configuration.inherited'), 'INHERITED'], [message('rules_configuration.overrides'), 'OVERRIDES']] @rules = Rule.search(java_facade, { :profile => @profile, :status => @status, :priorities => @priorities, :inheritance => @inheritance, @@ -179,7 +179,7 @@ class RulesConfigurationController < ApplicationController redirect_to :action => 'index', :id => params[:id], :searchtext => rule.name, :rule_status => 'INACTIVE', "plugins[]" => rule.plugin_name else - flash[:error]="Rule is not valid: <br/>#{rule.errors.full_messages.join('<br/>')}" + flash[:error]=message('rules_configuration.rule_not_valid_message_x', :params => rule.errors.full_messages.join('<br/>')) redirect_to :action => 'new', :id => params[:id], :rule_id => params[:rule_id] end end @@ -222,7 +222,7 @@ class RulesConfigurationController < ApplicationController if rule.save redirect_to :action => 'index', :id => params[:id], :searchtext => rule.name, :rule_status => '', "plugins[]" => rule.plugin_name else - flash[:error]="Rule is not valid: <br/>#{rule.errors.full_messages.join('<br/>')}" + flash[:error]=message('rules_configuration.rule_not_valid_message_x', :params => rule.errors.full_messages.join('<br/>')) redirect_to :action => 'new', :id => params[:id], :rule_id => params[:rule_id] end else @@ -246,9 +246,9 @@ class RulesConfigurationController < ApplicationController # it's mandatory to execute 'destroy_all' but not 'delete_all' because active_rule_parameters must # also be destroyed in cascade. ActiveRule.destroy_all("rule_id=#{rule.id}") - flash[:notice]='Rule deleted' + flash[:notice]=message('rules_configuration.rule_deleted') else - flash[:error]='Unknown rule' + flash[:error]=message('rules_configuration.unknown_rule') end redirect_to :action => 'index', :id => params[:id] end @@ -270,12 +270,12 @@ class RulesConfigurationController < ApplicationController case params[:bulk_action] when 'activate' count=activate_rules(profile, rule_ids) - flash[:notice]="#{count} rules have been activated." + flash[:notice]=message('rules_configuration.x_rules_have_been_activated', :params => count) status=STATUS_ACTIVE if status==STATUS_INACTIVE when 'deactivate' count=deactivate_rules(profile, rule_ids) - flash[:notice]="#{count} rules have been deactivated." + flash[:notice]=message('rules_configuration.x_rules_have_been_deactivated', :params => count) status=STATUS_INACTIVE if status==STATUS_ACTIVE end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/sessions_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/sessions_controller.rb index 5f9b1dc9a97..fc273b33370 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/sessions_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/sessions_controller.rb @@ -20,7 +20,7 @@ ### Sessions Controller from restful_authentication (http://agilewebdevelopment.com/plugins/restful_authentication) class SessionsController < ApplicationController - + layout 'nonav' skip_before_filter :check_authentication @@ -33,10 +33,10 @@ class SessionsController < ApplicationController self.current_user.remember_me cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } end - flash[:notice] = 'Logged in.' + flash[:notice] = message('session.flash_notice.logged_in') redirect_to(home_path) else - flash.now[:loginerror] = 'Authentication failed.' + flash.now[:loginerror] = message('session.flash_notice.authentication_failed') end end @@ -46,7 +46,7 @@ class SessionsController < ApplicationController self.current_user.forget_me end cookies.delete :auth_token - flash[:notice]='You have been logged out.' + flash[:notice]=message('session.flash_notice.logged_out') redirect_to(home_path) reset_session end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb index d2841e7b3d9..47d0d223998 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/timemachine_controller.rb @@ -53,7 +53,6 @@ class TimemachineController < ApplicationController end measures=ProjectMeasure.find(:all, :conditions => {:rule_id => nil, :rule_priority => nil, :snapshot_id => @sids, :characteristic_id => nil}) - measures.concat(AsyncMeasureSnapshot.search(@sids)) rows_by_metric_id={} @rows=[] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/alerts_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/alerts_helper.rb index 3d2cb09006b..1b626ddf09b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/alerts_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/alerts_helper.rb @@ -18,10 +18,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # module AlertsHelper - NUMERIC_THRESOLD_OPERATORS = {'is less than' => '<', 'is greater than' => '>', 'equals' => '=', 'is not' => '!=' } - BOOLEAN_THRESOLD_OPERATORS = {'is' => '='} - STRING_THRESOLD_OPERATORS = {'equals' => '=', 'is not' => '!=', 'is greater than' => '>', 'is less than' => '<'} - LEVEL_THRESOLD_OPERATORS = {'is' => '=', 'is not' => '!='} + NUMERIC_THRESOLD_OPERATORS = ['<', '>', '=', '!='] + BOOLEAN_THRESOLD_OPERATORS = ['='] + STRING_THRESOLD_OPERATORS = ['=', '!=', '>', '<'] + LEVEL_THRESOLD_OPERATORS = ['=', '!='] def operators_for_select(alert) if alert.metric.nil? diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 2e42bf097eb..935a7231d33 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -41,7 +41,7 @@ module ApplicationHelper def qualifier_icon(object) qualifier=(object.respond_to?('qualifier') ? object.qualifier : object.to_s) if qualifier - image_tag("q/#{qualifier}.png", :alt => Resourceable.qualifier_name(qualifier)) + image_tag("q/#{qualifier}.png", :alt => message(Resourceable.qualifier_name(qualifier))) else image_tag('e16.gif') end @@ -56,8 +56,8 @@ module ApplicationHelper end # i18n - def message(key, default, *parameters) - Java::OrgSonarServerUi::JRubyFacade.getInstance().getI18nMessage(I18n.locale, key, default, parameters.to_java) + def message(key, options={}) + Api::Utils.message(key, options) end # deprecated since 2.5. Use trend_icon() instead @@ -88,21 +88,21 @@ module ApplicationHelper label=nil if mode if mode=='days' - label = "over %s days" % mode_param + label = message('over_x_days', :params => mode_param.to_s) elsif mode=='version' if date - label = "since version %s (%s)" % [mode_param, date.strftime("%Y %b %d")] + label = message('since_version_detailed', :params => [mode_param.to_s, date.strftime("%Y %b %d").to_s]) else - label = "since version %s" % mode_param + label = message('since_version', :params => mode_param.to_s) end elsif mode=='previous_analysis' if !date.nil? - label = "since previous analysis (%s)" % (date.strftime("%Y %b %d")) + label = message('since_previous_analysis_detailed', :params => date.strftime("%Y %b %d").to_s) else - label = "since previous analysis" + label = message('since_previous_analysis') end elsif mode=='date' - label = "since #{date.strftime("%Y %b %d")}" + label = message('since_x', :params => date.strftime("%Y %b %d").to_s) end end label @@ -254,7 +254,7 @@ module ApplicationHelper # def format_measure(metric_or_measure, options={}) html='' - + m=nil if metric_or_measure.is_a? ProjectMeasure m = metric_or_measure elsif @snapshot @@ -414,10 +414,10 @@ module ApplicationHelper resource_id=(resource.is_a?(Fixnum) ? resource : (resource.copy_resource_id || resource.id)) html_id=options['html_id'] || "fav#{resource_id}" initial_class='notfav' - initial_tooltip='Click to add to favourites' + initial_tooltip=message('click_to_add_to_favourites') if current_user.favourite?(resource_id) initial_class='fav' - initial_tooltip='Click to remove from favourites' + initial_tooltip=message('click_to_remove_from_favourites') end link_to_remote('', :url => { :controller => 'favourites', :action => 'toggle', :id => resource_id, :elt => html_id}, diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb index 9e258c7e108..6d7fbd7f069 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb @@ -19,6 +19,7 @@ # module DashboardHelper include WidgetPropertiesHelper + include MetricsHelper def formatted_value(measure, default='') measure ? measure.formatted_value : default @@ -46,17 +47,17 @@ module DashboardHelper if mode if mode=='days' - label = "Added over %s days" % mode_param + label = message('added_over_x_days', :params => mode_param.to_s) elsif mode=='version' - label = "Added since version %s" % mode_param + label = message('added_since_version', :params => mode_param.to_s) elsif mode=='previous_analysis' if !date.nil? - label = "Added since previous analysis (%s)" % date.strftime("%Y %b. %d") + label = message('added_since_previous_analysis_detailed', :params => date.strftime("%Y %b. %d").to_s) else - label = "Added since previous analysis" + label = message('added_since_previous_analysis') end elsif mode=='date' - label = "Added since #{date.strftime("%Y %b %d")}" + label = message('added_since', :params => date.strftime("%Y %b %d").to_s) end if label selected=(params[:period]==index.to_s ? 'selected' : '') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb index 81f59c5ffb3..4f827a2823d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb @@ -171,14 +171,14 @@ module FiltersHelper def period_name(property) if property=='previous_analysis' - "Δ since previous analysis" + message('delta_since_previous_analysis') elsif property =~ /^[\d]+(\.[\d]+){0,1}$/ # is integer - "Δ over #{property} days" + message('delta_over_x_days', :params => property) elsif property =~ /\d{4}-\d{2}-\d{2}/ - "Δ since #{property}" + message('delta_since', :params => property) elsif !property.blank? - "Δ since version #{property}" + message('delta_since_version', :params => property) else nil end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/i18n_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/i18n_helper.rb deleted file mode 100644 index d6a764ffd83..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/i18n_helper.rb +++ /dev/null @@ -1,61 +0,0 @@ -# modify it under the terms of the GNU Lesser General Public - # License as published by the Free Software Foundation; either - # version 3 of the License, or (at your option) any later version. - # - # Sonar is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - # Lesser General Public License for more details. - # - # You should have received a copy of the GNU Lesser General Public - # License along with Sonar; if not, write to the Free Software - # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - # -module I18nHelper - - def self.java_locale() - locale_parts = I18n.locale.to_s.split('-') - return java.util.Locale.new(locale_parts[0]) if locale_parts.size == 1 - return java.util.Locale.new(locale_parts[0], locale_parts[1]) if locale_parts.size >= 2 - end - - def self.i18n - Java::OrgSonarServerUi::JRubyFacade.getInstance().getI18n() - end - - def self.translation(key, defaultText, *objects) - i18n.translation(java_locale(), key, defaultText, objects.to_java) - end - - def self.trans_widget(widget, key, default_text, *objects) - i18n.translation(java_locale(), "view." + widget.widget_key + "." + key, default_text, objects.to_java) - end - - def self.trans_page(view_id, key, default_text, *objects) - i18n.translation(java_locale(), "view." + view_id + "." + key, default_text, objects.to_java) - end - - def self.trans_tab(view_id, key, default_text, *objects) - i18n.translation(java_locale(), "view." + view_id + "." + key, default_text, objects.to_java) - end - - def self.trans_column(column_key, default_text, *objects) - i18n.translation(java_locale(), "general_columns." + column_key, default_text, objects.to_java) - end - - def self.trans_app_view(path, key, default_text, *objects) - i18n.translation(java_locale(), "app.view." + path + "." + key, default_text, objects.to_java) - end - - def self.trans_app_helper(path, key, default_text, *objects) - i18n.translation(java_locale(), "app.helper." + path + "." + key, default_text, objects.to_java) - end - - def self.trans_app_controller(path, key, default_text, *objects) - i18n.translation(java_locale(), "app.controller." + path + "." + key, default_text, objects.to_java) - end - - def self.trans_app_model(path, key, default_text, *objects) - i18n.translation(java_locale(), "app.model." + path + "." + key, default_text, objects.to_java) - end -end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb index f94dddf81ee..ef3725df381 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/metrics_helper.rb @@ -23,7 +23,7 @@ module MetricsHelper metrics.map {|m| m.domain(translate)}.uniq.compact.sort end - def options_grouped_by_domain(metrics, selected_key='') + def options_grouped_by_domain(metrics, selected_key='', options={}) metrics_per_domain={} metrics.each do |metric| domain=metric.domain || '' @@ -32,10 +32,14 @@ module MetricsHelper end html='' + if options[:include_empty]==true + html+= "<option value=''></option>" + end + metrics_per_domain.keys.sort.each do |domain| html += "<optgroup label=\"#{html_escape(domain)}\">" metrics_per_domain[domain].each do |m| - selected_attr = " selected='selected'" if (m.key==selected_key || m.id==selected_key) + selected_attr = (m.key==selected_key || m.id==selected_key) ? " selected='selected'" : '' html += "<option value='#{html_escape(m.key)}'#{selected_attr}>#{html_escape(m.short_name)}</option>" end html += '</optgroup>' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb index 3c2146fb835..528218e4d4c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb @@ -23,11 +23,11 @@ module ProfilesHelper end def label_for_rules_count(profile) - label="#{profile.count_active_rules} rules" + label="#{profile.count_active_rules} #{message('rules').downcase}" count_overriding=profile.count_overriding_rules if count_overriding>0 - label += ", incl. #{count_overriding} overriding" + label += message('quality_profiles.including_x_overriding.suffix', :params => count_overriding) label += image_tag('overrides.png') end label diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb index 695f922dbd2..f5c2843f204 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/users_helper.rb @@ -131,7 +131,7 @@ module UsersHelper unless param_id_value.blank? user = User.find(:all, :conditions => [ "login = ?", param_id_value ]).first param_displayed_value = user.name if user - param_displayed_value += " (me)" if user && current_user && current_user.login == param_id_value + param_displayed_value += " (#{message('me').downcase})" if user && current_user && current_user.login == param_id_value end server_url = url_for :controller => 'users', :action => 'autocomplete' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb index a44fe8abf29..c5c358ee8b8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb @@ -18,8 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # module WidgetPropertiesHelper - - + def property_value_field(definition, value) val=value || definition.defaultValue() if definition.type.name()==WidgetProperty::TYPE_INTEGER @@ -31,6 +30,9 @@ module WidgetPropertiesHelper elsif definition.type.name()==WidgetProperty::TYPE_BOOLEAN check_box_tag definition.key(), "true", val=='true' + elsif definition.type.name()==WidgetProperty::TYPE_METRIC + select_tag definition.key(), options_grouped_by_domain(Metric.all.select{|m| m.display?}, val, :include_empty => true) + elsif definition.type.name()==WidgetProperty::TYPE_STRING text_field_tag definition.key(), val, :size => 10 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb index 9ed45df354e..8f5d33436a6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb @@ -37,6 +37,10 @@ class Api::Utils true if Float(s) rescue false end + def self.is_integer?(s) + s.to_s =~ /\A[+-]?\d+\Z/ + end + def self.markdown_to_html(markdown) markdown ? Java::OrgSonarServerUi::JRubyFacade.markdownToHtml(ERB::Util.html_escape(markdown)) : '' end @@ -53,4 +57,16 @@ class Api::Utils # See http://jira.codehaus.org/browse/SONAR-2571 split_newlines(input).join("\n") end + + # + # i18n + # Since 2.10 + def self.message(key, options={}) + default = options[:default] + params = options[:params] + if params.nil? + params=[] + end + Java::OrgSonarServerUi::JRubyFacade.getInstance().getMessage(I18n.locale, key, default, params.to_java) + end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb index 71543d6d9ba..2fc8b509b05 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb @@ -24,7 +24,7 @@ class Dashboard < ActiveRecord::Base belongs_to :user has_many :widgets, :include => 'properties', :dependent => :delete_all - has_many :active_dashboards, :dependent => :delete_all + has_many :active_dashboards, :dependent => :destroy validates_length_of :name, :within => 1..256 validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb index c7eec4c6bad..f8286331374 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb @@ -92,7 +92,7 @@ class DrilldownColumn end @measures=ProjectMeasure.find(:all, - :select => "project_measures.id,project_measures.metric_id,project_measures.#{value_column},project_measures.text_value,project_measures.alert_status,project_measures.snapshot_id", + :select => "project_measures.id,project_measures.metric_id,project_measures.#{value_column},project_measures.text_value,project_measures.alert_status,project_measures.alert_text,project_measures.snapshot_id", :joins => :snapshot, :conditions => [conditions, condition_values], :order => order, diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/filter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/filter.rb index b1bf557b18d..3b472fe78c9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/filter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/filter.rb @@ -27,9 +27,9 @@ class Filter < ActiveRecord::Base belongs_to :user belongs_to :resource, :class_name => 'Project', :foreign_key => 'resource_id' - has_many :columns, :class_name => 'FilterColumn', :dependent => :delete_all, :validate => true, :order => 'order_index' - has_many :criteria, :class_name => 'Criterion', :dependent => :delete_all, :validate => true - has_many :active_filters, :dependent => :delete_all + has_many :columns, :class_name => 'FilterColumn', :dependent => :destroy, :validate => true, :order => 'order_index' + has_many :criteria, :class_name => 'Criterion', :dependent => :destroy, :validate => true + has_many :active_filters, :dependent => :destroy validates_length_of :name, :within => 1..100 validates_uniqueness_of :name, :scope => :user_id, :if => Proc.new { |filter| filter.user_id } @@ -38,7 +38,7 @@ class Filter < ActiveRecord::Base def criterion(family, key=nil) criteria.each do |criterion| if criterion.family==family && criterion.key==key - return criterion if ((key.nil? && criterion.key.nil?) ||Â (key && key==criterion.key)) + return criterion if ((key.nil? && criterion.key.nil?) || (key && key==criterion.key)) end end nil @@ -95,13 +95,6 @@ class Filter < ActiveRecord::Base column('links') end - def display_user_managed_metrics? - columns.each do |col| - return true if col.metric && col.metric.user_managed? - end - false - end - def default_view read_attribute(:default_view) || VIEW_LIST end @@ -145,7 +138,7 @@ class Filter < ActiveRecord::Base columns.each do |col| return col if col.id==col_id end - return nil + nil end def clean_columns_order diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/filter_column.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/filter_column.rb index d2208f6e47f..0694e37d8bd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/filter_column.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/filter_column.rb @@ -23,7 +23,7 @@ class FilterColumn < ActiveRecord::Base belongs_to :filter validates_inclusion_of :sort_direction, :in => %w( ASC DESC ), :allow_nil => true - + def self.create_from_string(string) if FAMILIES.include?(string) FilterColumn.new(:family => string) @@ -39,48 +39,14 @@ class FilterColumn < ActiveRecord::Base def name if on_metric? - metric ? metric.short_name : kee + Api::Utils.message("metric." + kee + ".name", :default => metric.short_name) else - case family - when 'date' - 'Build date' - when 'language' - 'Language' - when 'name' - 'Name' - when 'links' - 'Links' - when 'version' - 'Version' - when 'key' - 'Key' - else - kee - end + Api::Utils.message(family, :default => kee) end end def display_name - if on_metric? - metric ? metric.short_name : kee - else - case family - when 'date' - 'Build date' - when 'language' - 'Language' - when 'name' - 'Name' - when 'links' - 'Links' - when 'version' - 'Version' - when 'key' - 'Key' - else - kee - end - end + name end def metric diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/filter_context.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/filter_context.rb index 82dad3b41fa..7ce80b37ea3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/filter_context.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/filter_context.rb @@ -58,10 +58,6 @@ if @metric_ids.size>0 measures=ProjectMeasure.find(:all, :conditions => ['rule_priority is null and rule_id is null and characteristic_id is null and snapshot_id in (?)', @page_sids]) - if filter.display_user_managed_metrics? - measures.concat(AsyncMeasureSnapshot.search(@page_sids, @metric_ids)) - end - measures.each do |m| snapshot=@snapshots_by_id[m.snapshot_id] @measures_by_snapshot[snapshot]||={} diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb new file mode 100644 index 00000000000..72bff3fcf6a --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb @@ -0,0 +1,141 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# +class ManualMeasure < ActiveRecord::Base + include ActionView::Helpers::NumberHelper + + belongs_to :resource, :class_name => 'Project' + validates_uniqueness_of :metric_id, :scope => :resource_id + validates_length_of :text_value, :maximum => 4000, :allow_nil => true, :allow_blank => true + validates_length_of :description, :maximum => 4000, :allow_nil => true, :allow_blank => true + validate :validate_metric, :validate_value + + def metric + @metric ||= + begin + Metric.by_id(metric_id) + end + end + + def user + @user ||= + begin + user_login ? User.find(:first, :conditions => ['login=?', user_login]) : nil + end + end + + def username + user ? user.name : user_login + end + + def metric=(m) + @metric = m + write_attribute(:metric_id, m.id) if m.id + end + + def typed_value=(v) + if metric && metric.numeric? + self.value=v + else + self.text_value=v + end + end + + def pending?(snapshot=nil) + if snapshot.nil? + snapshot=resource.last_snapshot + end + snapshot && updated_at && snapshot.created_at<updated_at + end + + def formatted_value + if metric.nil? + return value.to_s + end + + case metric().val_type + when Metric::VALUE_TYPE_INT + number_with_precision(value(), :precision => 0) + when Metric::VALUE_TYPE_FLOAT + number_with_precision(value(), :precision => 1) + when Metric::VALUE_TYPE_PERCENT + number_to_percentage(value(), {:precision => 1}) + when Metric::VALUE_TYPE_MILLISEC + millisecs_formatted_value(value()) + when Metric::VALUE_TYPE_BOOLEAN + value() == 1 ? 'Yes' : 'No' + when Metric::VALUE_TYPE_LEVEL + text_value + when Metric::VALUE_TYPE_STRING + text_value + when Metric::VALUE_TYPE_RATING + text_value || value.to_i.to_s + else + value().to_s + end + end + + def editable_value + if metric.nil? + return '' + end + + if metric.numeric? + value ? value.to_s : '' + elsif metric.value_type==Metric::VALUE_TYPE_BOOLEAN + value ? (value==1 ? 'Yes' : 'No') : '' + else + text_value + end + end + + def validate_metric + if metric.nil? || !metric.enabled? + errors.add_to_base("Unknown metric") + elsif !metric.user_managed? + errors.add_to_base("Not a manual metric") + end + end + + def validate_value + if metric + case metric.value_type + when Metric::VALUE_TYPE_INT + errors.add('value', "An integer value must be provided") if value_before_type_cast.nil? || !Api::Utils.is_integer?(value_before_type_cast) + when Metric::VALUE_TYPE_FLOAT + errors.add('value', "A numerical value must be provided") if value_before_type_cast.nil? || !Api::Utils.is_number?(value_before_type_cast) + when Metric::VALUE_TYPE_PERCENT + errors.add('value', "A numerical value must be provided") if value_before_type_cast.nil? || !Api::Utils.is_number?(value_before_type_cast) + when Metric::VALUE_TYPE_MILLISEC + errors.add('value', "Value must equal or be greater than 0") if value_before_type_cast.nil? || !Api::Utils.is_number?(value_before_type_cast) || value<0 + when Metric::VALUE_TYPE_BOOLEAN + raw_value = text_value.downcase + errors.add('value', "Value must be 'No' or 'Yes'") if raw_value != "yes" && raw_value != "no" + write_attribute("value", 1.0) if raw_value == "yes" + write_attribute("value", 0.0) if raw_value == "no" + when Metric::VALUE_TYPE_LEVEL + raw_value = text_value.upcase + errors.add('value', "Value must be OK, WARN or ERROR") if !['OK', 'WARN', 'ERROR'].include?(raw_value) + write_attribute("value", Sonar::RulePriority.id(raw_value)) + write_attribute("text_value", raw_value) + end + end + end + +end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb index 43411eb8b8d..614d6b21824 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/metric.rb @@ -40,6 +40,8 @@ class Metric < ActiveRecord::Base ORIGIN_JAVA='JAV' CACHE_KEY='metrics' + I18N_DOMAIN_CACHE_KEY='i18n_domains' + I18N_SHORT_NAME_CACHE_KEY='i18n_metric_short_names' validates_length_of :name, :within => 1..64 validates_uniqueness_of :name @@ -60,16 +62,79 @@ class Metric < ActiveRecord::Base short_name<=>other.short_name end - def self.domains + def self.domains(translate=true) all.collect{|metric| - metric.domain + metric.domain(translate) }.compact.uniq.sort end + def self.i18n_domain_for(to_translate) + return nil if to_translate.nil? + + localeMap = Metric.i18n_domain_cache[to_translate] + locale = I18n.locale + + return localeMap[locale] if not localeMap.nil? and localeMap.has_key?(locale) + + i18n_key = 'domain.' + to_translate + result = Api::Utils.message(i18n_key, :default => to_translate) + localeMap[locale] = result if localeMap + result + end + def key name end + def domain(translate=true) + default_string = read_attribute(:domain) + return default_string unless translate + Metric.i18n_domain_for(default_string) + end + + def domain=(value) + write_attribute(:domain, value) + end + + def short_name(translate=true) + default_string = read_attribute(:short_name) + return default_string unless translate + + metric_key = read_attribute(:name) + return nil if metric_key.nil? + + localeMap = Metric.i18n_short_name_cache[metric_key] + locale = I18n.locale + + return localeMap[locale] if localeMap && localeMap.has_key?(locale) + + i18n_key = 'metric.' + metric_key + '.name' + result = Api::Utils.message(i18n_key, :default => default_string) + localeMap[locale] = result if localeMap + result + end + + def short_name=(value) + write_attribute(:short_name, value) + end + + def description(translate=true) + default_string = read_attribute(:description) + return default_string unless translate + + metric_name = read_attribute(:name) + + return nil if metric_name.nil? + + i18n_key = 'metric.' + metric_name + '.description' + result = Api::Utils.message(i18n_key, :default => default_string) + result + end + + def description=(value) + write_attribute(:description, value) + end + def user_managed? user_managed==true end @@ -156,8 +221,8 @@ class Metric < ActiveRecord::Base metrics end - def self.by_domain(domain) - all.select{|metric| metric.domain==domain}.sort + def self.by_domain(domain, translate=true) + all.select{|metric| metric.domain(translate)==domain}.sort end def self.major_metrics_id @@ -166,16 +231,14 @@ class Metric < ActiveRecord::Base def self.clear_cache Caches.clear(CACHE_KEY) + Caches.clear(I18N_DOMAIN_CACHE_KEY) + Caches.clear(I18N_SHORT_NAME_CACHE_KEY) end def self.default_time_machine_metrics [COMPLEXITY, COVERAGE, VIOLATIONS_DENSITY] end - def self.review_types - all.select{|metric| metric.user_managed?} - end - def self.by_keys(keys) result=[] keys.each do |k| @@ -309,4 +372,25 @@ class Metric < ActiveRecord::Base c end + def self.i18n_domain_cache + c = Caches.cache(I18N_DOMAIN_CACHE_KEY) + if c.size==0 + domains(false).each do |domain| + locale_map={} + c[domain]=locale_map + end + end + c + end + + def self.i18n_short_name_cache + c = Caches.cache(I18N_SHORT_NAME_CACHE_KEY) + if c.size==0 + all.each do |metric| + locale_map={} + c[metric.name]=locale_map + end + end + c + end end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb index a182dd8b876..5fd8dde7209 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb @@ -28,6 +28,7 @@ class Project < ActiveRecord::Base belongs_to :profile, :class_name => 'Profile', :foreign_key => 'profile_id' has_many :user_roles, :foreign_key => 'resource_id' has_many :group_roles, :foreign_key => 'resource_id' + has_many :manual_measures, :foreign_key => 'resource_id' belongs_to :root, :class_name => 'Project', :foreign_key => 'root_id' def self.by_key(k) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_link.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_link.rb index 422e45cbf55..f00e819f839 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_link.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_link.rb @@ -41,6 +41,14 @@ class ProjectLink < ActiveRecord::Base link_type end + def name(translate=true) + default_string = read_attribute(:name) + return default_string unless translate + + i18n_key = 'project_links.' + read_attribute(:link_type) + Api::Utils.message(i18n_key, :default => default_string) + end + def self.name_to_key(s) s.tr(' ', '_')[0..19] end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb index 54675821f79..0532898a30c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -31,12 +31,6 @@ class ProjectMeasure < ActiveRecord::Base belongs_to :characteristic has_one :measure_data, :class_name => 'MeasureData', :foreign_key => 'measure_id' - has_many :async_measure_snapshots - has_many :snapshots, :through => :async_measure_snapshots - - validates_numericality_of :value, :if => :numerical_metric? - validate :validate_date, :validate_value - def metric @metric ||= begin @@ -213,49 +207,6 @@ class ProjectMeasure < ActiveRecord::Base end end - # return reviews from the snapshot and also reviews created after the snapshot - def self.find_reviews_for_last_snapshot(snapshot) - ProjectMeasure.find(:all, :include => [:async_measure_snapshots, :measure_data], - :conditions => ['async_measure_snapshots.project_id=project_measures.project_id AND ' + - '((async_measure_snapshots.snapshot_id IS NULL AND project_measures.measure_date>?) ' + - 'OR async_measure_snapshots.snapshot_id=?) ', snapshot.created_at, snapshot.id]) - end - - def self.find_reviews_for_last_snapshot_with_opts(snapshot, options) - metrics = options[:metrics].nil? ? [] : Metric.ids_from_keys(options[:metrics].split(',')) - include = (options[:includeparams] == "true") ? [:async_measure_snapshots, :measure_data] : :async_measure_snapshots - - metrics_conditions = (metrics.empty?) ? "" : "AND project_measures.metric_id IN (?)" - conditions = 'async_measure_snapshots.project_id=project_measures.project_id AND ' + - '((async_measure_snapshots.snapshot_id IS NULL AND project_measures.measure_date>?) ' + - 'OR async_measure_snapshots.snapshot_id=?) ' + metrics_conditions - if metrics.empty? - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.created_at, snapshot.id]) - else - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.created_at, snapshot.id, metrics]) - end - end - - def self.find_reviews(snapshot) - conditions = 'async_measure_snapshots.snapshot_id=? ' + metrics_conditions - ProjectMeasure.find(:all, :include => [:async_measure_snapshots, :measure_data], - :conditions => ['async_measure_snapshots.snapshot_id=? ', snapshot.id]) - end - - - def self.find_reviews_with_opts(snapshot, options={}) - metrics = options[:metrics].nil? ? [] : Metric.ids_from_keys(options[:metrics].split(',')) - include = (options[:includeparams] == "true") ? [:async_measure_snapshots, :measure_data] : :async_measure_snapshots - - metrics_conditions = (metrics.empty?) ? "" : "AND project_measures.metric_id IN (?)" - conditions = 'async_measure_snapshots.snapshot_id=? ' + metrics_conditions - if metrics.empty? - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.id]) - else - ProjectMeasure.find(:all, :include => include, :conditions => [conditions, snapshot.id, metrics]) - end - end - def tip if rule_id rule.description @@ -309,7 +260,7 @@ class ProjectMeasure < ActiveRecord::Base end def <=>(other) - return value<=>other.value + value<=>other.value end private @@ -318,39 +269,5 @@ class ProjectMeasure < ActiveRecord::Base [Metric::VALUE_TYPE_INT, Metric::VALUE_TYPE_FLOAT, Metric::VALUE_TYPE_PERCENT, Metric::VALUE_TYPE_MILLISEC].include?(metric.val_type) end - def validate_date - if measure_date.nil? - errors.add_to_base('A valid date must be provided') - else - last_snasphot_date = project.last_snapshot.created_at - if project.last_snapshot.created_at < measure_date - errors.add_to_base("The date should not be after #{last_snasphot_date.strftime('%Y-%m-%d')}") - end - end - end - - def validate_value - case metric.value_type - when Metric::VALUE_TYPE_INT - errors.add_to_base("A numerical value must be provided") if value.nil? - when Metric::VALUE_TYPE_FLOAT - errors.add_to_base("A numerical value must be provided") if value.nil? - when Metric::VALUE_TYPE_PERCENT - errors.add_to_base("A numerical value must be provided") if value.nil? - when Metric::VALUE_TYPE_MILLISEC - errors.add_to_base("Value must be greater than 0") if value < 0 - when Metric::VALUE_TYPE_BOOLEAN - raw_value = send("value_before_type_cast") - if raw_value.instance_of?(String) - raw_value = raw_value.downcase - errors.add_to_base("Value must be 'No' or 'Yes'") if raw_value != "yes" && raw_value != "no" - write_attribute( "value", 1.0) if raw_value == "yes" - write_attribute( "value", 0.0) if raw_value == "no" - end - when Metric::VALUE_TYPE_STRING - errors.add_to_base("A text value must be provided") if text_value.blank? - end - end - end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb index 9d820401d0d..b639eb90849 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb @@ -54,45 +54,91 @@ class Review < ActiveRecord::Base # REVIEW CORE METHODS # # - + # params are mandatory: # - :user # - :text def create_comment(params={}) - comments.create!(params) + comment = comments.create!(params) touch + notification_manager.notifyChanged(id.to_i, comment.user.login.to_java, to_java_map, to_java_map("comment" => comment.text)) end - def edit_comment(comment_id, comment_text) + def edit_comment(current_user, comment_id, comment_text) comment=comments.find(comment_id) if comment + old_comment_text=comment.text comment.text=comment_text comment.save! touch + notification_manager.notifyChanged(id.to_i, current_user.login.to_java, to_java_map("comment" => old_comment_text), to_java_map("comment" => comment.text)) end end - def edit_last_comment(comment_text) + # TODO Godin: seems that this method not used anymore + def edit_last_comment(current_user, comment_text) comment=comments.last + old_comment_text=comment.text comment.text=comment_text comment.save! touch + notification_manager.notifyChanged(id.to_i, current_user.login.to_java, to_java_map("comment" => old_comment_text), to_java_map("comment" => comment.text)) end - - def delete_comment(comment_id) + + def delete_comment(current_user, comment_id) comment=comments.find(comment_id) comments.pop if comment + old_comment_text=comment.text comment.delete touch + notification_manager.notifyChanged(id.to_i, current_user.login.to_java, to_java_map("comment" => old_comment_text), to_java_map) end end - - def reassign(user) - self.assignee = user + + def notification_manager + Java::OrgSonarServerUi::JRubyFacade.getInstance().getReviewsNotificationManager() + end + + def to_java_map(params = {}) + map = java.util.HashMap.new({ + "project" => project.long_name.to_java, + "resource" => resource.long_name.to_java, + "title" => title.to_java, + "creator" => user == nil ? nil : user.login.to_java, + "assignee" => assignee == nil ? nil : assignee.login.to_java, + "status" => status.to_java, + "resolution" => resolution.to_java + }) + params.each_pair do |k,v| + map.put(k.to_java, v.to_java) + end + map + end + + def reassign(current_user, assignee) + old = self.to_java_map + self.assignee = assignee self.save! + notification_manager.notifyChanged(id.to_i, current_user.login.to_java, old, to_java_map) end - + + def reopen(current_user) + old = self.to_java_map + self.status = STATUS_REOPENED + self.resolution = nil + self.save! + notification_manager.notifyChanged(id.to_i, current_user.login.to_java, old, to_java_map) + end + + def resolve(current_user) + old = self.to_java_map + self.status = STATUS_RESOLVED + self.resolution = 'FIXED' + self.save! + notification_manager.notifyChanged(id.to_i, current_user.login.to_java, old, to_java_map) + end + # params are mandatory: # - :user (mandatory) # - :text (mandatory) @@ -109,14 +155,16 @@ class Review < ActiveRecord::Base violation.save! end end - create_comment(:user => params[:user], :text => params[:text]) + comment = comments.create!(:user => params[:user], :text => params[:text]) + old = self.to_java_map self.assignee = nil self.status = is_false_positive ? STATUS_RESOLVED : STATUS_REOPENED self.resolution = is_false_positive ? 'FALSE-POSITIVE' : nil self.save! + notification_manager.notifyChanged(id.to_i, comment.user.login.to_java, old, to_java_map("comment" => comment.text)) end end - + def false_positive resolution == 'FALSE-POSITIVE' end @@ -141,20 +189,6 @@ class Review < ActiveRecord::Base status == STATUS_OPEN end - def reopen - self.status = STATUS_REOPENED - self.resolution = nil - self.save! - end - - def resolve - self.status = STATUS_RESOLVED - self.resolution = 'FIXED' - self.save! - end - - - # # # SEARCH METHODS diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb index 6b2a91db46d..b21f4a4480e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb @@ -26,6 +26,10 @@ class Rule < ActiveRecord::Base has_many :active_rules belongs_to :parent, :class_name => 'Rule', :foreign_key => 'parent_id' + def repository_key + plugin_name + end + def parameters rules_parameters end @@ -57,7 +61,33 @@ class Rule < ActiveRecord::Base def <=>(rule) name<=>rule.name end - + + def name + @l10n_name ||= + begin + result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleName(I18n.locale, repository_key, plugin_rule_key) + result = read_attribute(:name) unless result + result + end + end + + def name=(value) + write_attribute(:name, value) + end + + def description + @l10n_description ||= + begin + result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleDescription(I18n.locale, repository_key, plugin_rule_key) + result = read_attribute(:description) unless result + result + end + end + + def description=(value) + write_attribute(:description, value) + end + def config_key plugin_config_key end @@ -106,7 +136,7 @@ class Rule < ActiveRecord::Base else json['priority'] = priority_text end - json['params'] = parameters.collect{|parameter| parameter.to_hash_json(active_rule)} unless parameters.empty? + json['params'] = parameters.collect { |parameter| parameter.to_hash_json(active_rule) } unless parameters.empty? json end @@ -116,7 +146,7 @@ class Rule < ActiveRecord::Base xml.key(key) xml.config_key(config_key) xml.plugin(plugin_name) - xml.description {xml.cdata!(description)} + xml.description { xml.cdata!(description) } active_rule = nil if profile active_rule = profile.active_by_rule_id(id) @@ -161,10 +191,10 @@ class Rule < ActiveRecord::Base if remove_blank(options[:plugins]) plugins = options[:plugins] unless options[:language].blank? - plugins = plugins & java_facade.getRuleRepositoriesByLanguage(options[:language]).collect{ |repo| repo.getKey() } + plugins = plugins & java_facade.getRuleRepositoriesByLanguage(options[:language]).collect { |repo| repo.getKey() } end elsif !options[:language].blank? - plugins = java_facade.getRuleRepositoriesByLanguage(options[:language]).collect{ |repo| repo.getKey() } + plugins = java_facade.getRuleRepositoriesByLanguage(options[:language]).collect { |repo| repo.getKey() } end if plugins @@ -177,16 +207,22 @@ class Rule < ActiveRecord::Base end unless options[:searchtext].blank? - conditions << "(UPPER(rules.name) LIKE :searchtext OR plugin_rule_key = :key)" searchtext = options[:searchtext].to_s.strip + search_text_conditions='(UPPER(rules.name) LIKE :searchtext OR plugin_rule_key = :key' + + additional_keys=java_facade.searchRuleName(I18n.locale, searchtext) + additional_keys.each do |java_rule_key| + search_text_conditions<<" OR (plugin_name='#{java_rule_key.getRepositoryKey()}' AND plugin_rule_key='#{java_rule_key.getKey()}')" + end + + search_text_conditions<<')' + conditions << search_text_conditions values[:searchtext] = "%" << searchtext.clone.upcase << "%" values[:key] = searchtext end includes=(options[:include_parameters] ? :rules_parameters : nil) - rules = Rule.find(:all, :order => 'rules.name', :include => includes, - :conditions => [conditions.join(" AND "), values]) - + rules = Rule.find(:all, :include => includes, :conditions => [conditions.join(" AND "), values]).sort_by { |rule| rule.name } filter(rules, options) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb index d7c67334baa..360b4f988af 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb @@ -1,22 +1,22 @@ - # - # Sonar, entreprise quality control tool. - # Copyright (C) 2008-2011 SonarSource - # mailto:contact AT sonarsource DOT com - # - # Sonar is free software; you can redistribute it and/or - # modify it under the terms of the GNU Lesser General Public - # License as published by the Free Software Foundation; either - # version 3 of the License, or (at your option) any later version. - # - # Sonar is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - # Lesser General Public License for more details. - # - # You should have received a copy of the GNU Lesser General Public - # License along with {library}; if not, write to the Free Software - # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - # +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with {library}; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# class RulesParameter < ActiveRecord::Base validates_presence_of :name, :param_type @@ -29,17 +29,30 @@ class RulesParameter < ActiveRecord::Base PARAM_TYPE_INTEGER_LIST = "i{}"; PARAM_TYPE_BOOLEAN = "b"; PARAM_TYPE_REGEXP = "r"; - + belongs_to :rule def is_set_type - return param_type.at(1) == "[" && param_type.ends_with?( "]" ) + return param_type.at(1) == "[" && param_type.ends_with?("]") end - + def get_allowed_tokens - return param_type[2,param_type.length-3].split( "," ) + return param_type[2, param_type.length-3].split(",") + end + + def description + @l10n_description ||= + begin + result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleParamDescription(I18n.locale, rule.repository_key, rule.plugin_rule_key, name()) + result = read_attribute(:description) unless result + result + end end - + + def description=(value) + write_attribute(:description, value) + end + def readable_param_type return "String" if param_type == PARAM_TYPE_STRING return "Set of string (, as delimiter)" if param_type == PARAM_TYPE_STRING_LIST @@ -49,55 +62,55 @@ class RulesParameter < ActiveRecord::Base return "Regular expression" if param_type == PARAM_TYPE_REGEXP return "Set of values (, as delimiter)" if is_set_type end - + def input_box_size return 15 if param_type == PARAM_TYPE_STRING or param_type == PARAM_TYPE_STRING_LIST or param_type == PARAM_TYPE_REGEXP return 8 if param_type == PARAM_TYPE_INTEGER or param_type == PARAM_TYPE_INTEGER_LIST return 4 if param_type == PARAM_TYPE_BOOLEAN if is_set_type - size = ( param_type.length / 2 ).to_i + size = (param_type.length / 2).to_i size = 64 if size > 64 return size end end def validate_value(attribute, errors, value) - return if attribute.nil? or attribute.length == 0 - if is_set_type - provided_tokens = attribute.split( "," ) - allowed_tokens = get_allowed_tokens - provided_tokens.each do |provided_token| - if !allowed_tokens.include?(provided_token) - errors.add( "#{value}", "Invalid value '" + provided_token + "'. Must be one of : " + allowed_tokens.join(", ") ) - end - end - elsif param_type == RulesParameter::PARAM_TYPE_INTEGER - begin - Kernel.Integer(attribute) - rescue - errors.add( "#{value}", "Invalid value '" + attribute + "'. Must be an integer." ) - end - elsif param_type == RulesParameter::PARAM_TYPE_INTEGER_LIST - provided_numbers = attribute.split( "," ) - provided_numbers.each do |provided_number| - begin - Kernel.Integer(provided_number) - rescue - errors.add("#{value}", "Invalid value '" + provided_number + "'. Must be an integer." ) - return - end - end - elsif param_type == RulesParameter::PARAM_TYPE_BOOLEAN - if attribute != "true" && attribute != "false" - errors.add( "#{value}", "Invalid value '" + attribute + "'. Must be one of : true,false" ) - end - elsif param_type == RulesParameter::PARAM_TYPE_REGEXP - begin - Regexp.new(attribute) - rescue - errors.add( "#{value}", "Invalid regular expression '" + attribute + "'.") - end - end + return if attribute.nil? or attribute.length == 0 + if is_set_type + provided_tokens = attribute.split(",") + allowed_tokens = get_allowed_tokens + provided_tokens.each do |provided_token| + if !allowed_tokens.include?(provided_token) + errors.add("#{value}", "Invalid value '" + provided_token + "'. Must be one of : " + allowed_tokens.join(", ")) + end + end + elsif param_type == RulesParameter::PARAM_TYPE_INTEGER + begin + Kernel.Integer(attribute) + rescue + errors.add("#{value}", "Invalid value '" + attribute + "'. Must be an integer.") + end + elsif param_type == RulesParameter::PARAM_TYPE_INTEGER_LIST + provided_numbers = attribute.split(",") + provided_numbers.each do |provided_number| + begin + Kernel.Integer(provided_number) + rescue + errors.add("#{value}", "Invalid value '" + provided_number + "'. Must be an integer.") + return + end + end + elsif param_type == RulesParameter::PARAM_TYPE_BOOLEAN + if attribute != "true" && attribute != "false" + errors.add("#{value}", "Invalid value '" + attribute + "'. Must be one of : true,false") + end + elsif param_type == RulesParameter::PARAM_TYPE_REGEXP + begin + Regexp.new(attribute) + rescue + errors.add("#{value}", "Invalid regular expression '" + attribute + "'.") + end + end end def to_hash_json(active_rule) @@ -112,7 +125,7 @@ class RulesParameter < ActiveRecord::Base def to_xml(active_rule, xml) xml.param do xml.name(name) - xml.description {xml.cdata!(description)} + xml.description { xml.cdata!(description) } if active_rule active_parameter = active_rule.active_param_by_param_id(id) xml.value(active_parameter.value) if active_parameter diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb index 9a0d2b5eaa3..5a6fd0ea838 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -35,10 +35,6 @@ class Snapshot < ActiveRecord::Base has_one :source, :class_name => 'SnapshotSource', :dependent => :destroy has_many :violations, :class_name => 'RuleFailure' - has_many :async_measure_snapshots - has_many :async_measures, :through => :async_measure_snapshots - - STATUS_UNPROCESSED = 'U' STATUS_PROCESSED = 'P' @@ -98,10 +94,6 @@ class Snapshot < ActiveRecord::Base parent_snapshot_id.nil? end - def all_measures - measures + async_measures - end - def descendants children.map(&:descendants).flatten + children end @@ -219,7 +211,7 @@ class Snapshot < ActiveRecord::Base @measures_hash ||= begin hash = {} - all_measures.each do |measure| + measures.each do |measure| hash[measure.metric_id]=measure end hash diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb index 4cda2d6c6db..c13f215fe3b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/rule_priority.rb @@ -35,8 +35,8 @@ class Sonar::RulePriority PRIORITY_CRITICAL = Java::OrgSonarApiRules::RulePriority::CRITICAL.ordinal() PRIORITY_BLOCKER = Java::OrgSonarApiRules::RulePriority::BLOCKER.ordinal() - def self.to_s(failure_level) - case failure_level + def self.to_s(failure_level, translate=false) + text = case failure_level when Java::OrgSonarApiRules::RulePriority::BLOCKER.ordinal() Java::OrgSonarApiRules::RulePriority::BLOCKER.to_s when Java::OrgSonarApiRules::RulePriority::CRITICAL.ordinal() @@ -48,6 +48,12 @@ class Sonar::RulePriority when Java::OrgSonarApiRules::RulePriority::INFO.ordinal() Java::OrgSonarApiRules::RulePriority::INFO.to_s end + + return text unless translate + + i18n_key = 'severity.' + text + result = Api::Utils.message(i18n_key, :default => as_text_map[text]) + result end def self.id(priority) @@ -58,7 +64,7 @@ class Sonar::RulePriority nil end end - + def self.as_array @@priorities_a ||= [] return @@priorities_a if @@priorities_a.size > 0 @@ -89,15 +95,26 @@ class Sonar::RulePriority priority==PRIORITY_BLOCKER end + @@priority_text_map={} + + def self.as_text_map + return @@priority_text_map if @@priority_text_map.size > 0 + @@priority_text_map[to_s(PRIORITY_INFO)]='Info' + @@priority_text_map[to_s(PRIORITY_MINOR)]='Minor' + @@priority_text_map[to_s(PRIORITY_MAJOR)]='Major' + @@priority_text_map[to_s(PRIORITY_CRITICAL)]='Critical' + @@priority_text_map[to_s(PRIORITY_BLOCKER)]='Blocker' + @@priority_text_map + end + def self.as_options @@priority_options ||= [] return @@priority_options if @@priority_options.size > 0 - @@priority_options << ['Info', to_s(PRIORITY_INFO)] - @@priority_options << ['Minor', to_s(PRIORITY_MINOR)] - @@priority_options << ['Major', to_s(PRIORITY_MAJOR)] - @@priority_options << ['Critical', to_s(PRIORITY_CRITICAL)] - @@priority_options << ['Blocker', to_s(PRIORITY_BLOCKER)] + @@priority_options << [as_text_map[to_s(PRIORITY_INFO)], to_s(PRIORITY_INFO)] + @@priority_options << [as_text_map[to_s(PRIORITY_MINOR)], to_s(PRIORITY_MINOR)] + @@priority_options << [as_text_map[to_s(PRIORITY_MAJOR)], to_s(PRIORITY_MAJOR)] + @@priority_options << [as_text_map[to_s(PRIORITY_CRITICAL)], to_s(PRIORITY_CRITICAL)] + @@priority_options << [as_text_map[to_s(PRIORITY_BLOCKER)], to_s(PRIORITY_BLOCKER)] @@priority_options end - end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb index 0be1a8494c9..4c9baa68cd5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap_builder.rb @@ -25,9 +25,8 @@ class Sonar::TreemapBuilder CONFIGURATION_DEFAULT_SIZE_METRIC = 'sonar.core.treemap.sizemetric' def self.size_metrics(options={}) - exclude_user_managed=options[:exclude_user_managed]||false - Metric.all.select{ |metric| - metric.treemap_size? && (!exclude_user_managed || !metric.user_managed?) + Metric.all.select{ |metric| + metric.treemap_size? }.sort end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb index f7477586cff..7635670b6b0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/user.rb @@ -27,10 +27,10 @@ class User < ActiveRecord::Base has_many :user_roles, :dependent => :delete_all has_many :properties, :foreign_key => 'user_id', :dependent => :delete_all has_many :active_filters, :include => 'filter', :order => 'order_index' - has_many :filters, :dependent => :delete_all + has_many :filters, :dependent => :destroy - has_many :active_dashboards, :dependent => :delete_all, :order => 'order_index' - has_many :dashboards, :dependent => :delete_all + has_many :active_dashboards, :dependent => :destroy, :order => 'order_index' + has_many :dashboards, :dependent => :destroy include Authentication include Authentication::ByPassword diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb index a47ba81b6e5..4aa241e38d3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb @@ -22,6 +22,7 @@ class WidgetProperty < ActiveRecord::Base TYPE_BOOLEAN = 'BOOLEAN' TYPE_FLOAT = 'FLOAT' TYPE_STRING = 'STRING' + TYPE_METRIC = 'METRIC' belongs_to :widget @@ -44,6 +45,8 @@ class WidgetProperty < ActiveRecord::Base Float(value) when TYPE_BOOLEAN value=='true' + when TYPE_METRIC + Metric.by_key(value.to_s) else value end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb index 23486909d89..317922eeadc 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/account/index.html.erb @@ -1,65 +1,86 @@ <h1>My profile</h1> -<br/> - -<table> +<div class="admin"> +<table class="form"> <tr> <td><b>Login:</b></td> - <td class="sep"> </td> <td id="login"><%= current_user.login %></td> </tr> <tr> <td><b>Name:</b></td> - <td class="sep"> </td> <td id="name"><%= current_user.name %></td> </tr> <tr> + <td><b>Email:</b></td> + <td id="name"><%= current_user.email %></td> + </tr> + <tr> <td><b>Groups:</b></td> - <td class="sep"> </td> <td id="groups"><%= current_user.groups.sort.map(&:name).join(', ') %></td> </tr> </table> -<br/> +</div> <% if User.editable_password? %> <h1>Change password</h1> -<br/> +<div class="admin"> <% form_tag( {:action => 'change_password' }, :id => 'pass_form_tag', :name => 'pass_form_tag') do -%> - <table> - <tr> - <td nowrap> - <label for="old_password"><b>Old value:</b></label> - </td> - <td class="sep"> </td> - <td align="left"> - <%= password_field_tag 'old_password' %> - </td> + <table class="form"> + <tr> + <td class="keyCell"><label for="old_password"><b>Old value:</b></label></td> + <td><%= password_field_tag 'old_password' %></td> </tr> <tr> - <td nowrap> - <label for="password"><b>New value:</b></label> - </td> - <td class="sep"> </td> - <td align="left"> - <%= password_field_tag 'password' %> - </td> - </tr> - <tr> - <td nowrap> - <label for="password_confirmation"><b>Confirm new value:</b></label> - </td> - <td class="sep"> </td> - <td align="left"> - <%= password_field_tag 'password_confirmation' %> - </td> - </tr> - - </table> - <br/> - <%= submit_tag 'Change password' %> + <td class="keyCell"><label for="password"><b>New value:</b></label></td> + <td><%= password_field_tag 'password' %></td> + </tr> + <tr> + <td class="keyCell"><label for="password_confirmation"><b>Confirm new value:</b></label></td> + <td><%= password_field_tag 'password_confirmation' %></td> + </tr> + <tr> + <td></td> + <td><%= submit_tag 'Change password' %></td> + </tr> + </table> <% end %> - <script type="text/javascript"> - //<![CDATA[ + + <script type="text/javascript"> + //<![CDATA[ $('pass_form_tag').focusFirstElement(); //]]> - </script> -<% end -%>
\ No newline at end of file + </script> +</div> +<% end -%> + +<h1>Notifications</h1> +<div class="admin"> +<% form_tag({:action => 'update_notifications'}, {:method => 'post'}) do %> + <table class="form"> + <tr> + <td></td> + <% for channel in @channels %> + <td><b><%= message('notification.channel.' + channel.getKey()) -%></b></td> + <% end %> + </tr> + <% for dispatcher in @dispatchers %> + <tr> + <td><b><%= message('notification.dispatcher.' + dispatcher.getKey()) -%></b></td> + <td> + <% + for channel in @channels + notification_id = dispatcher.getKey() + '.' + channel.getKey() + check_box_id = 'notifications[' + notification_id + ']' + check_box_checked = @notifications[notification_id] + %> + <%= check_box_tag check_box_id, 'true', check_box_checked %> + <% end %> + </td> + </tr> + <% end %> + <tr> + <td></td> + <td><%= submit_tag %></td> + </tr> + </table> +<% end %> +</div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_edit.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_edit.html.erb index 47c531322a3..419fbf2b5ce 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_edit.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_edit.html.erb @@ -6,22 +6,22 @@ </td> <td width="10%" nowrap> <select id="alert_operator" name="alert[operator]"> - <% operators_for_select(alert).each_pair do |name, key| %> - <option value="<%= key -%>" <%= 'selected' if alert.operator==key -%>><%= name -%></option> + <% operators_for_select(alert).each do |key| %> + <option value="<%= key -%>" <%= 'selected' if alert.operator==key -%>><%= message("alert.operator.#{key}") -%></option> <% end %> </select> </td> <td width="20%" align="left"> - <%= image_tag 'levels/warn.png', :alt => 'Warning threshold' %> + <%= image_tag 'levels/warn.png', :alt => message('alert.warning_tooltip') %> <%= value_field(alert, alert.value_warning, 'alert[value_warning]') %> <%= alert.metric.suffix if alert.metric %> </td> <td width="20%" align="left"> - <%= image_tag 'levels/error.png', :alt => 'Error threshold' %> + <%= image_tag 'levels/error.png', :alt => message('alert.error_tooltip') %> <%= value_field(alert, alert.value_error, 'alert[value_error]') %> <%= alert.metric.suffix if alert.metric %> </td> <td width="120px" nowrap> - <input id="alert_submit" type="submit" value="Update"></input> - <%= link_to 'Delete', {:action => 'delete', :id => alert.id, :profile_id =>@profile.id}, :confirm => 'Are you sure?', :method => :post, :class => 'action', :id => "delete_#{u alert.name}" %> + <input id="alert_submit" type="submit" value="<%= message('update_verb') -%>"></input> + <%= link_to message('delete'), {:action => 'delete', :id => alert.id, :profile_id =>@profile.id}, :confirm => message('are_you_sure'), :method => :post, :class => 'action', :id => "delete_#{u alert.name}" %> </td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_new.html.erb index a3e6dcbc2f8..572127c5ad8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_new.html.erb @@ -1,4 +1,4 @@ -<h3>Create alert</h3> +<h3><%= message('alert.create_alert') -%></h3> <%= form_remote_tag :url => {:action => 'create', :profile_id => @profile.id}, :html => {:id => 'new_alert_form'} %> <table class="spaced"> <tr> @@ -12,7 +12,7 @@ </script> <select id="alert_metric_id" name="alert[metric_id]" onChange="javascript:selectMetric()"> - <option value="" <%= 'selected' if @alert.metric.nil? %>>Select a metric</option> + <option value="" <%= 'selected' if @alert.metric.nil? %>><%= message('alert.select_metric') -%></option> <% Metric.domains.each do |domain| %> <optgroup label="<%= h domain -%>"> <%# 'new_' metrics excluded due to SONAR-2396 %> @@ -28,28 +28,28 @@ <select id="alert_operator" name="alert[operator]"> <% default_op=default_operator(@alert) - operators_for_select(@alert).each_pair do |name, key| %> - <option value="<%= key -%>" <%= 'selected' if default_op==key -%>><%= name -%></option> + operators_for_select(@alert).each do |key| %> + <option value="<%= key -%>" <%= 'selected' if default_op==key -%>><%= message("alert.operator.#{key}") -%></option> <% end %> </select> </td> <td width="20%" valign="top"> - <%= image_tag 'levels/warn.png', :alt => 'A warning is triggered when this value is reached.' %> + <%= image_tag 'levels/warn.png', :alt => message('alert.warning_tooltip') %> <%= value_field(@alert, '', 'alert[value_warning]') %> <%= @alert.metric.suffix if @alert.metric %><br/> - <span class="note">Warning threshold</span> + <span class="note"><%= message('alert.warning_threshold') -%></span> </td> <td width="20%" valign="top"> - <%= image_tag 'levels/error.png', :alt => 'An error is triggered when this value is reached.' %> + <%= image_tag 'levels/error.png', :alt => message('alert.error_tooltip') %> <%= value_field(@alert, '', 'alert[value_error]') %> <%= @alert.metric.suffix if @alert.metric %><br/> - <span class="note">Error threshold</span> + <span class="note"><%= message('alert.error_threshold') -%></span> </td> <td width="120px" nowrap valign="top"> - <input type="submit" value="Create" id="submit_create"></input> + <input type="submit" value="<%= message('create') -%>" id="submit_create"></input> </td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_show.html.erb index 77ee3fb5c89..f03e9edea33 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_show.html.erb @@ -4,17 +4,17 @@ <%= h alert.name %> </td> <td width="10%"> - <%= operators_for_select(alert).invert[alert.operator] %> + <%= message("alert.operator.#{alert.operator}") -%> </td> <td width="20%"> <% if alert.metric && !alert.value_warning.blank? %> - <%= image_tag 'levels/warn.png', :alt => 'Warning threshold' %> + <%= image_tag 'levels/warn.png', :alt => message('alert.warning_tooltip') %> <%= alert.value_warning %> <%= alert.metric.suffix if alert.metric %> <% end %> </td> <td width="20%"> <% if alert.metric && !alert.value_error.blank? %> - <%= image_tag 'levels/error.png', :alt => 'Error threshold' %> + <%= image_tag 'levels/error.png', :alt => message('alert.error_tooltip') %> <%= alert.value_error %> <%= alert.metric.suffix %> <% end %> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/edit.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/edit.html.erb index 5d935f10844..97071fb8ad1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/edit.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/edit.html.erb @@ -1,4 +1,4 @@ -<h1>Editing alert</h1> +<h1><%= message('alert.editing_alert') -%></h1> <% form_for([@profile, @alert]) do |f| %> <%= f.error_messages %> @@ -12,9 +12,9 @@ <%= f.text_field :name %> </p> <p> - <%= f.submit "Update" %> + <%= f.submit message('update_verb') %> </p> <% end %> -<%= link_to 'Show', [@profile, @alert] %> | -<%= link_to 'Back', profile_alerts_path(@profile) %> +<%= link_to message('show_verb'), [@profile, @alert] %> | +<%= link_to message('back'), profile_alerts_path(@profile) %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/index.html.erb index 78339cbc2ac..c70c6239f28 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/index.html.erb @@ -1,11 +1,11 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Alerts'} %> <% if is_admin? %> <% if @profile.provided? %> <div class="tabs-panel marginbottom10 background-gray"> <div class="line-info note"> - This profile can not be updated but it can be used as a template for your own configuration. Just copy it from the profiles page. + <%= message('rules_configuration.profile_cant_be_updated_description') -%> </div> </div> <% else %> @@ -19,7 +19,7 @@ <% if @alerts.empty? %> -<p id="alerts">No alerts.</p> +<p id="alerts"><%= message('alerts.no_alerts') -%></p> <% else %> <table class="data width100 marginbottom10" id="alerts"> @@ -43,16 +43,15 @@ <br/> <div class="help"> <h3>Notes</h3> -<p>Only project measures are checked against thresholds. Modules, packages and classes are ignored.</p> -Project health icons represent : +<%= message('alerts.notes.description') -%> <table class="data"> <thead> <tr><th colspan="3"></th></tr> </thead> <tbody> -<tr class="even"><td><%= image_tag 'levels/ok.png' %></td><td> at least one threshold is defined, no threshold is reached.</td></tr> -<tr class="odd"><td><%= image_tag 'levels/warn.png' %></td><td> at least one warning threshold is reached, no error threshold is reached.</td></tr> -<tr class="even"><td><%= image_tag 'levels/error.png' %></td><td>at least one error threshold is reached.</td></tr> +<tr class="even"><td><%= image_tag 'levels/ok.png' %></td><td> <%= message('alerts.notes.ok') -%></td></tr> +<tr class="odd"><td><%= image_tag 'levels/warn.png' %></td><td> <%= message('alerts.notes.warn') -%></td></tr> +<tr class="even"><td><%= image_tag 'levels/error.png' %></td><td> <%= message('alerts.notes.error') -%></td></tr> </tbody> </table> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/new.html.erb index 354aae26e32..cbf0989e497 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/new.html.erb @@ -1,4 +1,4 @@ -<h1>New alert</h1> +<h1><%= message('alert.new_alert') -%></h1> <% form_for([@profile, @alert]) do |f| %> <%= f.error_messages %> @@ -12,8 +12,8 @@ <%= f.text_field :name %> </p> <p> - <%= f.submit "Create" %> + <%= f.submit message('create') %> </p> <% end %> -<%= link_to 'Back', profile_alerts_path(@profile) %> +<%= link_to message('back'), profile_alerts_path(@profile) %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/show.html.erb index 4bfe7d68984..24c39d32db7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/alerts/show.html.erb @@ -1,13 +1,13 @@ <p> - <b>Profile:</b> + <b><%= message('profile') -%>:</b> <%=h @alert.profile_id %> </p> <p> - <b>Name:</b> + <b><%= message('name') -%>:</b> <%=h @alert.name %> </p> -<%= link_to 'Edit', edit_profile_alert_path(@profile, @alert) %> | -<%= link_to 'Back', profile_alerts_path(@profile) %> +<%= link_to message('edit'), edit_profile_alert_path(@profile, @alert) %> | +<%= link_to message('back'), profile_alerts_path(@profile) %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb index 609dc6fcff1..5edc83b7fc1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb @@ -21,21 +21,21 @@ <form id="cloudform" action="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>" method="GET"> <ul class="headerLine"> <li> - <span>Color:</span> + <span><%= message('color') -%>:</span> <select name="color" onchange="document.forms['cloudform'].submit()"> <% if @snapshot.measure('coverage') %> - <option value="coverage" <%= 'selected' if @color_metric.key=='coverage' -%>>Coverage</option> + <option value="coverage" <%= 'selected' if @color_metric.key=='coverage' -%>><%= message('metric.coverage.name') -%></option> <% end %> - <option value="violations_density" <%= 'selected' if @color_metric.key=='violations_density' -%>>Rules compliance</option> + <option value="violations_density" <%= 'selected' if @color_metric.key=='violations_density' -%>><%= message('metric.violations_density.name') -%></option> </select> </li> <li class="sep"> </li> <li> <input type="radio" name="size" value="ncloc" <%= 'checked' if @size_metric.key=='ncloc' -%> onclick="document.forms['cloudform'].submit()" id="radio-quick"> - <label for="radio-quick">Quick wins</label></option> + <label for="radio-quick"><%= message('cloud.quick_wins') -%></label></option> <input type="radio" name="size" value="function_complexity" <%= 'checked' if @size_metric.key=='function_complexity' -%> onclick="document.forms['cloudform'].submit()" id="radio-top"> - <label for="radio-top">Top risk</label></input> + <label for="radio-top"><%= message('cloud.top_risk') -%></label></input> </li> </ul> </form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml index a87eec11769..9af86fae226 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_edit_mode_controls.rhtml @@ -4,10 +4,10 @@ <% addeable_columns = components_configuration.addeable_columns %> <% if addeable_columns.size > 0 %> <tr> - <td colspan="2"><%= image_tag 'warning.png' %> Note that these changes will impact all users and all projects.</td> + <td colspan="2"><%= image_tag 'warning.png' %> <%= message('components.note_changes_impact_all_users') -%></td> </tr> <tr> - <td width="1%" nowrap>Add a column</td> + <td width="1%" nowrap><%= message('add_a_column') -%></td> <td> <form action="<%= url_for :controller => "columns", :action => "add" -%>" > <input type="hidden" name="rid" value="<%= @project.id if @project %>" /> @@ -27,12 +27,12 @@ </tr> <% end %> <tr> - <td width="1%" nowrap>Default sort on </td> + <td width="1%" nowrap><%= message('default_sort_on') -%> </td> <td> <form action="<%= url_for :controller => "columns", :action => "default_sorting" -%>"> <input type="hidden" name="rid" value="<%= @project.id if @project %>" /> <select name="id" onchange="$('sort_column_loading').show();submit();" id="select_default_sorting"> - <option value="project" <%= 'selected' if components_configuration.sorted_by_project_name? -%>>Project name</option> + <option value="project" <%= 'selected' if components_configuration.sorted_by_project_name? -%>><%= message('project_name') -%></option> <% configured_columns.sort_by{|col| col.name}.each do |column| if column.sortable? %> <option value="<%= column.id -%>" <%= 'selected' if column.sort_default? -%>><%= column.name %></option> @@ -45,9 +45,9 @@ </tr> <tr> <td colspan="2"> - <%= link_to( "Enable treemap", + <%= link_to( message('enable_treemap'), {:controller => "columns", :action => "toggle_treemap", :rid => @project.id}, {:class => 'action'} ) if (!components_configuration.treemap_enabled?) %> - <%= link_to( "Disable treemap", + <%= link_to( message('disable_treemap'), {:controller => "columns", :action => "toggle_treemap", :rid => @project.id}, {:class => 'action'} ) if components_configuration.treemap_enabled? %> <%= image_tag("treemap_icon.png") %> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml index 7e1300fdd75..14fb516daf0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header.rhtml @@ -3,7 +3,7 @@ <tr > <th></th> <th class="nosort"></th> - <th class="left text <%= 'sortfirstasc' if @components_configuration.sorted_by_project_name? -%>">Name</th> + <th class="left text <%= 'sortfirstasc' if @components_configuration.sorted_by_project_name? -%>"><%= message('name') -%></th> <% configured_columns.each do |column| %> <th class="<%= column.get_table_header_css %>" style="padding-right: 15px"><%= column.name %></th> <% end %> @@ -27,7 +27,7 @@ <tr> <th></th> <th class="nosort"></th> - <th class="left text <%= 'sortfirstasc' if @components_configuration.sorted_by_project_name? -%>">Name</th> + <th class="left text <%= 'sortfirstasc' if @components_configuration.sorted_by_project_name? -%>"><%= message('name') -%></th> <% configured_columns.each do |column| %> <th class="<%= column.get_table_header_css %>"><%= column.name %></th> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header_edit_mode.rhtml b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header_edit_mode.rhtml index 6bcdaf3f545..bfa5c4bad3d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header_edit_mode.rhtml +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_list_table_header_edit_mode.rhtml @@ -2,7 +2,7 @@ <tr> <th></th> <th></th> - <th>Name</th> + <th><%= message('name') -%></th> <% configured_columns.each do |column| %> <th class="<%= column.get_table_header_css_no_sort %>"> <span id="project_title_<%= column.id %>"><%= column.name %></span> @@ -15,11 +15,11 @@ <th></td> <% configured_columns.each do |column| %> <th class="right nosort" nowrap="nowrap"> - <%= link_to( image_tag("controls/resultset_previous.png", :alt => "Move left", :id => "move_left_" + column.id), + <%= link_to( image_tag("controls/resultset_previous.png", :alt => message('move_left'), :id => "move_left_" + column.id), {:controller => "columns", :action => "left", :id => column.id, :rid => @project.id}, :class => 'nolink') if column.position > 0 %> - <%= link_to( image_tag("bin_closed.png", :alt => "Remove column", :id => "remove_" + column.id), + <%= link_to( image_tag("bin_closed.png", :alt => message('remove_column'), :id => "remove_" + column.id), {:controller => "columns", :action => "delete", :id => column.id, :rid => @project.id}, :class => 'nolink') %> - <%= link_to( image_tag("controls/resultset_next.png", :alt => "Move right", :id => "move_right_" + column.id), + <%= link_to( image_tag("controls/resultset_next.png", :alt => message('move_left'), :id => "move_right_" + column.id), {:controller => "columns", :action => "right", :id => column.id, :rid => @project.id}, :class => 'nolink') if column.position != configured_columns.size - 1 %> </th> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_treemap_settings.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_treemap_settings.html.erb index 01f8504fa54..13d15a14429 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/_treemap_settings.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/_treemap_settings.html.erb @@ -10,11 +10,11 @@ end remote_form_for :treemap, :url => url_params, :html => { :id => 'tm_form', :method => 'get' }, :loading => "$('tm_form').disable();$('tm_loading').show();", :complete => "$('tm_form').enable();$('tm_loading').hide();" do |form | %> -<%= submit_tag(value = "Update", :id => 'submit_treemap', :style => 'display:none;') %> +<%= submit_tag(value = message('update_verb'), :id => 'submit_treemap', :style => 'display:none;') %> <table class="spaced"> <tr> <td valign="bottom"> - <span class="comments">Size</span> + <span class="comments"><%= message('size') -%></span> <br/> <%= select_tag 'size_metric', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics, @treemap.size_metric.key), :id => 'select_size_metric', :class => 'small',:onchange => "$('submit_treemap').click();" %> @@ -22,7 +22,7 @@ remote_form_for :treemap, :url => url_params, :html => { :id => 'tm_form', :meth </tr> <tr> <td> - <span class="comments">Color</span> + <span class="comments"><%= message('color') -%></span> <span id="treemap_gradient" class="comments little"> <%= render :partial => 'components/treemap_gradient', :locals => {:color_metric => @treemap.color_metric} %> </span> @@ -35,7 +35,7 @@ remote_form_for :treemap, :url => url_params, :html => { :id => 'tm_form', :meth <% if configuring? && has_role?(:admin) %> <tr > - <td class="admin"><%= button_to 'Set as default', "#", :id => 'set_default_treemap', :onclick => "$('form_set_default').submit()" %></td> + <td class="admin"><%= button_to message('set_as_default'), "#", :id => 'set_default_treemap', :onclick => "$('form_set_default').submit()" %></td> </tr> <% end %> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb index b1483f04e00..be9fef2c6f3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/components/index.html.erb @@ -1,13 +1,13 @@ <% if is_admin? %> <div id="page-operations"> <ul class="operations"> - <li>Customize + <li><%= message('customize') -%> <% if configuring? %> - <span class="green"><b>ON</b></span> | - <a class="action" href="<%= url_for :overwrite_params => {:configuring => nil} -%>" id="configure-off">OFF</a> + <span class="green"><b><%= message('on').upcase -%></b></span> | + <a class="action" href="<%= url_for :overwrite_params => {:configuring => nil} -%>" id="configure-off"><%= message('off').upcase -%></a> <% else %> - <a class="action" href="<%= url_for :overwrite_params => {:configuring => 'true'} -%>" id="configure-on">ON</a> - | <span class="red"><b>OFF</b></span> + <a class="action" href="<%= url_for :overwrite_params => {:configuring => 'true'} -%>" id="configure-on"><%= message('on').upcase -%></a> + | <span class="red"><b><%= message('off').upcase -%></b></span> <% end %> </li> </ul> @@ -18,8 +18,8 @@ <%= render :partial => 'list_edit_mode_controls', :locals => {:configured_columns => @columns, :components_configuration => @components_configuration}%> <% end %> <% if @snapshots.empty? && @project.nil? %> -<h3>No projects have been analysed.</h3> -<p>If Maven and Sonar are installed with default parameters on the same box, just launch the command <code>mvn sonar:sonar</code> to analyse your first project. In any other case, please refer to the <a href="http://www.sonarsource.org/documentation">documentation</a>.</p> +<h3><%= message('components.no_projects_have_been_analysed') -%>No projects have been analysed.</h3> +<p><%= message('components.explanation_launch_sonar_to_have_results') -%></p> <% else %> <table width="100%"> <tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb index 10e27fa1ac8..08096680906 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb @@ -2,16 +2,16 @@ begin widget_body=render :inline => definition.getTarget().getTemplate(), :locals => {:widget_properties => widget.properties_as_hash, :widget => widget, :dashboard_configuration => @dashboard_configuration} rescue => error - logger.error("Can not render widget #{definition.getId()}: " + error) + logger.error(message('dashboard.cannot_render_widget_x', :params => [definition.getId(), error])) logger.error(error.backtrace.join("\n")) widget_body="" end %> <div class="handle" style="//overflow:hidden;//zoom:1;"> - <a class="block-remove" onclick="portal.deleteWidget(this);return false;">Delete</a> + <a class="block-remove" onclick="portal.deleteWidget(this);return false;"><%= message('delete') -%></a> <% if definition.isEditable() %> - <a class="block-view-toggle" onclick="portal.editWidget(<%= widget.id -%>);return false;">Edit</a> + <a class="block-view-toggle" onclick="portal.editWidget(<%= widget.id -%>);return false;"><%= message('edit') -%></a> <% end %> <%= definition.getTitle() -%> </div> @@ -41,7 +41,7 @@ <%= widget_body -%> <% if default_layout %><div class="clear"> </div></div><% end %> <% else %> - <div class="widget"><p>No data</p></div> + <div class="widget"><p><%= message('no_data') -%></p></div> <% end %> <div style="clear: both;"></div> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb index b03580a90fd..579f164064f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb @@ -2,13 +2,13 @@ <% if logged_in? %> <ul class="operations"> <% if back %> - <li class="last"><%= link_to 'Back to dashboard', {:action => 'index', :did => @dashboard.id, :id => @resource.id } -%></li> + <li class="last"><%= link_to message('dashboard.back_to_dashboard'), {:action => 'index', :did => @dashboard.id, :id => @resource.id } -%></li> <% else %> <% if @dashboard.editable_by?(current_user) %> - <li><%= link_to 'Configure widgets', {:action => 'configure', :did => @dashboard.id, :id => @resource.id } -%></li> - <li><%= link_to 'Edit layout', {:action => 'edit_layout', :did => @dashboard.id, :id => @resource.id } -%></li> + <li><%= link_to message('dashboard.configure_widgets'), {:action => 'configure', :did => @dashboard.id, :id => @resource.id } -%></li> + <li><%= link_to message('dashboard.edit_layout'), {:action => 'edit_layout', :did => @dashboard.id, :id => @resource.id } -%></li> <% end %> - <li class="last"><%= link_to 'Manage dashboards', {:controller => 'dashboards', :action => 'index', :resource => @resource.id } -%></li> + <li class="last"><%= link_to message('dashboard.manage_dashboards'), {:controller => 'dashboards', :action => 'index', :resource => @resource.id } -%></li> <% end %> </ul> <% end %> @@ -22,7 +22,7 @@ <form method="GET" action="<%= url_for :controller => 'dashboard', :action => 'index', :id => @resource.id -%>" style="display: inline"> <input type="hidden" name="did" value="<%= @dashboard.id -%>" /> <select id="select-comparison" name="period" onchange="submit()" class="small"> - <option value="">Time changes...</option> + <option value=""><%= message('time_changes') -%>...</option> <%= period_select_options(@snapshot, 1) -%> <%= period_select_options(@snapshot, 2) -%> <%= period_select_options(@snapshot, 3) -%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb index d9b61337aa0..54265983a6f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb @@ -4,7 +4,7 @@ begin widget_body=render :inline => definition.getTarget().getTemplate(), :locals => {:widget_properties => widget.properties_as_hash, :widget => widget, :dashboard_configuration => @dashboard_configuration} rescue => error - logger.error("Can not render widget #{definition.getId()}: " + error) + logger.error(message('dashboard.cannot_render_widget_x', :params => [definition.getId(), error])) logger.error(error.backtrace.join("\n")) widget_body="" end @@ -24,7 +24,7 @@ %> <% else %> <div class="widget"> - <p>Please <a href="<%= url_for :action => :configure, :did => @dashboard.id, :id => @resource.id -%>">configure</a> the widget <b><%= definition.getTitle() -%></b>.</p> + <p><a href="<%= url_for :action => :configure, :did => @dashboard.id, :id => @resource.id -%>"><%= message('dashboard.please_configure_the_widget_x', :params => definition.getTitle()) -%></a></p> </div> <% end %> <div style="clear: both;"></div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb index eaaceb181c2..c911a8c0e35 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb @@ -1,9 +1,9 @@ <td> <div class="widget_def" id="def_<%= definition.getId().tr('_', '') -%>"> -<p><b><%= h definition.getTitle() -%></b></p> -<p><%= h definition.getDescription() -%></p> +<p><b><%= h message('widget.' + definition.getId() + '.title', :default => definition.getTitle()) -%></b></p> +<p><%= h message('widget.' + definition.getId() + '.description', :default => definition.getDescription()) -%></p> <%= form_tag :action => 'add_widget', :did => dashboard_id, :id => resource_id, :widget => definition.getId() %> -<input type="submit" value="Add widget" > +<input type="submit" value="<%= message('dashboard.add_widget') -%>" > </form> </div> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb index 3a34c98cb6d..7713ecf70e2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb @@ -1,7 +1,7 @@ <p> <ul class="horizontal widget_categs"> - <li>Filter: </li> - <li class="<%= 'selected' if filter_on_category.blank? -%>"><a href="#" onClick="return filterWidgets('')">None</a></li> + <li><%= message('filter_verb') -%>: </li> + <li class="<%= 'selected' if filter_on_category.blank? -%>"><a href="#" onClick="return filterWidgets('')"><%= message('none') -%></a></li> <% @widget_categories.each do |category| %> <li class="<%= 'selected' if filter_on_category==category -%>"><a href="#" onClick="return filterWidgets('<%= category -%>')"><%= h(category) -%></a></li> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb index a1a5d8ae52a..5e61afa5646 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb @@ -21,9 +21,9 @@ <% end %> <tr> <td colspan="2"> - <%= submit_tag 'Save' %> + <%= submit_tag message('save') %> <% if widget.configured %> - <a href="#" onClick="portal.cancelEditWidget(<%= widget.id -%>);return false;">Cancel</a> + <a href="#" onClick="portal.cancelEditWidget(<%= widget.id -%>);return false;"><%= message('cancel') -%></a> <% end %> </td> </tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb index 02ec1c72596..30c241fe82c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb @@ -2,7 +2,7 @@ <%= render :partial => 'dashboard/header', :locals => {:back => true} %> <div id="edit-layout" class="admin"> - <p class="note">Click to choose the layout: </p><br/> + <p class="note"><%= message('dashboard.click_to_choose_layout') -%>: </p><br/> <div class="select-layout <%= 'selected' if @dashboard.layout=='100%' -%>" style="text-align:center;width: 20%;"> <%= link_to image_tag('layout100.png'), {:action => 'set_layout', :did => @dashboard.id, :id => @resource.id, :layout => "100%"}, :method => :post %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb index 72f6133a23f..f5aef418880 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb @@ -3,28 +3,28 @@ <form action="<%= url_for :action => 'create', :resource => params[:resource] -%>" id="create-dashboard-form" method="POST"> <tbody> <tr> - <td colspan="2"><h1>Create dashboard</h1></td> + <td colspan="2"><h1><%= message('dashboard.create_dashboard') -%></h1></td> </tr> <tr> <td class="left" valign="top"> - Name:<br/><input type="text" name="name" size="30" maxlength="256"></input> + <%= message('name') -%>:<br/><input type="text" name="name" size="30" maxlength="256"></input> </td> </tr> <tr> <td class="left" valign="top"> - Description:<br/><input type="text" name="description" size="30" maxlength="1000"></input> + <%= message('description') -%>:<br/><input type="text" name="description" size="30" maxlength="1000"></input> </td> </tr> <% if is_admin? %> <tr> <td class="left" valign="top"> - Shared:<br/><input type="checkbox" name="shared" value="true"></input> + <%= message('shared') -%>:<br/><input type="checkbox" name="shared" value="true"></input> </td> </tr> <% end %> <tr> <td class="left" valign="top"> - <input type="submit" value="Create dashboard"/> + <input type="submit" value="<%= message('dashboard.create_dashboard') -%>"/> </td> </tr> </tbody> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_edit.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_edit.html.erb index 14b734c41b7..400a4df767c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_edit.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_edit.html.erb @@ -2,29 +2,29 @@ <table class="admintable" width="100%"> <tbody> <tr> - <td colspan="2"><h1>Edit dashboard</h1></td> + <td colspan="2"><h1><%= message('dashboard.edit_dashboard') -%></h1></td> </tr> <tr> <td class="left" valign="top"> - Name:<br/><input type="text" name="name" size="30" maxlength="256" value="<%= @dashboard.name -%>"></input> + <%= message('name') -%>:<br/><input type="text" name="name" size="30" maxlength="256" value="<%= @dashboard.name -%>"></input> </td> </tr> <tr> <td class="left" valign="top"> - Description:<br/><input type="text" name="description" size="30" maxlength="1000" value="<%= @dashboard.description -%>"></input> + <%= message('description') -%>:<br/><input type="text" name="description" size="30" maxlength="1000" value="<%= @dashboard.description -%>"></input> </td> </tr> <% if is_admin? %> <tr> <td class="left" valign="top"> - Shared:<br/><input type="checkbox" name="shared" value="true" <%= 'checked' if @dashboard.shared -%>></input> + <%= message('shared') -%>:<br/><input type="checkbox" name="shared" value="true" <%= 'checked' if @dashboard.shared -%>></input> </td> </tr> <% end %> <tr> <td class="left" valign="top"> - <input type="submit" value="Update dashboard"/> - <a href="<%= url_for :action => 'index', :resource => params[:resource] -%>">Cancel</a> + <input type="submit" value="<%= message('dashboard.update_dashboard') -%>"/> + <a href="<%= url_for :action => 'index', :resource => params[:resource] -%>"><%= message('cancel') -%></a> </td> </tr> </tbody> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb index d6a1a26b7af..965cb7045dc 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb @@ -3,19 +3,19 @@ <tr> <td valign="top"> - <h1 class="marginbottom10">My dashboards</h1> + <h1 class="marginbottom10"><%= message('dashboard.my_dashboards') -%></h1> <table class="data marginbottom10" id="dashboards"> <thead> <tr> - <th>Name</th> - <% if is_admin %><th>Shared</th><% end %> - <th>Order</th> - <th>Operations</th> + <th><%= message('name') -%></th> + <% if is_admin %><th><%= message('shared') -%></th><% end %> + <th><%= message('order') -%></th> + <th><%= message('operations') -%></th> </tr> </thead> <tbody> <% if @actives.nil? || @actives.empty? %> - <tr class="even"><td colspan="5">No dashboards</td></tr> + <tr class="even"><td colspan="5"><%= message('dashboard.no_dashboard') -%></td></tr> <% else @actives.each_with_index do |active,index| %> @@ -43,13 +43,13 @@ </td> <td> <% if active.owner?(current_user) %> - <%= link_to 'Configure widgets', {:controller => :dashboard, :action => 'configure', :did => active.dashboard_id, :id => params[:resource]}, :id => "configure-#{u active.name}" %> + <%= link_to message('dashboard.configure_widgets'), {:controller => :dashboard, :action => 'configure', :did => active.dashboard_id, :id => params[:resource]}, :id => "configure-#{u active.name}" %> | - <%= link_to_remote "Edit", :update => "admin_form", :url => { :action => "edit", :id => active.dashboard_id, :resource => params[:resource] }, :id => "edit-#{u active.name}", :method => :get %> + <%= link_to_remote message('edit'), :update => "admin_form", :url => { :action => "edit", :id => active.dashboard_id, :resource => params[:resource] }, :id => "edit-#{u active.name}", :method => :get %> | - <%= link_to 'Delete', {:action => 'delete', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :confirm => 'Do you want to delete this dashboard ?', :id => "delete-#{u active.name}" %> + <%= link_to message('delete'), {:action => 'delete', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u active.name}" %> <% else %> - <%= link_to 'Unfollow', {:action => 'unfollow', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :id => "unfollow-#{u active.name}" %> + <%= link_to message('unfollow'), {:action => 'unfollow', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :id => "unfollow-#{u active.name}" %> <% end %> </td> </tr> @@ -59,18 +59,18 @@ </tbody> </table> <br/><br/> - <h1 class="marginbottom10">Shared dashboards</h1> + <h1 class="marginbottom10"><%= message('dashboard.shared_dashboards') -%></h1> <table class="data" id="shared-dashboards"> <thead> <tr> - <th>Name</th> - <th>Shared by</th> - <th>Operations</th> + <th><%= message('name') -%></th> + <th><%= message('shared_by') -%></th> + <th><%= message('operations') -%></th> </tr> </thead> <tbody> <% if @shared_dashboards.nil? || @shared_dashboards.empty? %> - <tr class="even"><td colspan="5">No dashboards</td></tr> + <tr class="even"><td colspan="5"><%= message('dashboard.no_dashboard') -%></td></tr> <% else @shared_dashboards.each do |dashboard| %> @@ -85,7 +85,7 @@ <%= dashboard.user_name -%> </td> <td> - <%= link_to 'Follow', {:action => 'follow', :id => dashboard.id, :resource => params[:resource]}, :method => :post, :id => "follow-#{u dashboard.name}" %> + <%= link_to message('follow'), {:action => 'follow', :id => dashboard.id, :resource => params[:resource]}, :method => :post, :id => "follow-#{u dashboard.name}" %> </td> </tr> <% end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dependencies/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dependencies/index.html.erb index 46531a6be5b..286578434ae 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dependencies/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dependencies/index.html.erb @@ -25,20 +25,19 @@ padding: 5px; </style> <form action="<%= ApplicationController.root_context -%>/dependencies/index" id="search_form"> <input type="text" name="search" value="<%= params[:search] -%>" id="search_input"> </input> - <input type="submit" value="Search library" id="search_submit"></input><br/> - <p class="small gray">Find out which projects depend on a given library.<br/> - Search by group, artifact or name. E.g.: org.apache.struts, struts-core or Struts</p> + <input type="submit" value="<%= message('dependencies.search_library') -%>" id="search_submit"></input><br/> + <p class="small gray"><%= message('dependencies.search_help') -%></p> </form> <div id="deps_drilldown"> <% if @resources %> <div id="artifacts_col" class="drilldown_col"> - <h3>Select library :</h3> + <h3><%= message('dependencies.select_library') -%> :</h3> <div class="col"> <table> <tbody> <% if @resources.empty? %> - <tr class="even"><td>No data</td></tr> + <tr class="even"><td><%= message('no_data') -%></td></tr> <% end %> <% @resources.each do |resource|%> <tr class="<%= cycle('even', 'odd', :name => 'lib') -%> <%= 'selected' if resource==@resource -%>"> @@ -53,7 +52,7 @@ padding: 5px; <% if @versions %> <div id="versions_col" class="drilldown_col"> - <h3>Select version :</h3> + <h3><%= message('dependencies.select_version') -%> :</h3> <div class="col"> <table> <tbody> @@ -75,12 +74,12 @@ padding: 5px; <% if @project_snapshots %> <div id="results_col" class="drilldown_col"> - <h3>Used by :</h3> + <h3><%= message('dependencies.used_by') -%> :</h3> <div class="col"> <table> <tbody> <% if @project_snapshots.empty? %> - <tr class="even"><td>Not used</td></tr> + <tr class="even"><td><%= message('dependencies.not_used') -%></td></tr> <% end %> <% @project_snapshots.each do |project_snapshot|%> <tr class="<%= cycle('even', 'odd', :name => 'dep') -%>"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb index 14c91ad345a..56eae8f5b59 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb @@ -1,6 +1,6 @@ <tr class="<%= css -%> <%= 'selected' if Sonar::RulePriority.to_s(priority_id)==params[:priority] -%>"> <td><%= image_tag "priority/#{priority_id}.png" %></td> - <td><%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period} %></td> + <td><%= link_to Sonar::RulePriority.to_s(priority_id, true), {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period} %></td> <td style="padding-left: 10px;" align="right"> <%= @period ? format_variation(measure, :index => @period, :style => 'light') : format_measure(measure) -%> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb index a3d3cb61ca4..7df550d7529 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb @@ -8,7 +8,7 @@ <select id="select-comparison" name="period" onchange="submit()" class="small"> <% if @drilldown.display_value? %> - <option value="">Time changes...</option> + <option value=""><%= message('time_changes') -%>...</option> <% end %> <% for period_index in 1..5 do %> <%= period_select_options(@snapshot, period_index) if @drilldown.display_period?(period_index) -%> @@ -34,7 +34,7 @@ <table id="drilldown" class="width100" style="clear:left"> <% if @highlighted_metric!=@metric %> <tr> -<td colspan="<%= @drilldown.columns.size -%>">Drilldown on <b><%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%></b></td> +<td colspan="<%= @drilldown.columns.size -%>"><%= message('drilldown.drilldown_on') -%> <b><%= format_measure(@metric.key, :period => @period) -%> <%= @metric.short_name -%></b></td> </tr> <tr> <% end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb index 6efef65afc9..1f2a829d1b2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb @@ -6,12 +6,11 @@ <% profile_measure=@snapshot.measure(Metric::PROFILE) %> -<%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %> -<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %> +<% if profile_measure %>Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %> - <% end %> <% if @snapshot.project_snapshot.periods? %> -- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline"> +<form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline"> <select id="select-comparison" name="period" onchange="submit()" class="small"> - <option value="">Time changes...</option> + <option value=""><%= message('time_changes') -%>...</option> <%= violation_period_select_options(@snapshot, 1) -%> <%= violation_period_select_options(@snapshot, 2) -%> <%= violation_period_select_options(@snapshot, 3) -%> @@ -49,17 +48,17 @@ max = value if value && value>max end %> - <h3>Severity</h3> + <h3><%= message('violations_drilldown.col.severity') -%></h3> <table class="spacedicon" style="border: 1px solid #ccc;"> - <%= render :partial => 'rule_priority', :locals => {:label => 'Blocker', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_BLOCKER, :max => max, :measure => blocker_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Critical', :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_CRITICAL, :max => max, :measure => critical_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Major', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_MAJOR, :max => max, :measure => major_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Minor', :css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_MINOR, :max => max, :measure => minor_violations }%> - <%= render :partial => 'rule_priority', :locals => {:label => 'Info', :css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_INFO, :max => max, :measure => info_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_BLOCKER, :max => max, :measure => blocker_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_CRITICAL, :max => max, :measure => critical_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_MAJOR, :max => max, :measure => major_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'odd', :priority_id => Sonar::RulePriority::PRIORITY_MINOR, :max => max, :measure => minor_violations }%> + <%= render :partial => 'rule_priority', :locals => {:css => 'even', :priority_id => Sonar::RulePriority::PRIORITY_INFO, :max => max, :measure => info_violations }%> </table> </td> <td class="column" align="left" style="white-space: normal;"> - <h3>Rule</h3> + <h3><%= message('violations_drilldown.col.rule') -%></h3> <div class="scrollable"> <table class="spacedicon" width="100%" id="col_rules"> <% @@ -97,7 +96,7 @@ %> <tr class="<%= clazz -%>"> <td width="1%" nowrap> - <a id="<%= "rule#{rule_index}" -%>" title="Click for more on <%= rule.plugin_name -%>: <%= rule.plugin_rule_key -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"><img src="<%= ApplicationController.root_context -%>/images/priority/<%= rule_measure.rule_priority -%>.png" /></a> + <a id="<%= "rule#{rule_index}" -%>" title="<%= message('violations_drilldown.click_for_more_on_x', :params => [rule.plugin_name, rule.plugin_rule_key]) -%>" onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => rule.key, :layout => 'false' -%>"><img src="<%= ApplicationController.root_context -%>/images/priority/<%= rule_measure.rule_priority -%>.png" /></a> </td> <td> <%= link_to(rule.name, {:overwrite_params => {:rule => rule.key, :sid => nil, :priority => Sonar::RulePriority.to_s(@priority_id)}}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") %> @@ -113,7 +112,7 @@ <% end %> <% if rule_index==0 %> - <tr class="even"><td>No violations</td></tr> + <tr class="even"><td><%= message('violations_drilldown.no_violations') -%></td></tr> <% end %> </table> </div> @@ -174,19 +173,19 @@ </table> <br/> <div style="font-size: 85%;background-color: #eee;color: #777;padding: 4px 5px;border: 1px solid #ddd;margin-bottom: 20px;"> -<b>Path:</b> +<b><%= message('violations_drilldown.path') -%>:</b> <% if @priority_id %> -<%= Sonar::RulePriority.to_s(@priority_id) %> <%= link_to 'clear', {:overwrite_params => {:priority => nil}} %> +<%= Sonar::RulePriority.to_s(@priority_id, true) %> <%= link_to message('clear_verb'), {:overwrite_params => {:priority => nil}} %> <% else %> -Any severity +<%= message('violations_drilldown.any_severity') -%> <% end %> » <% if @rule %> -<%= h @rule.name %> <%= link_to 'clear', {:overwrite_params => {:rule => nil}} %> +<%= h @rule.name %> <%= link_to message('clear_verb'), {:overwrite_params => {:rule => nil}} %> <% else %> -Any rule +<%= message('violations_drilldown.any_rule') -%> <% end %> » <% paths.each do |path| %> -<%= path[0] %> <%= link_to 'clear', {:overwrite_params => {:rids => path[1]}} %> » +<%= path[0] %> <%= link_to message('clear_verb'), {:overwrite_params => {:rids => path[1]}} %> » <% end %> </div> <script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/email_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/email_configuration/index.html.erb new file mode 100644 index 00000000000..d1bd745c14a --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/email_configuration/index.html.erb @@ -0,0 +1,70 @@ +<h1><%= message('email_configuration.page') -%></h1> +<div class="admin"> +<% form_tag({:action => 'save'}) do -%> + <table class="form"> + <tr> + <td class="keyCell"><label for="smtp_host"><%= message('email_configuration.smtp_host') -%>:</label></td> + <td><%= text_field_tag 'smtp_host', @smtp_host %></td> + <td class="comments"><%= message('email_configuration.smtp_host.description') -%></td> + </tr> + <tr> + <td class="keyCell"><label for="smtp_port"><%= message('email_configuration.smtp_port') -%>:</label></td> + <td><%= text_field_tag 'smtp_port', @smtp_port %></td> + <td class="comments"><%= message('email_configuration.smtp_port.description') -%></td> + </tr> + <tr> + <td class="keyCell"><label for="smtp_secure_connection"><%= message('email_configuration.smtp_secure_connection') -%>:</label></td> + <td><%= select_tag 'smtp_secure_connection', options_for_select({'No' => '', 'SSL' => 'ssl'}, @smtp_secure_connection) %></td> + <td class="comments"><%= message('email_configuration.smtp_secure_connection.description') -%></td> + </tr> + <tr> + <td class="keyCell"><label for="smtp_username"><%= message('email_configuration.smtp_username') -%>:</label></td> + <td><%= text_field_tag 'smtp_username', @smtp_username %></td> + <td class="comments"><%= message('email_configuration.smtp_username.description') -%></td> + </tr> + <tr> + <td class="keyCell"><label for="smtp_password"><%= message('email_configuration.smtp_password') -%>:</label></td> + <td><%= password_field_tag 'smtp_password', @smtp_password %></td> + <td class="comments"><%= message('email_configuration.smtp_password.description') -%></td> + </tr> + <tr> + <td class="keyCell"><label for="email_from"><%= message('email_configuration.from_address') -%>:</label></td> + <td><%= text_field_tag 'email_from', @email_from %></td> + <td class="comments"><%= message('email_configuration.from_address.description') -%></td> + </tr> + <tr> + <td class="keyCell"><label for="email_prefix"><%= message('email_configuration.email_prefix') -%>:</label></td> + <td><%= text_field_tag 'email_prefix', @email_prefix %></td> + <td class="comments"><%= message('email_configuration.email_prefix.description') -%></td> + </tr> + <tr> + <td></td> + <td><%= submit_tag message('save') %></td> + </tr> + </table> +<% end -%> +</div> + +<h1><%= message('email_configuration.test.title') -%></h1> +<div class="admin"> +<% form_tag({:action => 'send_test_email'}) do -%> + <table class="form"> + <tr> + <td class="keyCell"><label for="to_address"><%= message('email_configuration.test.to_address') -%>:</label></td> + <td><%= text_field_tag 'to_address', current_user.email %></td> + </tr> + <tr> + <td class="keyCell"><label for="subject"><%= message('email_configuration.test.subject') -%>:</label></td> + <td><%= text_field_tag 'subject', message('email_configuration.test.subject_text') %></td> + </tr> + <tr> + <td class="keyCell"><label for="message"><%= message('email_configuration.test.message') -%>:</label></td> + <td><%= text_area_tag 'message', message('email_configuration.test.message_text'), {:cols => 40, :rows => 6} %></td> + </tr> + <tr> + <td></td> + <td><%= submit_tag message('email_configuration.test.send') %></td> + </tr> + </table> +<% end -%> +</div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/events/edit.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/events/edit.html.erb index e6459cb8b31..a46f38c21e3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/events/edit.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/events/edit.html.erb @@ -8,12 +8,12 @@ </tr> <tr> <td class="left" nowrap="nowrap" valign="top" width="1%"> - <span class="comments">Name (required)</span><br> + <span class="comments"><%= message('events.name_required') -%></span><br> <%= f.text_field :name %> </td> <td class="left" nowrap="nowrap" valign="top"> - <span class="comments">Category (<%= link_to 'configure', {:controller=> 'event_categories', :action => 'index'}, :class => 'action' %>)</span><br> - <%= f.select(:category, @categories.collect {|c| [ c.name, c.name ] }, {:include_blank => true}, {:onChange => "selectEventCateg()"}) %> + <span class="comments"><%= message('category') -%> (<%= link_to message('configure').downcase, {:controller=> 'event_categories', :action => 'index'}, :class => 'action' %>)</span><br> + <%= f.select(:category, @categories.collect {|c| [ message('event.category.' + c.name, :default => c.name), c.name ] }, {:include_blank => true}, {:onChange => "selectEventCateg()"}) %> </td> </tr> <tr> @@ -25,19 +25,19 @@ </tr> <tr> <td class="left" nowrap="nowrap" valign="top" colspan="2"> - <span class="comments">Date</span><br> + <span class="comments"><%= message('date') -%></span><br> <%= f.date_select :event_date %> </td> </tr> <tr> <td class="left" nowrap="nowrap" valign="top" colspan="2"> - <span class="comments">Description</span><br> + <span class="comments"><%= message('description') -%></span><br> <%= f.text_area :description, :cols => 50, :rows => 3 %> </td> </tr> <tr> <td class="left" nowrap="nowrap" valign="top" colspan="2"> - <%= f.submit "Update" %> <a href="#" onclick="$('event_form').hide()" class="action">cancel</a> + <%= f.submit message('update_verb') %> <a href="#" onclick="$('event_form').hide()" class="action"><%= message('cancel') -%></a> </td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/events/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/events/new.html.erb index 002a4b64e95..a04f5dc8be9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/events/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/events/new.html.erb @@ -8,36 +8,36 @@ </tr> <tr> <td class="left" nowrap="nowrap" valign="top" width="1%"> - <span class="comments">Name (required)</span><br> + <span class="comments"><%= message('events.name_required') -%></span><br> <%= f.text_field :name %> </td> <td class="left" nowrap="nowrap" valign="top"> - <span class="comments">Category (<%= link_to 'configure', {:controller=> 'event_categories', :action => 'index'}, :class => 'action' %>)</span><br> - <%= f.select(:category, @categories.collect {|c| [ c.name, c.name ] }, {:include_blank => true}, {:onChange => "selectEventCateg()"}) %> + <span class="comments"><%= message('category') -%> (<%= link_to message('configure').downcase, {:controller=> 'event_categories', :action => 'index'}, :class => 'action' %>)</span><br> + <%= f.select(:category, @categories.collect {|c| [ message('event.category.' + c.name, :default => c.name), c.name ] }, {:include_blank => true}, {:onChange => "selectEventCateg()"}) %> </td> </tr> <tr> <td colspan="2" id="event_cat_desc"> <% @categories.each do |categ| %> - <span id='event_cat_desc_<%= categ.name -%>' style="display:none;" class='comments'><%= categ.description -%></span> + <span id='event_cat_desc_<%= categ.name -%>' style='display:none' class='comments'><%= categ.description -%></span> <% end %> <td> </tr> <tr> <td class="left" nowrap="nowrap" valign="top" colspan="2"> - <span class="comments">Date</span><br> + <span class="comments"><%= message('date') -%></span><br> <%= f.date_select :event_date %> </td> </tr> <tr> <td class="left" nowrap="nowrap" valign="top" colspan="2"> - <span class="comments">Description</span><br> + <span class="comments"><%= message('description') -%></span><br> <%= f.text_area :description, :cols => 50, :rows => 3 %> </td> </tr> <tr> <td class="left" nowrap="nowrap" valign="top" colspan="2"> - <%= f.submit "Create" %> <a href="#" onclick="$('event_form').hide()" class="action">cancel</a> + <%= f.submit message('create') %> <a href="#" onclick="$('event_form').hide()" class="action"><%= message('cancel') -%></a> </td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_criterion.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_criterion.html.erb index 93067046dda..34d80b2abce 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_criterion.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_criterion.html.erb @@ -7,7 +7,7 @@ } </script> <select name="criteria[<%= id -%>][metric_id]" id="metric-<%= id -%>"> - <option value="">Select a metric</option> + <option value=""><%= message('select_a_metric') -%></option> <% Metric.domains.each do |domain| %> <optgroup label="<%= h domain -%>"> <% Metric.by_domain(domain).select{|m| !m.data? && !m.hidden?}.each do |metric| %> @@ -17,16 +17,16 @@ <% end %> </select> <select name="criteria[<%= id -%>][type]" id="type-<%= id -%>"> - <option value="value" <%= 'selected' unless (criterion && criterion.variation) -%>>Value</option> - <option value="variation" <%= 'selected' if criterion && criterion.variation -%>>Variation</option> + <option value="value" <%= 'selected' unless (criterion && criterion.variation) -%>><%= message('value') -%></option> + <option value="variation" <%= 'selected' if criterion && criterion.variation -%>><%= message('variation') -%></option> </select> <select name="criteria[<%= id -%>][operator]" id="op-<%= id -%>"> <option value=""></option> - <option value="<" <%= 'selected' if (criterion && criterion.operator=='<') -%>>Less than</option> - <option value="<=" <%= 'selected' if (criterion && criterion.operator=='<=') -%>>Less or equals</option> - <option value="=" <%= 'selected' if (criterion && criterion.operator=='=') -%>>Equals</option> - <option value=">" <%= 'selected' if (criterion && criterion.operator=='>') -%>>Greater than</option> - <option value=">=" <%= 'selected' if (criterion && criterion.operator=='>=') -%>>Greater or equals</option> + <option value="<" <%= 'selected' if (criterion && criterion.operator=='<') -%>><%= message('less_than') -%></option> + <option value="<=" <%= 'selected' if (criterion && criterion.operator=='<=') -%>><%= message('less_or_equals') -%></option> + <option value="=" <%= 'selected' if (criterion && criterion.operator=='=') -%>><%= message('equals') -%></option> + <option value=">" <%= 'selected' if (criterion && criterion.operator=='>') -%>><%= message('greater_than') -%></option> + <option value=">=" <%= 'selected' if (criterion && criterion.operator=='>=') -%>><%= message('greater_or_equals') -%></option> </select> <input type="text" name="criteria[<%= id -%>][value]" size="5" value="<%= criterion.value if criterion -%>" id="val-<%= id -%>"></input> -<a href="#" onClick="reset_criterion(<%= id -%>);return false;">Reset</a>
\ No newline at end of file +<a href="#" onClick="reset_criterion(<%= id -%>);return false;"><%= message('reset_verb') -%></a>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb index d899960b1eb..a0c8fcd78d9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb @@ -1,12 +1,12 @@ <tr> - <td class="first"> - Add column: + <td class="keyCell"> + <%= message('filters.add_column') -%>: </td> <td> <form id="add_column_form" action="<%= url_for :action => 'add_column', :id => @filter.id -%>" method="post"> <select name="column_type" id="select_column_type"> - <option value="value" selected>Value</option> - <option value="variation">Variation</option> + <option value="value" selected><%= message('value') -%></option> + <option value="variation"><%= message('variation') -%></option> </select> <select name="column" id="select_column"> @@ -17,22 +17,22 @@ <% if metric.display? %><option value="metric,<%= metric.id -%>"><%= metric.short_name -%></option><% end %> <% end %> <% if domain=='General' %> - <% unless @filter.column('date') %><option value="date">Build date</option><% end %> - <% unless @filter.column('key') %><option value="key">Key</option><% end %> - <% unless @filter.column('language') %><option value="language">Language</option><% end %> - <% unless @filter.column('links') %><option value="links">Links</option><% end %> - <% unless @filter.column('name') %><option value="name">Name</option><% end %> - <% unless @filter.column('version') %><option value="version">Version</option><% end %> + <% unless @filter.column('date') %><option value="date"><%= message('build_date') -%></option><% end %> + <% unless @filter.column('key') %><option value="key"><%= message('key') -%></option><% end %> + <% unless @filter.column('language') %><option value="language"><%= message('language') -%></option><% end %> + <% unless @filter.column('links') %><option value="links"><%= message('links') -%></option><% end %> + <% unless @filter.column('name') %><option value="name"><%= message('name') -%></option><% end %> + <% unless @filter.column('version') %><option value="version"><%= message('version') -%></option><% end %> <% end %> </optgroup> <% end %> </select> - <input type="submit" id="add_column_button" value="Add"></input> + <input type="submit" id="add_column_button" value="<%= message('add_verb') -%>"></input> </form> </td> </tr> <tr> - <td class="first">Default sorted column:</td> + <td class="keyCell"><%= message('filters.default_sorted_column') -%>:</td> <td> <form id="sorted_column_form" action="<%= url_for :action => 'set_sorted_column' -%>" method="post"> <select name="id"> @@ -44,20 +44,20 @@ <% end %> </select> <select name="sort"> - <option value="ASC" <%= 'selected' if default_sorted_column && default_sorted_column.ascending? -%>>Ascending</option> - <option value="DESC" <%= 'selected' if default_sorted_column && default_sorted_column.descending? -%>>Descending</option> + <option value="ASC" <%= 'selected' if default_sorted_column && default_sorted_column.ascending? -%>><%= message('ascending') -%></option> + <option value="DESC" <%= 'selected' if default_sorted_column && default_sorted_column.descending? -%>><%= message('descending') -%></option> </select> - <input type="submit" id="add_column_submit" value="Change" /> + <input type="submit" id="add_column_submit" value="<%= message('change_verb') -%>" /> </form> </td> </tr> <tr> - <td class="first">Page size:</td> + <td class="keyCell"><%= message('page_size') -%>:</td> <td> <form id="page_size_form" action="<%= url_for :action => 'set_page_size' -%>" method="post"> <input type="hidden" name="id" value="<%= @filter.id -%>"></input> <input type="text" name="size" value="<%= @filter.page_size -%>" maxsize="3" size="3"></input> - <input type="submit" id="set_page_size_submit" value="Change"/> - <span class="comments">Min <%= ::Filter::MIN_PAGE_SIZE -%>, max <%= ::Filter::MAX_PAGE_SIZE -%></span> + <input type="submit" id="set_page_size_submit" value="<%= message('change_verb') -%>"/> + <span class="comments"><%= message('min') -%> <%= ::Filter::MIN_PAGE_SIZE -%>, <%= message('max').downcase -%> <%= ::Filter::MAX_PAGE_SIZE -%></span> </td> </tr>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb index 39c8b2dc1e3..dacce6494f5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb @@ -5,14 +5,14 @@ %> <form class="admin" action="<%= url_for :action => 'set_columns', :id => @filter.id -%>" method="POST"> <tr> - <td class="first">Size:</td> + <td class="keyCell"><%= message('size') -%>:</td> <td> - <%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics({:exclude_user_managed => true}), size_metric.key), + <%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics(), size_metric.key), :id => 'size_metric' %> </td> </tr> <tr> - <td class="first">Color:</td> + <td class="keyCell"><%= message('color') -%>:</td> <td> <%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.color_metrics, color_metric.key), :id => 'color_metric' %> @@ -20,9 +20,9 @@ </td> </tr> <tr> - <td class="first"> </td> + <td class="keyCell"> </td> <td> - <input type="submit" value="Change"> + <input type="submit" value="<%= message('change_verb') -%>"> </td> </tr> </form>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb index b6231d2f023..78b86a04143 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb @@ -5,7 +5,7 @@ <div class="operations"> <form action="<%= url_for :overwrite_params => {:period => nil} -%>" style="display: inline" method="get"> <select name="period" onchange="submit()" class="small"> - <option value="">Time changes...</option> + <option value=""><%= message('time_changes') -%>...</option> <% period_names.each_with_index do |name, index| %> <option value="<%= index+1 -%>" <%= 'selected' if @filter_context.period_index==index+1 -%>><%= name -%></value> <% end %> @@ -28,9 +28,9 @@ <tr class="admin"><th></th> <% filter.columns.each do |column| %> <th nowrap class="<%= column_align(column) -%>"> - <%= link_to image_tag("controls/resultset_previous.png"), {:action => 'left_column', :id => column.id}, :title => 'Move left', :method => :post if filter.first_column!=column %> - <%= link_to image_tag("bin_closed.png"), {:action => 'delete_column', :id => column.id}, :title => 'Remove this column', :method => :post if column.deletable? %> - <%= link_to image_tag("controls/resultset_next.png"), {:action => 'right_column', :id => column.id}, :title => 'Move right', :method => :post if filter.last_column!=column %> + <%= link_to image_tag("controls/resultset_previous.png"), {:action => 'left_column', :id => column.id}, :title => message('move_left'), :method => :post if filter.first_column!=column %> + <%= link_to image_tag("bin_closed.png"), {:action => 'delete_column', :id => column.id}, :title => message('remove_column'), :method => :post if column.deletable? %> + <%= link_to image_tag("controls/resultset_next.png"), {:action => 'right_column', :id => column.id}, :title => message('move_right'), :method => :post if filter.last_column!=column %> </th> <% end %> </tr> @@ -40,7 +40,7 @@ <tfoot> <tr> <td colspan="<%= filter.columns.size + 1 -%>"> - <span id="results_count"><%= pluralize(@filter_context.size, 'result') %></span> + <span id="results_count"><%= pluralize(@filter_context.size, message('result').downcase) %></span> <% if @filter_context.page_count>1 %> | @@ -53,7 +53,7 @@ <% if @filter.projects_homepage? %> <a href="<%= url_for :controller => :feeds, :action => 'projects', :id => EventCategory::KEY_ALERT -%>" class="nolink"><%= image_tag 'rss-12x12.png' %></a> - <a href="<%= url_for :controller => :feeds, :action => 'projects', :id => EventCategory::KEY_ALERT -%>" class="action">Alerts feed</a> + <a href="<%= url_for :controller => :feeds, :action => 'projects', :id => EventCategory::KEY_ALERT -%>" class="action"><%= message('alerts_feed') -%></a> <% end %> </td> </tr> @@ -129,6 +129,6 @@ </table> <br/> <% if @filter_context.security_exclusions? %> - <p class="notes">Due to security settings, some results are not being displayed.</p> + <p class="notes"><%= message('results_not_display_due_to_security') -%></p> <% end %> </div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_tabs.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_tabs.html.erb index dddf84fb4ed..d6570269035 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_tabs.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_tabs.html.erb @@ -1,11 +1,11 @@ <% if logged_in? %> <div id="page-operations"> <ul class="operations"> - <li><a href="<%= url_for :action => 'new' -%>" >Add filter</a></li> + <li><a href="<%= url_for :action => 'new' -%>" ><%= message('filters.add_filter') -%></a></li> <% if @filter && @filter.id && editable_filter?(@filter) %> - <li><a href="<%= url_for :action => 'edit', :id => @filter.id -%>">Edit filter</a></li> + <li><a href="<%= url_for :action => 'edit', :id => @filter.id -%>"><%= message('filters.edit_filter') -%></a></li> <% end %> - <li class="last"><%= link_to 'Manage filters', {:action => 'manage'} -%></li> + <li class="last"><%= link_to message('filters.manage_filters'), {:action => 'manage'} -%></li> </ul> </div> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_treemap.html.erb index f927de3ecb4..93d0455651d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_treemap.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_treemap.html.erb @@ -1,5 +1,5 @@ <% if @filter.period? %> -Treemap does not support yet the selection of a period. +<%= message('filters.treemap_not_supported_for_period_selection') -%> <% else %> <% diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb index abf745ddd85..2c8b206dff1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb @@ -1,20 +1,20 @@ <%= render :partial => 'filters/tabs', :locals => {:selected_tab => nil} %> -<h1>My filters</h1> +<h1><%= message('filters.my_filters') -%></h1> <br/> <table class="data" id="actives"> <thead> <tr> - <th>Name</th> - <th>Author</th> - <th>Shared</th> - <th>Order</th> - <th>Operations</th> + <th><%= message('name') -%></th> + <th><%= message('author') -%></th> + <th><%= message('shared') -%></th> + <th><%= message('order') -%></th> + <th><%= message('operations') -%></th> </tr> </thead> <tbody> <% if @actives.nil? || @actives.empty? %> - <tr class="even"><td colspan="5">No filters</td></tr> + <tr class="even"><td colspan="5"><%= message('filters.no_filters') -%></td></tr> <% else @@ -39,10 +39,10 @@ </td> <td> <% if editable_filter?(active.filter) %> - <%= link_to 'Edit', {:action => 'edit', :id => active.filter_id}, :id => "edit-#{u active.name}" %> | - <%= link_to 'Delete', {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => 'Do you want to delete this filter ?', :id => "delete-#{u active.name}" %> + <%= link_to message('edit'), {:action => 'edit', :id => active.filter_id}, :id => "edit-#{u active.name}" %> | + <%= link_to message('delete'), {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => message('filters.do_you_want_to_delete'), :id => "delete-#{u active.name}" %> <% else %> - <%= link_to 'Unfollow', {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => 'Do you want to stop following this filter ?', :id => "unfollow-#{u active.name}" %> + <%= link_to message('unfollow'), {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => message('filters.do_you_want_to_stop_following'), :id => "unfollow-#{u active.name}" %> <% end %> </td> </tr> @@ -53,20 +53,20 @@ </table> <br/><br/><br/> -<h1>Shared filters</h1> -<p>These filters are shared by administrators and can be followed without copying them.</p> +<h1><%= message('filters.shared_filters') -%></h1> +<p><%= message('filters.shared_filters_description') -%></p> <br/> <table class="data" id="shared"> <thead> <tr> - <th>Name</th> - <th>Author</th> - <th>Operations</th> + <th><%= message('name') -%></th> + <th><%= message('author') -%></th> + <th><%= message('operations') -%></th> </tr> </thead> <tbody> <% if @shared_filters.nil? || @shared_filters.empty? %> - <tr class="even"><td colspan="3">No results.</td></tr> + <tr class="even"><td colspan="3"><%= message('no_results') -%>.</td></tr> <% else %> <% @shared_filters.each do |filter| %> <tr class="<%= cycle('even', 'odd') -%>"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb index 5428a8aeb1e..eabbdbf682b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb @@ -23,12 +23,12 @@ table#columns td { <table class="form"> <tbody> <tr> - <td class="first">Name:</td> + <td class="keyCell"><%= message('name') -%>:</td> <td> <input type="text" name="name" id="name" value="<%= @filter.name -%>" class="spaced"></input> <% if is_admin? %> <span class="spacer"></span> - <label for="shared">Shared:</label> + <label for="shared"><%= message('shared') -%>:</label> <input type="checkbox" name="shared" id="shared" <%= 'checked' if @filter.shared -%>></input> <% end %> </td> @@ -36,74 +36,74 @@ table#columns td { </tbody> <tbody id="simple-form"> <tr> - <td class="first">Path:</td> + <td class="keyCell"><%= message('path') -%>:</td> <td> <b><span id="path_name"><%= @filter.resource ? @filter.resource.path_name : params[:path_name] -%></span></b> <input type="hidden" name="path_id" id="path_id" value="<%= @filter.resource ? @filter.resource.id : params[:path_id] -%>"></input> - <a onclick="searchPopup(this);return false;" href="<%= url_for :action => :search_path, :search => (@filter.resource ? @filter.resource.name : nil) -%>">Search</a> - <a href="#" onClick="$('path_name').innerText='';$('path_name').innerHTML='';Form.Element.clear('path_id');return false;">Reset</a> + <a onclick="searchPopup(this);return false;" href="<%= url_for :action => :search_path, :search => (@filter.resource ? @filter.resource.name : nil) -%>"><%= message('search_verb') -%></a> + <a href="#" onClick="$('path_name').innerText='';$('path_name').innerHTML='';Form.Element.clear('path_id');return false;"><%= message('reset_verb') -%></a> </td> </tr> <tr> - <td class="first">Search for:</td> + <td class="keyCell"><%= message('filters.search_for') -%>:</td> <td> <% qualifiers=(@filter.criterion('qualifier') ? @filter.criterion('qualifier').text_values : []) %> <% if controller.java_facade.hasPlugin('views') %> - <input type="checkbox" name="qualifiers[]" value="VW" <%= 'checked' if qualifiers.include?('VW') -%> id="q-VW"></input> <label for="q-VW">Views</label> + <input type="checkbox" name="qualifiers[]" value="VW" <%= 'checked' if qualifiers.include?('VW') -%> id="q-VW"></input> <label for="q-VW"><%= message('views') -%></label> <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="SVW" <%= 'checked' if qualifiers.include?('SVW') -%> id="q-SVW"></input> <label for="q-SVW">Sub-views</label> + <input type="checkbox" name="qualifiers[]" value="SVW" <%= 'checked' if qualifiers.include?('SVW') -%> id="q-SVW"></input> <label for="q-SVW"><%= message('sub_views') -%></label> <span class="spacer"> </span> <% end %> - <input type="checkbox" name="qualifiers[]" value="TRK" <%= 'checked' if qualifiers.include?('TRK') -%> id="q-TRK"></input> <label for="q-TRK">Projects</label> + <input type="checkbox" name="qualifiers[]" value="TRK" <%= 'checked' if qualifiers.include?('TRK') -%> id="q-TRK"></input> <label for="q-TRK"><%= message('projects') -%></label> <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="BRC" <%= 'checked' if qualifiers.include?('BRC') -%> id="q-BRC"></input> <label for="q-BRC">Sub-projects</label> + <input type="checkbox" name="qualifiers[]" value="BRC" <%= 'checked' if qualifiers.include?('BRC') -%> id="q-BRC"></input> <label for="q-BRC"><%= message('sub_projects') -%></label> <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="DIR,PAC" <%= 'checked' if qualifiers.include?('DIR') -%> id="q-DIR"></input> <label for="q-DIR">Directories/Packages</label> + <input type="checkbox" name="qualifiers[]" value="DIR,PAC" <%= 'checked' if qualifiers.include?('DIR') -%> id="q-DIR"></input> <label for="q-DIR"><%= message('directories') -%>/<%= message('packages') -%></label> <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="FIL,CLA" <%= 'checked' if qualifiers.include?('FIL') -%> id="q-FIL"></input> <label for="q-FIL">Files/Classes</label> + <input type="checkbox" name="qualifiers[]" value="FIL,CLA" <%= 'checked' if qualifiers.include?('FIL') -%> id="q-FIL"></input> <label for="q-FIL"><%= message('files') -%>/<%= message('classes') -%></label> <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="UTS" <%= 'checked' if qualifiers.include?('UTS') -%> id="q-UTS"></input> <label for="q-UTS">Unit tests</label> + <input type="checkbox" name="qualifiers[]" value="UTS" <%= 'checked' if qualifiers.include?('UTS') -%> id="q-UTS"></input> <label for="q-UTS"><%= message('unit_tests') -%></label> <span class="spacer"> </span> </td> </tr> <tr> - <td class="first">Criteria:</td> + <td class="keyCell"><%= message('criteria') -%>:</td> <td> <%= render :partial => 'filters/criterion', :locals => {:id => '0', :criterion => (@filter.measure_criteria.size>0 ? @filter.measure_criteria[0] : nil)} %> </td> </tr> <tr> - <td class="first">and: </td> + <td class="keyCell"><%= message('and').downcase -%>: </td> <td> <%= render :partial => 'filters/criterion', :locals => {:id => '1', :criterion => (@filter.measure_criteria.size>1 ? @filter.measure_criteria[1] : nil) } %> </td> </tr> <tr> - <td class="first">and: </td> + <td class="keyCell"><%= message('and').downcase -%>: </td> <td> <%= render :partial => 'filters/criterion', :locals => {:id => '2', :criterion => (@filter.measure_criteria.size>2 ? @filter.measure_criteria[2] : nil) } %> </td> </tr> <% unless @filter.advanced_search? %> <tr id="advanced-search-link"> - <td align="right"><a href="#" onClick="$('advanced-search').show();$('advanced-search-link').hide();return false;">Advanced search</a></td> + <td align="right"><a href="#" onClick="$('advanced-search').show();$('advanced-search-link').hide();return false;"><%= message('filters.advanced_search') -%></a></td> <td></td> </tr> <% end %> </tbody> <tbody id="advanced-search" style="<%= 'display: none' unless @filter.advanced_search? -%>"> <tr> - <td class="first">Default period:</td> + <td class="keyCell"><%= message('filters.default_period') -%>:</td> <td> <select id="period_index" name="period_index"> - <option value="">None</option> + <option value=""><%= message('none') -%></option> <% period_names.each_with_index do |name, index| %> <option value="<%= index+1 -%>" <%= 'selected' if @filter.period_index==index+1 -%>><%= name -%></value> <% end %> @@ -111,64 +111,66 @@ table#columns td { </td> </tr> <tr> - <td class="first">Language:</td> + <td class="keyCell"><%= message('language') -%>:</td> <td> <% languages=(@filter.criterion('language') ? @filter.criterion('language').text_values : []) %> <% controller.java_facade.getLanguages().each do |language| %> <input type="checkbox" name="languages[]" value="<%= language.getKey() -%>" <%= 'checked' if languages.include?(language.getKey()) -%> id="lang-<%= language.getKey() -%>"> </input> <label for="lang-<%= language.getKey() -%>"><%= language.getName() -%></label> <% end %> - <span class="comments">When no language is selected, no filter will apply</span> + <span class="comments"><%= message('filters.when_no_language_no_filter_apply') -%></span> </td> </tr> <tr> - <td class="first"><%= image_tag 'star.png' %> <label for="favourites">Favourites only:</label></td> + <td class="keyCell"><%= image_tag 'star.png' %> <label for="favourites"><%= message('filters.favourite_only') -%>:</label></td> <td> <input type="checkbox" name="favourites" id="favourites" <%= 'checked' if @filter.favourites -%>></input> </td> </tr> <tr> - <td class="first"><label for="key_regexp">Resource key like:</label></td> + <td class="keyCell"><label for="key_regexp"><%= message('filters.resource_key_like') -%>:</label></td> <td> <% key_regexp_criterion=@filter.criterion('key') %> <input type="text" name="key_regexp" id="key_regexp" value="<%= key_regexp_criterion.text_value if key_regexp_criterion -%>"></input> - <span class="comments">Use the character * to match zero or more characters.</span> + <span class="comments"><%= message('filters.use_star_to_match') -%></span> </td> </tr> <tr> - <td class="first"><label for="name_regexp">Resource name like:</label></td> + <td class="keyCell"><label for="name_regexp"><%= message('filters.resource_name_like') -%>:</label></td> <td> <% name_regexp_criterion=@filter.criterion('name') %> <input type="text" name="name_regexp" id="name_regexp" value="<%= name_regexp_criterion.text_value if name_regexp_criterion -%>"></input> - <span class="comments">Use the character * to match zero or more characters.</span> + <span class="comments"><%= message('filters.use_star_to_match') -%></span> </td> </tr> <tr> - <td class="first"><label for="date">Build date:</label></td> + <td class="keyCell"><label for="date"><%= message('build_date') -%>:</label></td> <td> <% date_criterion = @filter.criterion('date') %> <select id="date_operator" name="date_operator"> <option value=""></option> - <option value="<" <%= 'selected' if (date_criterion && date_criterion.operator=='<') -%>>Prior to last</value> - <option value=">=" <%= 'selected' if (date_criterion && date_criterion.operator=='>=') -%>>During last</value> + <option value="<" <%= 'selected' if (date_criterion && date_criterion.operator=='<') -%>><%= message('filters.prior_to_last') -%></value> + <option value=">=" <%= 'selected' if (date_criterion && date_criterion.operator=='>=') -%>><%= message('filters.during_last') -%></value> </select> - <input type="text" name="date_value" id="date_value" size="3" value="<%= date_criterion.value.to_i if date_criterion -%>"></input> days + <input type="text" name="date_value" id="date_value" size="3" value="<%= date_criterion.value.to_i if date_criterion -%>"></input> <%= message('days').downcase -%> </td> </tr> </tbody> <tbody> <tr> <td colspan="2"> - <input type="submit" value="Save & Preview" onclick="filter_form.preview.value='true';return true;"/> + <input type="submit" value="<%= message('save_and_preview') -%>" onclick="filter_form.preview.value='true';return true;"/> <span class="spacer"> </span> - <input type="submit" value="Save & Close" /> + <input type="submit" value="<%= message('save_and_close') -%>" /> <span class="spacer"> </span> - <% if @filter.id %> - <input name="delete" class="red-button" value="Delete" type="button" - onclick="if (confirm('Do you want to delete this filter ?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = '<%= url_for :action => 'delete', :id => @filter.id %>';f.submit(); };return false;"> + <% if @filter.id + confirmation_message = message('filters.do_you_want_to_delete') + %> + <input name="delete" class="red-button" value="<%= message('delete') -%>" type="button" + onclick="if (confirm('<%= confirmation_message -%>')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = '<%= url_for :action => 'delete', :id => @filter.id %>';f.submit(); };return false;"> <span class="spacer"> </span> - <a href="<%= url_for :action => 'index', :name => @filter.name -%>">Cancel</a> + <a href="<%= url_for :action => 'index', :name => @filter.name -%>"><%= message('cancel') -%></a> <% else %> - <a href="<%= url_for :action => 'index' -%>">Cancel</a> + <a href="<%= url_for :action => 'index' -%>"><%= message('cancel') -%></a> <% end %> </td> </tr> @@ -182,16 +184,16 @@ $('name').focus(); <br/> <% if @filter_context %> - <h1>Display</h1> + <h1><%= message('display') -%></h1> <div class="admin"> <table class="form" id="view-form"> <tr> - <td class="first">Display as:</td> + <td class="keyCell"><%= message('filters.display_as') -%>:</td> <td> <form action="<%= url_for :action => :set_view, :id => @filter.id -%>" method="POST"> - <input type="radio" name="view" value="list" <%= 'checked' if @filter.default_view==::Filter::VIEW_LIST -%> id="view-list" onClick="$('view-loading').show();submit();"></input> <label for="view-list">Table</label> + <input type="radio" name="view" value="list" <%= 'checked' if @filter.default_view==::Filter::VIEW_LIST -%> id="view-list" onClick="$('view-loading').show();submit();"></input> <label for="view-list"><%= message('table') -%></label> <span class="spacer"> </span> - <input type="radio" name="view" value="treemap" <%= 'checked' if @filter.default_view==::Filter::VIEW_TREEMAP -%> id="view-treemap" onClick="$('view-loading').show();submit();"></input> <label for="view-treemap">Treemap</label> + <input type="radio" name="view" value="treemap" <%= 'checked' if @filter.default_view==::Filter::VIEW_TREEMAP -%> id="view-treemap" onClick="$('view-loading').show();submit();"></input> <label for="view-treemap"><%= message('treemap') -%></label> <span class="spacer"> </span> <%= image_tag 'loading.gif', :id => 'view-loading', :style=>'display: none' %> </form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/search_path.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/search_path.html.erb index 02dc65cf144..a3dc8ced1fe 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/search_path.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/search_path.html.erb @@ -1,10 +1,10 @@ -<h1>Search</h1> +<h1><%= message('search_verb') -%></h1> <br/> <form action="<%= url_for :action => :search_path -%>" method="post" id="search_form"> <input type="text" name="search" id="search" value="<%= params[:search] -%>"></input> - <input type="submit" value="Search" id="search_submit" /><br/> - <p class="note">Search by name</p> + <input type="submit" value="<%= message('search_verb') -%>" id="search_submit" /><br/> + <p class="note"><%= message('filters.search_by_name') -%></p> </form> <br/> @@ -28,7 +28,7 @@ </thead> <tbody> <% if @snapshots.empty? %> - <tr class="even"><td colspan="3">No results</td></tr> + <tr class="even"><td colspan="3"><%= message('no_results') -%></td></tr> <% else @snapshots.each do |snapshot| %> @@ -38,7 +38,7 @@ <% path_name=snapshot.path_name %> <%= path_name -%> </td> - <td><a href="#" onClick="selectPath(<%= snapshot.project_id-%>, '<%= escape_javascript(path_name) -%>')">Select</a></td> + <td><a href="#" onClick="selectPath(<%= snapshot.project_id-%>, '<%= escape_javascript(path_name) -%>')"><%= message('select_verb') -%></a></td> </tr> <% end end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb index dbe6685989b..3b6601281b4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb @@ -3,13 +3,13 @@ <table> <tr> <td> - <span class="comments">Size:</span><br/> - <%= select_tag 'size_metric', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics({:exclude_user_managed => true}), @size_metric.key), + <span class="comments"><%= message('size') -%>:</span><br/> + <%= select_tag 'size_metric', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics(), @size_metric.key), :id => 'size_metric', :class => 'small', :onchange => "load_treemap(this.form.size_metric.value,this.form.color_metric.value, false);return false;" %> </td> <td class="sep"> </td> <td> - <span class="comments">Color: <%= render :partial => 'components/treemap_gradient', :locals => {:color_metric => @color_metric} %></span> + <span class="comments"><%= message('color') -%>: <%= render :partial => 'components/treemap_gradient', :locals => {:color_metric => @color_metric} %></span> <br/> <%= select_tag 'color_metric', options_grouped_by_domain(Sonar::TreemapBuilder.color_metrics, @color_metric.key), :id => 'color_metric', :class => 'small', :onchange => "load_treemap(this.form.size_metric.value,this.form.color_metric.value, false);return false;" %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb index 66344364c10..59c9aa6eee1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb @@ -1,5 +1,5 @@ <ol id="crumbs"> - <li><a href="<%= ApplicationController.root_context -%>/">Home</a></li> + <li><a href="<%= ApplicationController.root_context -%>/"><%= message('layout.home') -%></a></li> <% if @snapshot resources=[] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 5a09ff6a1f3..fbc097c14a6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -1,22 +1,25 @@ -<% selected_section = controller.class::SECTION %> +<% + selected_section = controller.class::SECTION + @project=@resource unless @project +%> <div id="container"> <div id="hd"> <%= render :partial => 'layouts/breadcrumb' %> <ol id="nav"> - <li><input type="text" autocomplete="off" size="15" name="search" id="projectSearch" onFocus="this.size=30;this.value='';autocompleteProjects('<%= ApplicationController.root_context -%>/api/resources?scopes=<%= Project::SCOPE_SET -%>&qualifiers=<%= Project::QUALIFIER_VIEW-%>,<%= Project::QUALIFIER_SUBVIEW-%>,<%= Project::QUALIFIER_PROJECT-%>', '<%= ApplicationController.root_context -%>/dashboard/index/', this, $('projectResults'));return true;" onBlur="javacript:this.size=15" value="Search"/><div id="projectResults" style="display:none"></div></li> + <li><input type="text" autocomplete="off" size="15" name="search" id="projectSearch" onFocus="this.size=30;this.value='';autocompleteProjects('<%= ApplicationController.root_context -%>/api/resources?scopes=<%= Project::SCOPE_SET -%>&qualifiers=<%= Project::QUALIFIER_VIEW-%>,<%= Project::QUALIFIER_SUBVIEW-%>,<%= Project::QUALIFIER_PROJECT-%>', '<%= ApplicationController.root_context -%>/dashboard/index/', this, $('projectResults'));return true;" onBlur="javacript:this.size=15" value="<%= message('search_verb') -%>"/><div id="projectResults" style="display:none"></div></li> <li> - <a href="javascript:window.print()"><img src="<%= ApplicationController.root_context -%>/images/print.gif" alt="Print" title="Print" /></a> - <% if @project %><a href="<%= url_for :overwrite_params => {:id => @project.key}-%>" id="permalink"><img src="<%= ApplicationController.root_context -%>/images/permalink.gif" alt="Permalink" title="Permalink" /></a><% end %> + <a href="javascript:window.print()"><img src="<%= ApplicationController.root_context -%>/images/print.gif" alt="<%= message('layout.print') -%>" title="<%=message('layout.print')-%>" /></a> + <% if @project %><a href="<%= url_for :overwrite_params => {:id => @project.key}-%>" id="permalink"><img src="<%= ApplicationController.root_context -%>/images/permalink.gif" alt="<%=message('layout.permalink')-%>" title="<%=message('layout.permalink')-%>" /></a><% end %> </li> <% if logged_in? %> <li> <img src="<%= ApplicationController.root_context -%>/images/user.gif"/><a href="<%= ApplicationController.root_context -%>/account/index"><%= current_user.name(true) -%></a> - » <a href="<%= ApplicationController.root_context -%>/sessions/logout">Log out</a> + » <a href="<%= ApplicationController.root_context -%>/sessions/logout"><%= message('layout.logout') -%></a> </li> <% else %> - <li><a href="<%= ApplicationController.root_context -%>/sessions/new"><%= message('app.view.layouts.layout.login', 'Log in') -%></a></li> + <li><a href="<%= ApplicationController.root_context -%>/sessions/new"><%= message('layout.login') -%></a></li> <% end %> - <li><a href="<%= ApplicationController.root_context -%>/profiles">Configuration</a></li> + <li><a href="<%= ApplicationController.root_context -%>/profiles"><%= message('layout.configuration') -%></a></li> </ol> </div> @@ -25,68 +28,70 @@ <div id="sidebar"> <ul> <% if selected_section==Navigation::SECTION_HOME %> - <li class="<%= 'selected' if controller.controller_path=='filters' -%>"><a href="<%= ApplicationController.root_context -%>/filters/index">Filters</a></li> - <li class="<%= 'selected' if controller.controller_path=='reviews' -%>"><a href="<%= ApplicationController.root_context -%>/reviews/index">Reviews</a></li> - <li class="<%= 'selected' if controller.controller_path=='dependencies' -%>"><a href="<%= ApplicationController.root_context -%>/dependencies/index">Dependencies</a></li> + <li class="<%= 'selected' if controller.controller_path=='filters' -%>"><a href="<%= ApplicationController.root_context -%>/filters/index"><%= message('filters.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='reviews' -%>"><a href="<%= ApplicationController.root_context -%>/reviews/index"><%= message('reviews.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='dependencies' -%>"><a href="<%= ApplicationController.root_context -%>/dependencies/index"><%= message('dependencies.page') -%></a></li> <% controller.java_facade.getPages(Navigation::SECTION_HOME, nil, nil, nil).each do |page| selected=request.request_uri.include?("/plugins/home/#{page.getId()}") %> - <li class="<%= 'selected' if selected -%>"><a href="<%= ApplicationController.root_context -%>/plugins/home/<%= page.getId() -%>"><%= page.getTitle()-%></a></li> + <li class="<%= 'selected' if selected -%>"><a href="<%= ApplicationController.root_context -%>/plugins/home/<%= page.getId() -%>"><%= message(page.getId() + '.page', :default => page.getTitle()) -%></a></li> <% end %> <% elsif (selected_section==Navigation::SECTION_RESOURCE) %> <% ActiveDashboard.user_dashboards(current_user).each do |active_dashboard| %> <li class="<%= 'selected' if @dashboard && controller.controller_path=='dashboard' && active_dashboard.dashboard_id==@dashboard.id -%>"><a href="<%= ApplicationController.root_context -%>/dashboard/index/<%= @project.id -%>?did=<%= active_dashboard.dashboard_id -%>"><%= active_dashboard.dashboard.name -%></a></li> <% end %> - <li class="<%= 'selected' if request.request_uri.include?('/components/index') -%>"><a href="<%= ApplicationController.root_context -%>/components/index/<%= @project.id -%>">Components</a></li> - <li class="<%= 'selected' if request.request_uri.include?('/drilldown/violations') -%>"><a href="<%= ApplicationController.root_context -%>/drilldown/violations/<%= @project.id -%>">Violations drilldown</a></li> - <li class="<%= 'selected' if controller.controller_path=='timemachine' -%>"><a href="<%= ApplicationController.root_context -%>/timemachine/index/<%= @project.id -%>">Time machine</a></li> - <li class="<%= 'selected' if request.request_uri.include?('/cloud/index') -%>"><a href="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>">Clouds</a></li> + <li class="<%= 'selected' if request.request_uri.include?('/components/index') -%>"><a href="<%= ApplicationController.root_context -%>/components/index/<%= @project.id -%>"><%= message('components.page') -%></a></li> + <li class="<%= 'selected' if request.request_uri.include?('/drilldown/violations') -%>"><a href="<%= ApplicationController.root_context -%>/drilldown/violations/<%= @project.id -%>"><%= message('violations_drilldown.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='timemachine' -%>"><a href="<%= ApplicationController.root_context -%>/timemachine/index/<%= @project.id -%>"><%= message('timemachine.page') -%></a></li> + <li class="<%= 'selected' if request.request_uri.include?('/cloud/index') -%>"><a href="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>"><%= message('clouds.page') -%></a></li> <% controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language).each do |page| %> - <li class="<%= 'selected' if request.request_uri.include?("page=#{page.getId()}") -%>"><a href="<%= ApplicationController.root_context -%>/plugins/resource/<%= @project.id-%>?page=<%= page.getId() -%>"><%= page.getTitle() %></a></li> + <li class="<%= 'selected' if request.request_uri.include?("page=#{page.getId()}") -%>"><a href="<%= ApplicationController.root_context -%>/plugins/resource/<%= @project.id-%>?page=<%= page.getId() -%>"><%= message(page.getId() + '.page', :default => page.getTitle()) %></a></li> <% end %> - <% if has_role?(:admin, @project) && @project.set? %> - <li class="h2">System</li> + <% if has_role?(:admin, @project) %> + <li class="h2"><%= message('sidebar.project_settings') -%></li> + <li class="<%= 'selected' if request.request_uri.include?('/manual_measures') -%>"><a href="<%= ApplicationController.root_context -%>/manual_measures/index/<%= @project.id -%>"><%= message('manual_measures.page') -%></a></li> <% if (@project.project? || @project.module?) %> - <li class="<%= 'selected' if request.request_uri.include?('/project/settings') -%>"><a href="<%= ApplicationController.root_context -%>/project/settings/<%= @project.id -%>">Settings</a></li> + <li class="<%= 'selected' if request.request_uri.include?('/project/settings') -%>"><a href="<%= ApplicationController.root_context -%>/project/settings/<%= @project.id -%>"><%= message('project_settings.page') -%></a></li> <% end %> <% if (@project.project? || @project.view? || @project.subview?) %> - <li class="<%= 'selected' if request.request_uri.include?('/project_roles') -%>"><a href="<%= ApplicationController.root_context -%>/project_roles/index?resource=<%= @project.id -%>">Project roles</a></li> + <li class="<%= 'selected' if request.request_uri.include?('/project_roles') -%>"><a href="<%= ApplicationController.root_context -%>/project_roles/index?resource=<%= @project.id -%>"><%= message('project_roles.page') -%></a></li> <% end %> <% end %> <% elsif selected_section==Navigation::SECTION_CONFIGURATION %> - <li class="<%= 'selected' if request.request_uri.include?('/profiles') || request.request_uri.include?('/rules_configuration') -%>"><a href="<%= ApplicationController.root_context -%>/profiles">Quality profiles</a></li> + <li class="<%= 'selected' if request.request_uri.include?('/profiles') || request.request_uri.include?('/rules_configuration') -%>"><a href="<%= ApplicationController.root_context -%>/profiles"><%= message('quality_profiles.page') -%></a></li> <% if is_admin? %> - <li class="<%= 'selected' if controller.controller_path=='event_categories' -%>"><a href="<%= ApplicationController.root_context -%>/event_categories/index">Event categories</a></li> - <li class="<%= 'selected' if controller.controller_path=='metrics' -%>"><a href="<%= ApplicationController.root_context -%>/metrics/index">Manual metrics</a></li> - <li class="<%= 'selected' if controller.controller_path=='admin_filters' -%>"><a href="<%= ApplicationController.root_context -%>/admin_filters/index">Default filters</a></li> - <li class="<%= 'selected' if controller.controller_path=='admin_dashboards' -%>"><a href="<%= ApplicationController.root_context -%>/admin_dashboards/index">Default dashboards</a></li> - <li class="<%= 'selected' if controller.controller_path=='account' -%>"><a href="<%= ApplicationController.root_context -%>/account/index">My profile</a></li> + <li class="<%= 'selected' if controller.controller_path=='event_categories' -%>"><a href="<%= ApplicationController.root_context -%>/event_categories/index"><%= message('event_categories.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='metrics' -%>"><a href="<%= ApplicationController.root_context -%>/metrics/index"><%= message('manual_metrics.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='admin_filters' -%>"><a href="<%= ApplicationController.root_context -%>/admin_filters/index"><%= message('default_filters.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='admin_dashboards' -%>"><a href="<%= ApplicationController.root_context -%>/admin_dashboards/index"><%= message('default_dashboards.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='account' -%>"><a href="<%= ApplicationController.root_context -%>/account/index"><%= message('my_profile.page') -%></a></li> <% controller.java_facade.getPages(Navigation::SECTION_CONFIGURATION, nil,nil, nil).each do |page| %> - <li class="<%= 'selected' if request.request_uri.include?("plugins/configuration/#{page.getId()}") -%>"><a href="<%= ApplicationController.root_context -%>/plugins/configuration/<%= page.getId() -%>"><%= page.getTitle() %></a></li> + <li class="<%= 'selected' if request.request_uri.include?("plugins/configuration/#{page.getId()}") -%>"><a href="<%= ApplicationController.root_context -%>/plugins/configuration/<%= page.getId() -%>"><%= message(page.getId() + '.page', :default => page.getTitle()) %></a></li> <% end %> - <li class="h2">Security</li> - <li class="<%= 'selected' if request.request_uri.include?('/users') -%>"><a href="<%= ApplicationController.root_context -%>/users">Users</a></li> - <li class="<%= 'selected' if request.request_uri.include?('/groups') -%>"><a href="<%= ApplicationController.root_context -%>/groups/index">Groups</a></li> - <li class="<%= 'selected' if request.request_uri.include?('/roles/global') -%>"><a href="<%= ApplicationController.root_context -%>/roles/global">Global roles</a></li> - <li class="<%= 'selected' if request.request_uri.include?('/roles/projects') -%>"><a href="<%= ApplicationController.root_context -%>/roles/projects">Project roles</a></li> + <li class="h2"><%= message('sidebar.security') -%></li> + <li class="<%= 'selected' if request.request_uri.include?('/users') -%>"><a href="<%= ApplicationController.root_context -%>/users"><%= message('users.page') -%></a></li> + <li class="<%= 'selected' if request.request_uri.include?('/groups') -%>"><a href="<%= ApplicationController.root_context -%>/groups/index"><%= message('user_groups.page') -%></a></li> + <li class="<%= 'selected' if request.request_uri.include?('/roles/global') -%>"><a href="<%= ApplicationController.root_context -%>/roles/global"><%= message('global_roles.page') -%></a></li> + <li class="<%= 'selected' if request.request_uri.include?('/roles/projects') -%>"><a href="<%= ApplicationController.root_context -%>/roles/projects"><%= message('project_roles.page') -%></a></li> - <li class="h2">System</li> - <li class="<%= 'selected' if request.request_uri.include?('/settings') -%>"><a href="<%= ApplicationController.root_context -%>/settings/index">Settings</a></li> - <li class="<%= 'selected' if controller.controller_path=='backup' -%>"><a href="<%= ApplicationController.root_context -%>/backup">Backup</a></li> - <li class="<%= 'selected' if controller.controller_path=='system' -%>"><a href="<%= ApplicationController.root_context -%>/system">System Info</a></li> + <li class="h2"><%= message('sidebar.system') -%></li> + <li class="<%= 'selected' if request.request_uri.include?('/settings') -%>"><a href="<%= ApplicationController.root_context -%>/settings/index"><%= message('settings.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='backup' -%>"><a href="<%= ApplicationController.root_context -%>/backup"><%= message('backup.page') -%></a></li> + <li class="<%= 'selected' if controller.controller_path=='system' -%>"><a href="<%= ApplicationController.root_context -%>/system"><%= message('system_info.page') -%></a></li> <% update_center_activated = controller.java_facade.getConfigurationValue('sonar.updatecenter.activate') || 'true'; if update_center_activated=='true' %> - <li class="<%= 'selected' if controller.controller_path=='updatecenter' -%>"><a href="<%= ApplicationController.root_context -%>/updatecenter">Update Center</a></li> + <li class="<%= 'selected' if controller.controller_path=='updatecenter' -%>"><a href="<%= ApplicationController.root_context -%>/updatecenter"><%= message('update_center.page') -%></a></li> <% end %> + <li class="<%= 'selected' if controller.controller_path=='email_configuration' -%>"><a href="<%= ApplicationController.root_context -%>/email_configuration"><%= message('email_configuration.page') -%></a></li> <% end %> <% end %> </ul> - <div id="logo"><center><a href="http://www.sonarsource.org/"><%= image_tag('sonar.png', :alt => 'Embrace Quality', :class => 'png') -%></a></center></div> + <div id="logo"><center><a href="http://www.sonarsource.org/"><%= image_tag('sonar.png', :alt => message('layout.sonar.slogan'), :class => 'png') -%></a></center></div> </div> <% if @sidebar %><div id="sidebarconf"><%= render :partial => @sidebar %></div><% else %><div id="sidebarconf" class="hidden"> </div><% end %> @@ -94,9 +99,9 @@ </div> <div id="content" class="with_sidebar"> <% if @project %><div class="print"><h2><%= @project.name(true) %></h2></div><% end %> - <div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" onclick="javascript:$('error').hide();return false;">hide</a>]</div> - <div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" onclick="javascript:$('info').hide();return false;">hide</a>]</div> - <div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" onclick="javascript:$('warning').hide();return false;">hide</a>]</div> + <div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" onclick="javascript:$('error').hide();return false;"><%= message('hide').downcase -%></a>]</div> + <div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" onclick="javascript:$('info').hide();return false;"><%= message('hide').downcase -%></a>]</div> + <div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" onclick="javascript:$('warning').hide();return false;"><%= message('hide').downcase -%></a>]</div> <%= yield %> </div> </div> @@ -107,6 +112,17 @@ <% controller.java_facade.getWebFooters().each do |footer| %> <% if footer.getHtml() %><div><%= footer.getHtml().to_s %></div><% end %> <% end %> -<div id="ftlinks">Powered by <a href="http://www.sonarsource.com" target="SonarSource" class="external">SonarSource</a> - Open Source <a href="http://www.sonarsource.org/documentation/license/" target="license" class="external">LGPL</a> - v.<%= sonar_version -%> - <a href="http://sonar-plugins.codehaus.org" class="external" target="plugins">Plugins</a> - <a href="http://sonar.codehaus.org/documentation" class="external" target="sonar_doc" class="external">Documentation</a> - <a href="http://sonar.codehaus.org/support/" target="support" class="external">Ask a question</a> - <a href="http://jira.codehaus.org/browse/SONAR" target="issuetracker" class="external">Bug/feature request</a></div> +<div id="ftlinks"> + <%= message('layout.powered_by') -%> <a href="http://www.sonarsource.com" target="SonarSource" class="external">SonarSource</a> + - + Open Source <a href="http://www.sonarsource.org/documentation/license/" target="license" class="external">LGPL</a> + - + v.<%= sonar_version -%> + - + <a href="http://sonar.codehaus.org/documentation" class="external" target="sonar_doc" class="external"><%= message('layout.documentation') -%></a> + - + <a href="http://sonar.codehaus.org/support/" target="support" class="external"><%= message('layout.ask_a_questions') -%></a> + - + <a href="http://jira.codehaus.org/browse/SONAR" target="issuetracker" class="external"><%= message('layout.bug_feature_request') -%></a></div> </div> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb index a4fcad6bd6d..6e20677bf70 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb @@ -1,7 +1,7 @@ <div id="body" class="nolayout"> <% if @snapshot %><div class="print"><h2><%= @snapshot.project.name(true) %></h2></div><% end %> - <div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" onclick="javascript:$('error').hide();return false;">hide</a>]</div> - <div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" onclick="javascript:$('warning').hide();return false;">hide</a>]</div> - <div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" onclick="javascript:$('info').hide();return false;">hide</a>]</div> + <div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" onclick="javascript:$('error').hide();return false;"><%= message('hide').downcase -%></a>]</div> + <div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" onclick="javascript:$('warning').hide();return false;"><%= message('hide').downcase -%></a>]</div> + <div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" onclick="javascript:$('info').hide();return false;"><%= message('hide').downcase -%></a>]</div> <%= yield %> </div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb index b8bee4362ca..d1b22d6c199 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb @@ -12,7 +12,6 @@ <div id="maintenance"> <div id="maintenancelogo"><a href="http://www.sonarsource.org"><%= image_tag('sonar.png', :class => 'png') -%></a></div> -<h1>Sonar is under maintenance. Please <a href="<%= ApplicationController.root_context -%>/">check back</a> later.</h1> -<p>Whilst waiting, you might want to check <a href="http://sonar-plugins.codehaus.org">new plugins</a> to extend the current functionality. </p> -<p>If you are an administrator and have no idea why this message is showing, you should read the <a href="http://docs.codehaus.org/display/SONAR/Upgrade+guide">upgrade guide</a>.</p> +<h1><%= message('maintenance.sonar_is_under_maintenance') -%> <a href="<%= ApplicationController.root_context -%>/"><%= message('maintenance.please_check_back_later') -%></a></h1> +<%= message('maintenance.more_information') -%> </div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb new file mode 100644 index 00000000000..b6d5665f784 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb @@ -0,0 +1,69 @@ +<style type="text/css"> + #manualMeasures td { + vertical-align: top; + } + + #manualMeasures td.pendingMeasure { + background-color: orange; + cursor: help; + padding: 0 2px; + width: 2px; + } +</style> + +<div class="line-block marginbottom10"> + <ul class="operations"> + <li class="last"> + <%= image_tag 'add.png' -%> + <a href="<%= ApplicationController.root_context -%>/manual_measures/new/<%= @resource.id -%>" id="addMeasureLink"><%= message('manual_measures.add_measure_link') -%></a> + </li> + </ul> + <h1><%= message('manual_measures.page') -%></h1> +</div> + + +<table class="width100 data sortable" id="manualMeasures"> + <thead> + <tr> + <th style="padding: 0; margin: 0" class="nosort"></th> + <th class="thin nowrap"><%= message('manual_measures.col.domain') -%></th> + <th class="thin nowrap sortfirstasc"><%= message('manual_measures.col.metric') -%></th> + <th class="thin nowrap nosort" style="text-align: right"><%= message('manual_measures.col.value') -%></th> + <th><%= message('manual_measures.col.description') -%></th> + <th style="text-align: right"><%= message('manual_measures.col.author') -%></th> + <th style="text-align: right"><%= message('manual_measures.col.date') -%></th> + <th class="thin nowrap nosort"><%= message('manual_measures.col.operations') -%></th> + </tr> + </thead> + <tbody> + <% if @measures.empty? %> + <td colspan="8" class="even">No measures</td> + <% end %> + <% + @measures.each do |measure| + %> + <a name="<%= measure.metric.key -%>"></a> + <tr> + <% if measure.pending?(@snapshot) %> + <td class="pendingMeasure" title="Pending. New value will be available during next project analysis."></td> + <% else %> + <td style="padding: 0"></td> + <% end %> + <td class="thin nowrap"><%= measure.metric.domain -%></td> + <td class="thin nowrap"><%= measure.metric.short_name -%></td> + <td class="thin nowrap" align="right"><%= measure.formatted_value -%></td> + <td id="desc"><%= measure.description -%></td> + <td align="right"><%= measure.username -%> + </td> + <td align="right"> + <%= l(measure.updated_at) -%> + </td> + <td class="thin nowrap"> + <a href="<%= url_for :controller => 'manual_measures', :action => 'new', :metric => measure.metric.key, :id => @resource.id -%>"><%= message('edit') -%></a> + <%= link_to message('delete'), {:action => 'delete', :metric => measure.metric.key, :id => @resource.id}, {:method => 'POST', :confirm => "This measure will be deleted during next project analysis", :class => 'action'} -%> + </td> + </tr> + <% end %> + </tbody> +</table> +<script>TableKit.Sortable.init('manualMeasures');</script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb new file mode 100644 index 00000000000..ab98dee404f --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb @@ -0,0 +1,99 @@ +<script type="text/javascript"> + function changeMetric() { + document.location = '<%= ApplicationController.root_context-%>/manual_measures/new/<%= @resource.id -%>?metric=' + $('metricSelect').getValue(); + return false; + } + function saveAndAddNew() { + $('redirect_to_new').setValue('true'); + return true; + } +</script> +<h1 class="marginbottom10"><%= message('manual_measures.add_measure_title') -%></h1> + +<% if @measure && @measure.errors.on_base + @measure.errors.on_base.each do |error| %> + <div class="error"><%= error -%></div> +<% end + end +%> + +<form action="<%= url_for :action => (@measure ? 'save' : 'new') -%>" method="POST" id="createForm"> + <input type="hidden" name="id" value="<%= @resource.id -%>"/> + <table class="width100 form"> + <tbody> + <tr> + <td class="keyCell"> + <%= message('manual_measures.col.metric') -%>: + </td> + <td> + <select name="metric" onchange="changeMetric();" id="metricSelect"> + <%= options_grouped_by_domain(Metric.all.select { |m| m.user_managed? }, (@metric ? @metric.key : nil), :include_empty => true) -%> + </select> + <%= link_to message('manual_measures.manage_metrics_link'), :controller => 'metrics', :action => 'index' if has_role?(:admin)-%> + + <% if @metric && @metric.description %> + <br/> + <span class="note"><%= @metric.description -%></span> + <% end %> + </td> + </tr> + <% if @measure %> + <tr> + <td class="keyCell"> + <%= message('manual_measures.col.value') -%>: + </td> + <td> + <input type="text" name="val" id="valueText" value="<%= @measure ? @measure.editable_value : '' -%>"/> + <%= '%' if @metric && @metric.value_type==Metric::VALUE_TYPE_PERCENT -%> + <% if @measure.errors.on('value') + @measure.errors.on('value').each do |error| %> + <span class="error"><%= error -%></span> + <% end + end %> + </td> + </tr> + <tr> + <td class="keyCell"> + <%= message('manual_measures.col.description') -%>: + </td> + <td> + <textarea rows="5" cols="80" name="desc" class="width100"><%= @measure.description -%></textarea> + <% if @measure.errors.on('description') + @measure.errors.on('description').each do |error| %> + <span class="error"><%= error -%></span> + <% end + end %> + </td> + </tr> + <% unless @measure.new_record?() %> + <tr> + <td class="keyCell"> + <%= message('manual_measures.col.last_change') -%>: + </td> + <td> + <%= message('manual_measures.col.last_change_label', :params => [@measure.username, l(@measure.updated_at)]) -%> + </td> + </tr> + <% end %> + <% end %> + <tr> + <td class="keyCell"> + </td> + <td> + <% if @measure %> + <input type="hidden" name="redirect_to_new" value="false" id="redirect_to_new"/> + <input type="submit" value="<%= message('manual_measures.save_button') -%>"/> + <input type="submit" value="<%= message('manual_measures.save_and_add_button') -%>" onclick="saveAndAddNew()"/> + <% end %> + <%= link_to message('cancel'), :action => 'index', :id => @resource.id -%> + </td> + </tr> + </tbody> + </table> +</form> + +<% if @metric %> + <script type="text/javascript"> + $('valueText').focus(); + </script> +<% end %>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/markdown/_help.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/markdown/_help.html.erb index d116702f885..c15a405b420 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/markdown/_help.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/markdown/_help.html.erb @@ -1,16 +1,16 @@ -<h3>Help Tips</h3> +<h3><%= message('help_tips') -%></h3> <table> <tr> - <td>*bold*</td> + <td>*<%= message('bold') -%>*</td> <td class="sep"></td> - <td><b>bold</b></td> + <td><b><%= message('bold') -%></b></td> </tr> <tr> - <td>``code``</td> + <td>``<%= message('code') -%>``</td> <td class="sep"></td> - <td><code>code</code></td> + <td><code><%= message('code') -%></code></td> </tr> <tr> - <td colspan="3">* Bulleted point</td> + <td colspan="3">* <%= message('bulleted_point') -%></td> </tr> </table>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb index 7c1c0f6da9a..9eed83c9fd7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb @@ -4,6 +4,7 @@ <table class="sortable data width100" id="metrics"> <thead> <tr> + <th class="left">Key</th> <th class="left">Name</th> <th class="left">Description</th> <th class="left">Domain</th> @@ -14,10 +15,11 @@ <tbody> <% @metrics.each do |metric| %> <tr> - <td class="left" nowrap><%= h metric.short_name %></td> - <td class="left"><%= h metric.description %></td> - <td class="left" ><%= metric.domain %></td> - <td class="left" ><%= metric.value_type_name %></td> + <td class="left" nowrap><span class="note"><%= metric.key -%></span></td> + <td class="left" nowrap><%= h metric.short_name -%></td> + <td class="left"><%= h metric.description -%></td> + <td class="left" ><%= metric.domain -%></td> + <td class="left" ><%= metric.value_type_name -%></td> <td class="left" width="1%" nowrap> <% if is_admin? && metric.updatable_online? %> <%= button_to 'Edit', {:action => 'index', :id => metric.id}, {:class => 'action', :id => "edit_#{h(metric.short_name)}", :method => 'get'} %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_new.html.erb index 8865f45fbe3..529fae5ef3e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_new.html.erb @@ -3,7 +3,7 @@ <table class="spaced"> <tr> <td align="left" nowrap="nowrap" width="1%"> - Name + <%= message('name') -%> </td> <td align="left"> <input type="text" name="name"/> @@ -11,7 +11,7 @@ </tr> <tr> <td align="left" nowrap="nowrap"> - Language + <%= message('language') -%> </td> <td align="left"> <% languages_select=languages.collect do |language| @@ -29,7 +29,7 @@ <% @plugins_by_language[language.getKey()].each do |plugin| %> <tr> <td align="left" style="vertical-align: top;" nowrap="nowrap" width="1%"> - <%= image_tag'bullet.png' %> <%= plugin.getName() %> XML (optional) + <%= image_tag'bullet.png' %> <%= plugin.getName() %> XML (<%= message('optional').downcase -%>) </td> <td align="left"> <%= file_field_tag plugin.getKey() %> @@ -43,8 +43,8 @@ <table class="spaced"> <tr> <td colspan="2" align="left"> - <%= submit_tag 'create' %> - <a href="<%= url_for :controller => 'profiles', :action => 'index' -%>" class="action">cancel</a> + <%= submit_tag message('create') %> + <a href="<%= url_for :controller => 'profiles', :action => 'index' -%>" class="action"><%= message('cancel') -%></a> </td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb index 5fa8fce9926..03015f5d72a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_tabs.html.erb @@ -4,22 +4,22 @@ %> <ul class="tabs"> <li> - <a href="<%= url_for :controller => 'rules_configuration', :action => 'index', :id => @profile.id %>" <%= "class='selected'" if selected_tab=='Coding rules' -%>>Coding rules</a> + <a href="<%= url_for :controller => 'rules_configuration', :action => 'index', :id => @profile.id %>" <%= "class='selected'" if selected_tab=='Coding rules' -%>><%= message('coding_rules') -%></a> </li> <li> - <a href="<%= url_for :controller => 'alerts', :action => 'index', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='Alerts' -%>>Alerts</a> + <a href="<%= url_for :controller => 'alerts', :action => 'index', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='Alerts' -%>><%= message('alerts') -%></a> </li> <li> - <a href="<%= url_for :controller => 'profiles', :action => 'projects', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='Projects' -%>>Projects</a> + <a href="<%= url_for :controller => 'profiles', :action => 'projects', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='Projects' -%>><%= message('projects') -%></a> </li> <li> - <a href="<%= url_for :controller => 'profiles', :action => 'permalinks', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='Permalinks' -%>>Permalinks</a> + <a href="<%= url_for :controller => 'profiles', :action => 'permalinks', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='Permalinks' -%>><%= message('permalinks') -%></a> </li> <li> - <a href="<%= url_for :controller => 'profiles', :action => 'inheritance', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='inheritance' -%>>Profile inheritance</a> + <a href="<%= url_for :controller => 'profiles', :action => 'inheritance', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='inheritance' -%>><%= message('quality_profiles.profile_inheritance') -%></a> </li> <li> - <a href="<%= url_for :controller => 'profiles', :action => 'changelog', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='changelog' -%>>Changelog</a> + <a href="<%= url_for :controller => 'profiles', :action => 'changelog', :id => @profile.id -%>" <%= "class='selected'" if selected_tab=='changelog' -%>><%= message('changelog') -%></a> </li> <% if new_tab %> <li> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb index f6f2038a346..38521ea84a6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb @@ -1,29 +1,29 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %> <div class="tabs-panel marginbottom10"> <% if @select_versions.nil? %> - No changes has been done on this quality profile. + <%= message('quality_profiles.no_changes_done_on_this_profile') -%> <% else %> <% form_tag({:action => 'changelog'}, {:method => 'post', :class => 'marginbottom10'}) do %> <%= hidden_field_tag "id", @profile.id %> - Changelog from + <%= message('quality_profiles.changelog_from') -%> <%= select_tag "since", options_for_select(@select_versions, @since_version) %> - to + <%= message('to').downcase -%> <%= select_tag "to", options_for_select(@select_versions, @to_version) %> - <%= submit_tag "Load", :id => 'submit'%> + <%= submit_tag message('load_verb'), :id => 'submit'%> <% end %> <table class="data width100"> <thead> <tr> - <th>Profile version</th> - <th>Date</th> - <th>User</th> - <th>Action</th> - <th>Rule</th> - <th>Parameters</th> + <th><%= message('quality_profiles.profile_version') -%></th> + <th><%= message('date') -%></th> + <th><%= message('user') -%></th> + <th><%= message('action') -%></th> + <th><%= message('rule') -%></th> + <th><%= message('parameters') -%></th> </tr> </thead> <% @@ -38,33 +38,32 @@ <td valign="top"> <% if change.old_severity if change.new_severity %> - Severity changed from <%= image_tag "priority/#{change.old_severity_text}.png" %><b><%= change.old_severity_text %></b> to + <%= message('quality_profiles.severity_changed_from_x_to', :params => [image_tag("priority/#{change.old_severity_text}.png"), change.old_severity_text]) -%> <% else %> - Severity was <%= image_tag "priority/#{change.old_severity_text}.png" %><b><%= change.old_severity_text %></b> + <%= message('quality_profiles.severity_was_x', :params => [image_tag("priority/#{change.old_severity_text}.png"), change.old_severity_text]) -%> <% end end %> <% if change.new_severity if change.old_severity %> <%= image_tag "priority/#{change.new_severity_text}.png" %><b><%= change.new_severity_text %></b> <% else %> - Severity set to <%= image_tag "priority/#{change.new_severity_text}.png" %><b><%= change.new_severity_text %></b> + <%= message('quality_profiles.severity_set_to_x', :params => [image_tag("priority/#{change.new_severity_text}.png"), change.new_severity_text]) -%> <% end end %> <% if (change.old_severity or change.new_severity) and change.parameters.size > 0 %> <br/> <% end %> <% change.parameters.each do |param_change| %> - Parameter <b><%=param_change.name %></b> <% if not param_change.old_value %> - set to <b><%= param_change.new_value %></b> + <%= message('quality_profiles.parameter_set_to_x', :params => [param_change.name, param_change.new_value]) -%> <% elsif not param_change.new_value if change.enabled == false %> - was <b><%= param_change.old_value %></b> + <%= message('quality_profiles.parameter_was_x', :params => [param_change.name, param_change.old_value]) -%> <% else %> - reset to default value (was <b><%= param_change.old_value %></b>) + <%= message('quality_profiles.parameter_reset_to_default_value_x', :params => [param_change.name, param_change.old_value]) -%> <% end else %> - changed from <b><%= param_change.old_value %></b> to <b><%= param_change.new_value %></b> + <%= message('quality_profiles.parameter_changed_from_x_to_x', :params => [param_change.name, param_change.old_value, param_change.new_value]) -%> <% end %> <%= "<br/>" unless param_change == change.parameters.last %> <% end%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb index c21ef1e34e4..74c0418d429 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/compare.html.erb @@ -1,5 +1,5 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / - Compare</h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / + <%= message('compare') -%></h1> <form method="GET" class="marginbottom10"> <select name="id1" class="small"> @@ -11,7 +11,7 @@ <option value=""></option> <%= options_for_profiles(@profiles, params[:id2].to_i) %> </select> - <input type="submit" value="Compare" class="small" id="submit-compare"/> + <input type="submit" value="<%= message('compare') -%>" class="small" id="submit-compare"/> </form> <% if @profile1 && @profile2 %> @@ -19,20 +19,20 @@ <table class="header1" id="comparison-header"> <tr> <td width="25%"> - <p>Only in <%= h(@profile1.name) -%></p> - <span class="big"><a href="#in1" id="in1Value"><%= @in1.size -%></a></span> rules + <p><%= message('quality_profiles.only_in_profile_x', :params => h(@profile1.name)) -%></p> + <span class="big"><a href="#in1" id="in1Value"><%= @in1.size -%></a></span> <%= message('rules').downcase -%> </td> <td width="25%"> - <p>Only in <%= h(@profile2.name) -%></p> - <span class="big"><a href="#in2" id="in2Value"><%= @in2.size -%></a></span> rules + <p><%= message('quality_profiles.only_in_profile_x', :params => h(@profile2.name)) -%></p> + <span class="big"><a href="#in2" id="in2Value"><%= @in2.size -%></a></span> <%= message('rules').downcase -%> </td> <td width="25%"> - <p>With different configuration</p> - <span class="big"><a href="#modified" id="modifiedValue"><%= @modified.size -%></a></span> rules + <p><%= message('quality_profiles.with_different_configuration') -%></p> + <span class="big"><a href="#modified" id="modifiedValue"><%= @modified.size -%></a></span> <%= message('rules').downcase -%> </td> <td width="25%"> - <p>With same configuration</p> - <span class="big" id="sameValue"><%= @sames.size -%></span> rules + <p><%= message('quality_profiles.with_same_configuration') -%></p> + <span class="big" id="sameValue"><%= @sames.size -%></span> <%= message('rules').downcase -%> </td> </tr> </table> @@ -46,7 +46,7 @@ <table class="data width100 marginbottom10" id="in1-rules"> <thead> <tr> - <th><a name="in1"/><%= @in1.size -%> rules only in + <th><a name="in1"/><%= message('quality_profiles.x_rules_only_in', :params => @in1.size) -%> <a href="<%= url_for :controller => 'rules_configuration', :action => 'index', :id => @profile1.id -%>"><%= h @profile1.name %></a> </th> </tr> @@ -73,7 +73,7 @@ <table class="data width100 marginbottom10" id="in2-rules"> <thead> <tr> - <th><a name="in2"/><%= @in2.size -%> rules only in + <th><a name="in2"/><%= message('quality_profiles.x_rules_only_in', :params => @in2.size) -%> <a href="<%= url_for :controller => 'rules_configuration', :action => 'index', :id => @profile2.id -%>"><%= h @profile2.name %></a> </th> </tr> @@ -97,7 +97,7 @@ <table class="data width100 marginbottom10" id="modified-rules"> <thead> <tr> - <th width="49%"><a name="modified"/><%= @modified.size -%> rules have a different configuration<br/> + <th width="49%"><a name="modified"/><%= message('quality_profiles.x_rules_have_different_configuration', :params =>@modified.size) -%><br/> <a href="<%= url_for :controller => 'rules_configuration', :action => 'index', :id => @profile1.id -%>"><%= h @profile1.name %></a> </th> <th width="2%"></th> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/edit.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/edit.html.erb index 920580b929c..b96cabb758f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/edit.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/edit.html.erb @@ -1,4 +1,4 @@ -<h1>Editing profile</h1> +<h1>message('quality_profiles.editing_profile')</h1> <% form_for(@profile) do |f| %> <%= f.error_messages %> @@ -12,9 +12,9 @@ <%= f.check_box :active %> </p> <p> - <%= f.submit "Update" %> + <%= f.submit message('update_verb') %> </p> <% end %> -<%= link_to 'Show', @profile %> | -<%= link_to 'Back', profiles_path %> +<%= link_to message('show_verb'), @profile %> | +<%= link_to message('back'), profiles_path %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb index 0c52938ba87..f000c79e958 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb @@ -3,25 +3,25 @@ <ul class="operations"> <li> <%= image_tag 'compare.png' -%> - <a href="<%= ApplicationController.root_context-%>/profiles/compare" id="compare-link">Compare profiles</a> + <a href="<%= ApplicationController.root_context-%>/profiles/compare" id="compare-link"><%= message('quality_profiles.compare_profiles') -%></a> </li> <li class="last"> <%= image_tag 'restore.gif' -%> - <a href="#" onclick="$('restore-form').show();return false;" id="restore-link">Restore profile</a> + <a href="#" onclick="$('restore-form').show();return false;" id="restore-link"><%= message('quality_profiles.restore_profile') -%></a> </li> </ul> </div> <form class="admin marginbottom10" id="restore-form" action="<%= url_for :action => 'restore' -%>" enctype="multipart/form-data" style="display: none" method="post"> <table class="spaced width100"> <tr> - <td width="1%" nowrap>Backup: </td> + <td width="1%" nowrap><%= message('backup_verb') -%>: </td> <td><%= file_field_tag 'backup' %></td> </tr> <tr> <td colspan="2"> - <input type="submit" value="Restore profile"/> - <a href="#" onclick="$('restore-form').reset();$('restore-form').hide();return false;">Cancel</a> + <input type="submit" value="<%= message('quality_profiles.restore_profile') -%>"/> + <a href="#" onclick="$('restore-form').reset();$('restore-form').hide();return false;"><%= message('cancel') -%></a> </td> </tr> </table> @@ -37,11 +37,11 @@ <% if administrator? %> <ul style="float: right" class="horizontal"> <li class="marginleft10 add"> - <a href="#" onClick="$('create-form-<%= language.getKey() -%>').show();$('create-form-<%= language.getKey() -%>-name').focus();return false;" id="create-link-<%= language.getKey() -%>">Create</a> + <a href="#" onClick="$('create-form-<%= language.getKey() -%>').show();$('create-form-<%= language.getKey() -%>-name').focus();return false;" id="create-link-<%= language.getKey() -%>"><%= message('create') -%></a> </li> </ul> <% end %> - <h2><%= language.getName() %> profiles</h2> + <h2><%= message('quality_profiles.x_language_profiles', :params => language.getName()) -%></h2> </div> <% if administrator? %> @@ -49,7 +49,7 @@ <input type="hidden" name="language" value="<%= language.getKey() -%>"></input> <table class="spaced width100"> <tr> - <td width="1%" nowrap>Name: </td> + <td width="1%" nowrap><%= message('name') -%>: </td> <td><input type="text" name="name" id="create-form-<%= language.getKey()-%>-name"></input></td> </tr> <% importers.to_a.sort{|x,y| x.getName() <=> y.getName()}.each do |importer| %> @@ -57,15 +57,15 @@ <td width="1%" nowrap><%= importer.getName() -%>: </td> <td> <%= file_field_tag "backup[#{importer.getKey()}]" %></input> - <span class="note">Optional configuration file</span> + <span class="note"><%= message('quality_profiles.optional_configuration_file') -%></span> </td> </tr> <% end %> <tr> <td colspan="2"> - <input type="submit" value="Create <%= language.getName() %> profile" id="create-submit-<%= language.getKey() -%>"></input> - <a href="#" onclick="$('create-form-<%= language.getKey()-%>').reset();$('create-form-<%= language.getKey()-%>').hide();return false;">Cancel</a> + <input type="submit" value="<%= message('quality_profiles.create_x_language_profile', :params => language.getName()) -%>" id="create-submit-<%= language.getKey() -%>"></input> + <a href="#" onclick="$('create-form-<%= language.getKey()-%>').reset();$('create-form-<%= language.getKey()-%>').hide();return false;"><%= message('cancel') -%></a> </td> </tr> </table> @@ -75,13 +75,13 @@ <table class="data width100" id="profiles_<%= language.getKey() -%>"> <thead> <tr> - <th class="left">Name</th> - <th class="right">Rules</th> - <th class="right">Alerts</th> - <th class="right">Projects</th> - <th class="right">Default</th> + <th class="left"><%= message('name') -%></th> + <th class="right"><%= message('rules') -%></th> + <th class="right"><%= message('alerts') -%></th> + <th class="right"><%= message('projects') -%></th> + <th class="right"><%= message('default') -%></th> <% if administrator? %> - <th width="1%" class="right" colspan="4">Operations</th> + <th width="1%" class="right" colspan="4"><%= message('operations') -%></th> <% end %> </tr> </thead> @@ -104,9 +104,9 @@ <td align="right"> <% if (!profile.default_profile? && administrator?) %> - <%= button_to 'Set as default', { :action => 'set_as_default', :id => profile.id }, :class => 'action', + <%= button_to message('set_as_default'), { :action => 'set_as_default', :id => profile.id }, :class => 'action', :id => "activate_#{u profile.key}", - :confirm => "Are you sure that you want to set the profile '#{profile.name}' as default ?", + :confirm => message('quality_profiles.are_you_sure_want_x_profile_as_default', :params => profile.name), :method => :post %> <% end %> <% if profile.default_profile? %> @@ -120,7 +120,7 @@ <td align="right"> <% if !profile.provided? %> <% form_tag(:action => 'backup', :id => profile.id) do -%> - <input type="submit" name="button_backup" id="backup_<%= u profile.key %>" value="Backup"></input> + <input type="submit" name="button_backup" id="backup_<%= u profile.key %>" value="<%= message('backup_verb') -%>"></input> <% end end %> </td> @@ -129,7 +129,7 @@ <% if !(profile.provided?) %> <% form_tag(:action => 'rename', :id => profile.id) do -%> <%= hidden_field_tag 'rename_' + profile.id.to_s %> - <input type="button" name="button_rename" id="rename_<%= u profile.key %>" value="Rename" onClick='var name=prompt("New name"); if (name!=null) {$("rename_<%= profile.id %>").value=name; submit();} else {return false;}'> + <input type="button" name="button_rename" id="rename_<%= u profile.key %>" value="<%= message('rename') -%>" onClick='var name=prompt("<%= message('quality_profiles.new_name') -%>"); if (name!=null) {$("rename_<%= profile.id %>").value=name; submit();} else {return false;}'> <% end end %> </td> @@ -137,15 +137,15 @@ <td align="right"> <% form_tag(:action => 'copy', :id => profile.id) do -%> <%= hidden_field_tag 'copy_' + profile.id.to_s %> - <input type="button" name="button_copy" id="copy_<%= u profile.key %>" value="Copy" onClick='var name=prompt("Name for the new profile"); if (name!=null) {$("copy_<%= profile.id %>").value=name; submit();} else {return false;}'> + <input type="button" name="button_copy" id="copy_<%= u profile.key %>" value="<%= message('copy') -%>" onClick='var name=prompt("<%= message('quality_profiles.name_for_new_profile') -%>"); if (name!=null) {$("copy_<%= profile.id %>").value=name; submit();} else {return false;}'> <% end %> </td> <td> <% if profile.deletable? %> - <%= button_to "Delete", { :action => 'delete', :id => profile.id }, :class => 'action red-button', + <%= button_to message('delete'), { :action => 'delete', :id => profile.id }, :class => 'action red-button', :id => "delete_#{u profile.key}", - :confirm => "Are you sure that you want to delete the profile '#{profile.name}' ?", + :confirm => message('quality_profiles.are_you_sure_want_delete_profile_x', :params => profile.name), :method => :post %> <% end %> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb index c97b7fc1dc6..e4186610c66 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb @@ -1,4 +1,4 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'inheritance'} %> <div class="tabs-panel marginbottom10"> @@ -31,15 +31,15 @@ <td valign="top" width="300"> <div class="admin"> <% if @profile.provided? %> - <p>This profile can not be edited.</p> + <p><%= message('quality_profiles.profile_cant_be_edited') -%></p> <% else %> - <h3>Set parent:</h3> - <p>Inherit rules configuration from the profile:</p> + <h3><%= message('quality_profiles.set_parent') -%>:</h3> + <p><%= message('quality_profiles.inherit_rules_from_profile') -%>:</p> <% form_tag({:action => 'change_parent'}, {:method => 'post'}) do %> <%= hidden_field_tag "id", @profile.id %> <%= select_tag "parent_name", options_for_select(@select_parent, @profile.parent_name) %> - <%= submit_tag "Change", :id => 'submit_parent'%> + <%= submit_tag message('change_verb'), :id => 'submit_parent'%> <% end %> <% end %> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/new.html.erb index 09d970647e3..7706b78162b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/new.html.erb @@ -1,4 +1,4 @@ -<h1>New profile</h1> +<h1><%= message('quality_profiles.new_profile') -%></h1> <% form_for(@profile) do |f| %> <%= f.error_messages %> @@ -12,8 +12,8 @@ <%= f.check_box :active %> </p> <p> - <%= f.submit "Create" %> + <%= f.submit message('create') %> </p> <% end %> -<%= link_to 'Back', profiles_path %> +<%= link_to message('back'), profiles_path %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb index 0b1bd2acd4d..e583d280f9a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/permalinks.html.erb @@ -1,10 +1,10 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Permalinks'} %> <div class="tabs-panel marginbottom10 "> <% exporters=controller.java_facade.getProfileExportersForLanguage(@profile.language) %> <% if exporters.empty? %> - <p>No permalinks</p> + <p><%= message('quality_profiles.no_permalinks') -%></p> <% else %> <br/> <table class="data without-header marginbottom10" id="permalinks-table"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb index 59afeb3554d..ce16627b5db 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb @@ -1,4 +1,4 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Projects'} %> <div class="tabs-panel"> @@ -8,7 +8,7 @@ <table> <tr> <td style="padding: 5px 0" valign="top"> - <h3>Available projects</h3> + <h3><%= message('quality_profiles.available_projects') -%></h3> <select name="from" id="from" size="10" style="max-width:380px;margin-top: 5px" multiple="multiple"> <% @available_projects.each do |project| %> <option value="<%= project.id -%>"><%= project.name %><%= " (#{project.profile.name})" if project.profile %></option> @@ -16,18 +16,18 @@ </select> </td> <td align="center" style="padding: 0 10px;"> - <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select »</button><br/> - <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all »</button><br/><br/> - <button id="select_left" onclick="SelectBox.move('to', 'from');return false;">« unselect</button><br/> - <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;">« unselect all</button> + <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;"><%= message('select_verb').downcase -%> »</button><br/> + <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;"><%= message('select_all').downcase -%> »</button><br/><br/> + <button id="select_left" onclick="SelectBox.move('to', 'from');return false;">« <%= message('unselect_verb').downcase -%></button><br/> + <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;">« <%= message('unselect_all').downcase -%></button> </td> <td class="box" style="padding: 5px 10px;" valign="top"> - <h3>Associated projects</h3> + <h3><%= message('quality_profiles.associated_projects') -%></h3> <select name="projects[]" id="to" size="10" multiple="multiple" style="min-width: 300px;margin: 5px 0;"> <%= options_from_collection_for_select(@profile.projects, "id", "name") %> </select><br/> <div style="padding:5px 0"> - <input type="submit" id="save" value="Save" onclick="SelectBox.select_all('to');submit();"></input> + <input type="submit" id="save" value="<%= message('save') -%>" onclick="SelectBox.select_all('to');submit();"></input> </div> </td> </tr> @@ -41,7 +41,7 @@ SelectBox.init('to'); <% else %> <% if @profile.projects.empty? %> - <p>No projects are explicitly associated to the profile '<%= @profile.name %>'.</p> + <p><%= message('quality_profiles.no_projects_associated_to_profile_x', :params => @profile.name) -%></p> <% else %> <ol> <% @profile.projects.each do |project| %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb index 2d2724e7536..72303b086d5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/show.html.erb @@ -1,13 +1,13 @@ <p> - <b>Name:</b> + <b>message('name'):</b> <%=h @profile.name %> </p> <p> - <b>Active:</b> + <b>message('active'):</b> <%=h @profile.active %> </p> -<%= link_to 'Edit', edit_profile_path(@profile) %> | -<%= link_to 'Back', profiles_path %> +<%= link_to message('edit'), edit_profile_path(@profile) %> | +<%= link_to message('back'), profiles_path %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_dashboard_edit_review.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_dashboard_edit_review.html.erb deleted file mode 100644 index 4f9e4507299..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_dashboard_edit_review.html.erb +++ /dev/null @@ -1,73 +0,0 @@ -<%= render :partial => 'layouts/flashes', :object => 'reviews_flashes' %> - -<% form_for :review, @review, :url => { :action => 'add_review', :sid => @snapshot.id }, :method => 'post' do |f| %> - <table class="spaced admin" style="padding: 5px"> - - <% review_metrics = [''] + @review_types.collect do |metric| - ["#{metric.short_name}", metric.id] - end - if review_metrics.size>0 %> - <tr> - <td align="left" colspan="2" nowrap> - <span class="comments">Metric (<%= link_to 'configure', {:controller => 'metrics', :action => 'index'}, {:class => 'action'} %>)</span><br/> - <%= f.select( :metric_id, review_metrics, {}, {:onChange => "selectReviewMetric();"}) %></td> - </tr> - <tr> - <td colspan="2"> - <% @review_types.each do |metric| %> - <span id='review_description_<%= metric.id %>' style='display:none' class='review_description_update comments'> - <%= metric.description %> - </span> - <% end %> - <td> - </tr> - <tr> - <td align="left"><span class="comments">Date*</span><br/> - <%= f.date_select :measure_date %> - </td> - <td align="left" nowrap> - <span class="comments">Value*</span> - <% @review_types.each do |metric| -%> - <span id='review_value_<%= metric.id %>' style='display:none' class='review_description_update comments'> - (<%= metric.value_type_name -%>) - </span> - <% end -%> - <br/> - <%= f.text_field :value, :size => 10 %> - </td> - </tr> - <tr> - <td align="left" colspan="2"><span class="comments">Description</span><br/> - <%= text_area_tag :description, '', :rows => 3, :cols => 40 %></td> - </tr> - <tr> - <td align="left" colspan="2"><span class="comments">Link</span><br/> - <%= text_field_tag :url, '', :size => 40 %> - </td> - </tr> - <tr> - <td align="left" colspan="2"> - <%= submit_tag( "Submit", :id => 'save_review' ) %> - <%= link_to 'cancel', {:action => 'index', :id => @snapshot.project.id} , - {:id => 'cancel_add_review', :class => 'action'}%> - </td> - </tr> - <tr> - <td colspan="2"><span class="comments">* required fields</span></td> - </tr> - <% else %> - <tr> - <td align="left" colspan="2"> - <p><img src="../../images/controls/error.gif" /> - Please - <%= link_to 'create metrics.', {:controller => 'metrics', :action => 'index'}, {:class => 'action'} %> - </p> - </td> - </tr> - <% end %> - </table> -<% end %> - - - - diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/events.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/events.html.erb index 7d76f8ede80..0d520b56241 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/events.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/events.html.erb @@ -1,10 +1,10 @@ <% show_admin_actions=is_admin?(@snapshot) %> -<h3>Events +<h3><%= message('events') -%> <select class="small" id="select_category" onchange="<%= remote_function(:update => 'events_portlet', :url => { :controller => :project, :action => :events, :id => @snapshot.id }, :with => "'category=' + $F('select_category')", :method => 'get') -%>"> -<option value="">All</option> +<option value=""><%= message('all') -%></option> <% @categories.each do |categ| %> -<option value="<%= h categ.name -%>" <%= 'selected' if @category==categ.name -%>><%= h categ.name %></option> +<option value="<%= h categ.name -%>" <%= 'selected' if @category==categ.name -%>><%= h message('event.category.' + categ.name, :default => categ.name) %></option> <% end %> </select></h3> @@ -25,7 +25,7 @@ %> <tr class="<%= cycle 'even','odd' -%>"> <td x="<%= event.event_date -%>"><%= l(event.event_date.to_date) %></td> - <td><%= event.category %></td> + <td><%= h message('event.category.' + event.category, :default => event.category) %></td> <td><%= event.name %></td> <td> <% unless event.description.blank? %> @@ -34,8 +34,8 @@ </td> <td> <% if show_admin_actions %> - <%= link_to_remote 'Edit', {:url => edit_event_path(event), :method => :get, :update => "event_form", :complete => "$('event_form').show();"}, :class => 'action', :id => "edit_event_#{h event.name}" %> - <%= link_to 'Delete', event, :confirm => 'Are you sure ?', :method => :delete, :class => 'action',:id => "delete_event_#{h event.name}" %> + <%= link_to_remote message('edit'), {:url => edit_event_path(event), :method => :get, :update => "event_form", :complete => "$('event_form').show();"}, :class => 'action', :id => "edit_event_#{h event.name}" %> + <%= link_to message('delete'), event, :confirm => message('are_you_sure'), :method => :delete, :class => 'action',:id => "delete_event_#{h event.name}" %> <% end %> </td> </tr> @@ -49,12 +49,12 @@ </table> <% if index>=max_rows %> - <a href="#" onclick="$('all_events').show();$('show_more_events').hide()" id="show_more_events" class="action">Show more</a> + <a href="#" onclick="$('all_events').show();$('show_more_events').hide()" id="show_more_events" class="action"><%= message('show_more') -%></a> <% end %> <% if show_admin_actions %> -<%= link_to_remote "Add an event", {:url => { :controller => 'events', :action => "new", :rid => @snapshot.project_id, :sid => @snapshot.id }, +<%= link_to_remote message('events.add_an_event'), {:url => { :controller => 'events', :action => "new", :rid => @snapshot.project_id, :sid => @snapshot.id }, :update => "event_form", :success => "$('event_form').show();"}, {:class => 'action'} %> <% end %> <div id="event_form" /> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_plugins.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_plugins.html.erb index 445b5598a21..7582ee2d3d4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_plugins.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/settings/_plugins.html.erb @@ -1,4 +1,4 @@ -<h2>Plugin settings</h2> +<h1 class="marginbottom10">Settings</h1> <div class="yui-g widget" id="widget_plugins"> <%= render :partial => 'settings/plugins', :locals => {:project=>@project} %> </div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb index 96c67ece219..d3fc617b3c1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb @@ -8,7 +8,7 @@ <td class="sep"> </td> <% if m=measure('new_line_coverage') %> - <td class="name">Line coverage:</td> + <td class="name"><%= message('metric.line_coverage.name') -%>:</td> <td class="value"><%= format_variation(m, :period => @period, :style => 'none') -%></td> <% else %> <td colspan="2"></td> @@ -16,7 +16,7 @@ <td class="sep"> </td> <% if m=measure('new_branch_coverage') %> - <td class="name">Branch coverage:</td> + <td class="name"><%= message('metric.branch_coverage.name') -%>:</td> <td class="value"><%= format_variation(m, :period => @period, :style => 'none') -%></td> <% else %> <td colspan="2"></td> @@ -25,7 +25,7 @@ <tr> <td class="sep"> </td> <% if m=measure('new_uncovered_lines') %> - <td class="name">Uncovered lines:</td> + <td class="name"><%= message('metric.uncovered_lines.name') -%>:</td> <td class="value"><%= format_variation(m, :period => @period, :style => 'none') -%>/<%= format_variation('new_lines_to_cover', :period => @period, :style => 'none') -%></td> <% else %> <td colspan="2"></td> @@ -33,7 +33,7 @@ <td class="sep"> </td> <% if m=measure('new_uncovered_conditions') %> - <td class="name">Uncovered conditions: </td> + <td class="name"><%= message('metric.uncovered_conditions.name') -%>: </td> <td class="value"><%= format_variation(m, :period => @period, :style => 'none') -%>/<%= format_variation('new_conditions_to_cover', :period => @period, :style => 'none') -%></td> <% else %> <td colspan="2"></td> @@ -45,16 +45,16 @@ <tr> <td class="big" rowspan="2"><%= format_measure('coverage', :default => '-') -%></td> <td class="sep"> </td> - <%= render :partial => 'measure', :locals => {:measure => measure('line_coverage'), :title => 'Line coverage'} -%> + <%= render :partial => 'measure', :locals => {:measure => measure('line_coverage'), :title => message('metric.line_coverage.name')} -%> <td class="sep"> </td> - <%= render :partial => 'measure', :locals => {:measure => measure('branch_coverage'), :title => 'Branch coverage'} -%> + <%= render :partial => 'measure', :locals => {:measure => measure('branch_coverage'), :title => message('metric.branch_coverage.name')} -%> </tr> <tr> <td class="sep"> </td> - <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_lines'), :title => 'Uncovered lines', :ratio => measure('lines_to_cover')} -%> + <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_lines'), :title => message('metric.uncovered_lines.name'), :ratio => measure('lines_to_cover')} -%> <td class="sep"> </td> - <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_conditions'), :title => 'Uncovered conditions', :ratio => measure('conditions_to_cover')} -%> + <%= render :partial => 'measure', :locals => {:measure => measure('uncovered_conditions'), :title => message('metric.uncovered_conditions.name'), :ratio => measure('conditions_to_cover')} -%> </tr> </table> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb index de5451252c1..e825e52289d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_source.html.erb @@ -5,31 +5,31 @@ <table class="metrics"> <% if m=measure('lines') %> <tr> - <td class="name">Lines:</td> + <td class="name"><%= message('metric.lines.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('ncloc') %> <tr> - <td class="name">Lines of code:</td> + <td class="name"><%= message('metric.ncloc.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('functions') %> <tr> - <td class="name">Methods:</td> + <td class="name"><%= message('metric.functions.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('accessors') %> <tr> - <td class="name">Accessors:</td> + <td class="name"><%= message('metric.accessors.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('paragraphs') %> <tr> - <td class="name">Paragraphs:</td> + <td class="name"><%= message('metric.paragraphs.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> @@ -39,25 +39,25 @@ <table class="metrics"> <% if m=measure('statements') %> <tr> - <td class="name">Statements:</td> + <td class="name"><%= message('metric.statements.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('complexity') %> <tr> - <td class="name">Complexity:</td> + <td class="name"><%= message('metric.complexity.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('function_complexity') %> <tr> - <td class="name">Complexity/method:</td> + <td class="name"><%= message('metric.function_complexity.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('paragraph_complexity') %> <tr> - <td class="name">Complexity/paragraph:</td> + <td class="name"><%= message('metric.paragraph_complexity.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> @@ -67,25 +67,25 @@ <table class="metrics"> <% if m=measure('comment_lines_density') %> <tr> - <td class="name">Comments:</td> + <td class="name"><%= message('metric.comment_lines_density.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('comment_lines') %> <tr> - <td class="name">Comment lines:</td> + <td class="name"><%= message('metric.comment_lines.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('commented_out_code_lines') %> <tr> - <td class="name">Commented-out LOC:</td> + <td class="name"><%= message('metric.commented_out_code_lines.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('comment_blank_lines') %> <tr> - <td class="name">Blank comments:</td> + <td class="name"><%= message('metric.comment_blank_lines.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> @@ -95,19 +95,19 @@ <table class="metrics"> <% if m=measure('public_documented_api_density') %> <tr> - <td class="name">Public documented API:</td> + <td class="name"><%= message('metric.public_documented_api_density.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('public_undocumented_api') %> <tr> - <td class="name">Public undocumented API:</td> + <td class="name"><%= message('metric.public_undocumented_api.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('public_api') %> <tr> - <td class="name">Public API:</td> + <td class="name"><%= message('metric.public_api.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> @@ -117,25 +117,25 @@ <table class="metrics"> <% if m=measure('classes') %> <tr> - <td class="name">Classes:</td> + <td class="name"><%= message('metric.classes.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('noc') %> <tr> - <td class="name">Number of Children:</td> + <td class="name"><%= message('metric.noc.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('dit') %> <tr> - <td class="name">Depth in Tree:</td> + <td class="name"><%= message('metric.dit.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> <% if m=measure('rfc') %> <tr> - <td class="name">Response for Class (RFC):</td> + <td class="name"><%= message('metric.rfc.name') -%>:</td> <td class="value"><%= format_measure(m) -%></td> </tr> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb index 9e6522c5f88..58ed8b42cc9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_violations.html.erb @@ -2,31 +2,31 @@ <% if @period && measure('new_violations') %> <table> <tr> - <td><span class="big"><%= format_variation('new_violations', :default => 0, :period => @period, :style => 'none') -%></span> new violations</td> + <td><span class="big"><%= format_variation('new_violations', :default => 0, :period => @period, :style => 'none') -%></span> <%= message('new_violations').downcase -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/BLOCKER.png' -%></td> - <td class="name">Blocker:</td> + <td class="name"><%= message('blocker') -%>:</td> <td class="value"><%= format_variation('new_blocker_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/CRITICAL.png' -%></td> - <td class="name">Critical:</td> + <td class="name"><%= message('critical') -%>:</td> <td class="value"><%= format_variation('new_critical_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MAJOR.png' -%></td> - <td class="name">Major:</td> + <td class="name"><%= message('major') -%>:</td> <td class="value"><%= format_variation('new_major_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MINOR.png' -%></td> - <td class="name">Minor:</td> + <td class="name"><%= message('minor') -%>:</td> <td class="value"><%= format_variation('new_minor_violations', :default => 0, :period => @period, :style => 'none') -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/INFO.png' -%></td> - <td class="name">Info:</td> + <td class="name"><%= message('info') -%>:</td> <td class="value"><%= format_variation('new_info_violations', :default => 0, :period => @period, :style => 'none') -%></td> </tr> </table> @@ -34,31 +34,31 @@ <% else %> <table class="sourceHeader"> <tr> - <td nowrap><span class="big"><%= format_measure('violations', :default => 0) -%></span> violations</td> + <td nowrap><span class="big"><%= format_measure('violations', :default => 0) -%></span> <%= message('violations').downcase -%></td> <td class="sep"> </td> <td nowrap><%= image_tag 'priority/BLOCKER.png' -%></td> - <td class="name">Blocker:</td> + <td class="name"><%= message('blocker') -%>:</td> <td class="value"><%= format_measure('blocker_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/CRITICAL.png' -%></td> - <td class="name">Critical:</td> + <td class="name"><%= message('critical') -%>:</td> <td class="value"><%= format_measure('critical_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MAJOR.png' -%></td> - <td class="name">Major:</td> + <td class="name"><%= message('major') -%>:</td> <td class="value"><%= format_measure('major_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/MINOR.png' -%></td> - <td class="name">Minor:</td> + <td class="name"><%= message('minor') -%>:</td> <td class="value"><%= format_measure('minor_violations', :default => 0) -%></td> <td class="sep"> </td> <td><%= image_tag 'priority/INFO.png' -%></td> - <td class="name">Info:</td> + <td class="name"><%= message('info') -%>:</td> <td class="value"><%= format_measure('info_violations', :default => 0) -%></td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb index 7e765102206..df02860d42c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_options.html.erb @@ -28,7 +28,7 @@ if @expandable %> <td class="<%= 'first' if first -%>"> <input type="checkbox" value="true" name="expand" id="expand" <%= 'checked' if @expanded -%> onclick="applyOptions()"/> - <label for="expand">Full source</label> + <label for="expand"><%= message('full_source') -%></label> </td> <% first=false end %> @@ -36,7 +36,7 @@ <% if @scm_available && !@display_violations && @snapshot.project_snapshot.periods? %> <td class="<%= 'first' if first -%>"> <select id="period" name="period" onchange="applyOptions()"> - <option value="">Time changes...</option> + <option value=""><%= message('time_changes') -%>...</option> <%= period_select_options(@snapshot, 1) -%> <%= period_select_options(@snapshot, 2) -%> <%= period_select_options(@snapshot, 3) -%> @@ -51,7 +51,7 @@ <% if @display_violations %> <td class="<%= 'first' if first -%>"> <select id="period" name="period" onchange="applyOptions()"> - <option value="">Time changes...</option> + <option value=""><%= message('time_changes') -%>...</option> <%= violation_period_select_options(@snapshot, 1) -%> <%= violation_period_select_options(@snapshot, 2) -%> <%= violation_period_select_options(@snapshot, 3) -%> @@ -67,10 +67,10 @@ <% if @display_coverage %> <td class="<%= 'first' if first -%>"> <select id="coverage_filter" name="coverage_filter" onchange="applyOptions()"> - <option value="lines_to_cover" <%= 'selected' if @coverage_filter=='lines_to_cover' -%>>Lines to cover</option> - <option value="uncovered_lines" <%= 'selected' if @coverage_filter=='uncovered_lines' -%>>Uncovered lines</option> - <option value="conditions_to_cover" <%= 'selected' if @coverage_filter=='conditions_to_cover' -%>>Branches to cover</option> - <option value="uncovered_conditions" <%= 'selected' if @coverage_filter=='uncovered_conditions' -%>>Uncovered branches</option> + <option value="lines_to_cover" <%= 'selected' if @coverage_filter=='lines_to_cover' -%>><%= message('metric.lines_to_cover.name') -%></option> + <option value="uncovered_lines" <%= 'selected' if @coverage_filter=='uncovered_lines' -%>><%= message('metric.uncovered_lines.name') -%></option> + <option value="conditions_to_cover" <%= 'selected' if @coverage_filter=='conditions_to_cover' -%>><%= message('metric.conditions_to_cover.name') -%></option> + <option value="uncovered_conditions" <%= 'selected' if @coverage_filter=='uncovered_conditions' -%>><%= message('metric.uncovered_conditions.name') -%></option> </select> </td> <% first=false diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb index 06d89dc5414..5546d9d64ce 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_rules_filter.html.erb @@ -32,14 +32,14 @@ end %> <select id="rule" name="rule" onchange="applyOptions()"> - <option value="">All violations</option> - <option value="f-positive" <%= 'selected' if params[:rule]=="f-positive" -%>>False-Positives only</option> - <optgroup label="Severity"> + <option value=""><%= message('all_violations') -%></option> + <option value="f-positive" <%= 'selected' if params[:rule]=="f-positive" -%>><%= message('false_positives_only') -%></option> + <optgroup label="<%= message('severity') -%>"> <% if blocker_violations value=(@period ? blocker_violations.variation(@period) : blocker_violations.value) if value && value>0 %> - <option value="<%= Sonar::RulePriority::BLOCKER.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::BLOCKER.to_s -%>>Blocker (<%= blocker_violations.format_numeric_value(value) -%>)</option> + <option value="<%= Sonar::RulePriority::BLOCKER.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::BLOCKER.to_s -%>><%= message('blocker') -%> (<%= blocker_violations.format_numeric_value(value) -%>)</option> <% end end %> @@ -47,7 +47,7 @@ value=(@period ? critical_violations.variation(@period) : critical_violations.value) if value && value>0 %> - <option value="<%= Sonar::RulePriority::CRITICAL.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::CRITICAL.to_s -%>>Critical (<%= critical_violations.format_numeric_value(value) -%>)</option> + <option value="<%= Sonar::RulePriority::CRITICAL.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::CRITICAL.to_s -%>><%= message('critical') -%> (<%= critical_violations.format_numeric_value(value) -%>)</option> <% end end %> @@ -56,7 +56,7 @@ value=(@period ? major_violations.variation(@period) : major_violations.value) if value && value>0 %> - <option value="<%= Sonar::RulePriority::MAJOR.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::MAJOR.to_s -%>>Major (<%= major_violations.format_numeric_value(value) -%>)</option> + <option value="<%= Sonar::RulePriority::MAJOR.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::MAJOR.to_s -%>><%= message('major') -%> (<%= major_violations.format_numeric_value(value) -%>)</option> <% end end %> @@ -65,7 +65,7 @@ value=(@period ? minor_violations.variation(@period) : minor_violations.value) if value && value>0 %> - <option value="<%= Sonar::RulePriority::MINOR.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::MINOR.to_s -%>>Minor (<%= minor_violations.format_numeric_value(value) -%>)</option> + <option value="<%= Sonar::RulePriority::MINOR.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::MINOR.to_s -%>><%= message('minor') -%> (<%= minor_violations.format_numeric_value(value) -%>)</option> <% end end %> @@ -74,7 +74,7 @@ value=(@period ? info_violations.variation(@period) : info_violations.value) if value && value>0 %> - <option value="<%= Sonar::RulePriority::INFO.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::INFO.to_s -%>>Info (<%= info_violations.format_numeric_value(value) -%>)</option> + <option value="<%= Sonar::RulePriority::INFO.to_s -%>" <%= 'selected' if params[:rule]==Sonar::RulePriority::INFO.to_s -%>><%= message('info') -%> (<%= info_violations.format_numeric_value(value) -%>)</option> <% end end %> @@ -82,7 +82,7 @@ </optgroup> - <optgroup label="Rule"> + <optgroup label="<%= message('rule') -%>"> <%= options_for_select(rule_options, params[:rule].to_i) -%> </optgroup> </select>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb index 3374fc037fc..9c629eaad77 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb @@ -13,22 +13,22 @@ first=true if @snapshot.source %> - <li class="<%= 'first' if first -%>"><a href="<%= ApplicationController.root_context -%>/api/sources?resource=<%= @resource.key -%>&format=txt">Raw</a></li> + <li class="<%= 'first' if first -%>"><a href="<%= ApplicationController.root_context -%>/api/sources?resource=<%= @resource.key -%>&format=txt"><%= message('raw') -%></a></li> <% first=false end if request.xhr? %> - <li class="<%= 'first' if first -%>"><a href="<%= ApplicationController.root_context -%>/resource/index/<%= @resource.key -%>" onclick="window.open(this.href,'resource','height=800,width=900,scrollbars=1,resizable=1');return false;">New Window</a></li> + <li class="<%= 'first' if first -%>"><a href="<%= ApplicationController.root_context -%>/resource/index/<%= @resource.key -%>" onclick="window.open(this.href,'resource','height=800,width=900,scrollbars=1,resizable=1');return false;"><%= message('new_window') -%></a></li> <% end %> </ul> <ul class="tabs" > <% if request.xhr? %> <% @extensions.each do |extension| %> - <li><a href="#" onclick="loadAjaxTab('<%= @resource.id -%>','<%= extension.getId() -%>',<%= display_title -%>)" class="<%= 'selected' if @extension && @extension.getId()==extension.getId() -%>"><%= extension.getTitle() -%></a></li> + <li><a href="#" onclick="loadAjaxTab('<%= @resource.id -%>','<%= extension.getId() -%>',<%= display_title -%>)" class="<%= 'selected' if @extension && @extension.getId()==extension.getId() -%>"><%= message(extension.getId() + '.page', :default => extension.getTitle()) %></a></li> <% end %> <% else %> <script>function loadTab(url) {$('resource-loading').show();document.location.href=url;return false;}</script> <% @extensions.each do |extension| %> - <li><a href="#" onClick="loadTab('<%= url_for(:overwrite_params => {:tab => extension.getId(), :metric => nil}) -%>')" class="<%= 'selected' if @extension && @extension.getId()==extension.getId() -%>"><%= extension.getTitle() -%></a></li> + <li><a href="#" onClick="loadTab('<%= url_for(:overwrite_params => {:tab => extension.getId(), :metric => nil}) -%>')" class="<%= 'selected' if @extension && @extension.getId()==extension.getId() -%>"><%= message(extension.getId() + '.page', :default => extension.getTitle()) %></a></li> <% end %> <% end %> <li> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb index e77da238aeb..b692a19a301 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb @@ -22,19 +22,19 @@ <% if violation.switched_off? %> <%= image_tag("sep12.png") -%> - <span class="falsePositive">False-Positive</span> + <span class="falsePositive"><%= message('false_positive') -%></span> <% end %> <% if violation.review && violation.review.isReopened? %> <%= image_tag("sep12.png") -%> - <span class="review-reopened">Reopened</span> + <span class="review-reopened"><%= message('reopened') -%></span> <% end %> <% if violation.review && violation.review.assignee_id %> <%= image_tag("sep12.png") -%> - Assigned to: <%= h(violation.review.assignee.name) -%> + <%= message('assigned_to') -%>: <%= h(violation.review.assignee.name) -%> <% end %> @@ -46,14 +46,14 @@ unless violation.switched_off? %> - <%= link_to_remote (violation.review.isResolved? ? "Reopen" : "Resolve"), + <%= link_to_remote (violation.review.isResolved? ? message('reopen') : message('resolve')), :url => { :controller => "reviews", :action => "violation_change_status", :id => violation.id}, :update => "vId" + violation.id.to_s, - :confirm => violation.review.isResolved? ? "Do you want to reopen this review?" : "Do you want to resolve this review?" -%> + :confirm => violation.review.isResolved? ? message('reviews.do_you_want_to_reopen') : message('reviews.do_you_want_to_resolve') -%> <% unless violation.review && violation.review.isResolved? %> - <%= link_to_remote (violation.review.assignee_id ? "Reassign" : "Assign"), + <%= link_to_remote (violation.review.assignee_id ? message('reassign') : message('assign')), :url => { :controller => "reviews", :action => "violation_assign_form", :violation_id => violation.id}, :update => "vActions" + violation.id.to_s, :complete => "$('vActions" + violation.id.to_s + "').show();$('commentActions" + violation.id.to_s + "').hide();$('assignee_login').focus();" -%> @@ -63,7 +63,7 @@ else %> - <%= link_to_remote "Review", + <%= link_to_remote message('review_verb'), :url => { :controller => "reviews", :action => "violation_comment_form", :id => violation.id }, :update => "reviewForm" + violation.id.to_s, :complete => "$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();$('vActions#{violation.id}').hide();" -%> @@ -71,7 +71,7 @@ <% if (!violation.review) || (violation.review && violation.review.can_change_false_positive_flag?) %> - <%= link_to_remote (violation.switched_off? ? "Unflag as false-positive" : "Flag as false-positive"), + <%= link_to_remote (violation.switched_off? ? message('reviews.unflag_as_false_positive') : message('reviews.flag_as_false_positive')), :url => { :controller => "reviews", :action => "violation_false_positive_form", :id => violation.id, :false_positive => !violation.switched_off? }, :update => "reviewForm" + violation.id.to_s, :complete => "$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();$('vActions" + violation.id.to_s + "').hide();$('commentActions" + violation.id.to_s + "').hide();" -%> @@ -97,7 +97,7 @@ <%= image_tag("sep12.png") -%> - <%= link_to_remote "Add comment", + <%= link_to_remote message('add_comment'), :url => { :controller => "reviews", :action => "violation_comment_form", :id => violation.id }, :update => "reviewForm" + violation.id.to_s, :complete => "$('vActions#{violation.id}').hide();$('commentActions" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus()" -%> @@ -105,16 +105,16 @@ if current_user.id == review_comment.user_id %> - <%= link_to_remote "Edit", + <%= link_to_remote message('edit'), :url => { :controller => "reviews", :action => "violation_comment_form", :comment_id => review_comment.id, :id => violation.id }, :update => "lastComment" + violation.id.to_s, :complete => "$('vActions#{violation.id}').hide();$('commentActions#{violation.id}').hide();$('commentText#{violation.id}').focus();" -%> <% unless comment_index == 0 %> - <%= link_to_remote "Delete", + <%= link_to_remote message('delete'), :url => { :controller => "reviews", :action => "violation_delete_comment", :comment_id => review_comment.id, :id => violation.id }, :update => "vId" + violation.id.to_s, - :confirm => "Do you want to delete this comment?" -%> + :confirm => message('reviews.do_you_want_to_delete_comment') -%> <% end %> <% end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb index 2ec5fe829e0..df4a07ab164 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb @@ -3,11 +3,11 @@ <%= hidden_field_tag :id, params[:review_id] -%> <%= user_autocomplete_field "assignee_login", "" -%> - <%= submit_to_remote "submit_btn", "Assign", + <%= submit_to_remote "submit_btn", message('assign'), :url => { :action => 'assign' }, :update => "review" -%> - <%= link_to_remote 'Cancel', + <%= link_to_remote message('cancel'), :url => { :action => 'show', :id => params[:review_id] }, :update => "review" %> <script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_comment_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_comment_form.html.erb index 2a7723c8324..92067818d04 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_comment_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_comment_form.html.erb @@ -1,5 +1,5 @@ <% - button=(@comment ? 'Update comment' : 'Add comment') + button=(@comment ? message('update_comment') : message('add_comment')) %> <form method="POST" action="save_comment"> <input type="hidden" name="id" value="<%= params[:id] -%>"/> @@ -14,7 +14,7 @@ <br/> <%= submit_to_remote "submit_btn", button, :url => { :action => 'save_comment'}, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'review' -%> - <%= link_to_remote 'Cancel', :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> + <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> </td> <td class="sep"></td> <td style="vertical-align:top;width: 90px"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_false_positive_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_false_positive_form.html.erb index b4a0be8ac11..3a2befa2df4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_false_positive_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_false_positive_form.html.erb @@ -1,10 +1,10 @@ <% if params[:false_positive]=='true' - title = "Why is it a false-positive ?" - button = "Flag as false-positive" + title = message('reviews.why_false_positive') + button = message('reviews.flag_as_false_positive') else - title = "Why is it not a false-positive anymore ?" - button = "Unflag as false-positive" + title = message('reviews.why_not_false_positive') + button = message('reviews.unflag_as_false_positive') end %> <form method="POST" action="violation_flag_as_false_positive"> @@ -16,5 +16,5 @@ <textarea id="commentText" rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea> <%= submit_to_remote "submit_btn", button, :url => { :action => 'flag_as_false_positive' }, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'review' -%> - <%= link_to_remote 'Cancel', :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> + <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> </form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb index 542a584c296..517ca7dae22 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb @@ -1,10 +1,10 @@ <div id="rev_<%= review.id -%>"> <div class="reportTitle"> - <h2>Review #<%= h(review.id.to_s) -%> - <%= h(review.title) -%></h2> + <h2><%= message('reviews.review_number', :params => h(review.id.to_s)) -%> - <%= h(review.title) -%></h2> <% if review.false_positive %> <%= image_tag("sep12.png") -%> - <span class="falsePositive">False-Positive</span> + <span class="falsePositive"><%= message('false_positive') -%></span> <% end %> <% @@ -18,13 +18,13 @@ <% if !violation_switched_off %> - <%= link_to_remote (review.isResolved? ? "Reopen" : "Resolve"), + <%= link_to_remote (review.isResolved? ? message('reopen') : message('resolve')), :url => { :controller => "reviews", :action => "change_status", :id => review.id}, :update => "review", - :confirm => review.isResolved? ? "Do you want to reopen this review?" : "Do you want to resolve this review?" -%> + :confirm => review.isResolved? ? message('reviews.do_you_want_to_reopen') : message('reviews.do_you_want_to_resolve') -%> <% unless review.isResolved? %> - <%= link_to_remote (review.assignee_id ? "Reassign" : "Assign"), + <%= link_to_remote (review.assignee_id ? message('reassign') : message('assign')), :url => { :controller => "reviews", :action => "assign_form", :review_id => review.id}, :update => "assignForm", :complete => "$('rActions').hide(); $('editActions').hide(); $('assignee_login').focus();" -%> @@ -33,7 +33,7 @@ <% end %> <% end %> <% if review.can_change_false_positive_flag? %> - <%= link_to_remote (violation_switched_off ? "Unflag as false-positive" : "Flag as false-positive"), + <%= link_to_remote (violation_switched_off ? message('reviews.unflag_as_false_positive') : message('reviews.flag_as_false_positive')), :url => { :controller => "reviews", :action => "false_positive_form", :id => review.id, :false_positive => !violation_switched_off }, :update => "reviewForm", :complete => "$('reviewForm').show(); $('rActions').hide(); $('editActions').hide(); $('commentText').focus();" -%> @@ -46,21 +46,21 @@ <table class="reportDetails"> <tr> <td class="key"> - Status: + <%= message('status') -%>: </td> <td class="val"> - <%= image_tag "status/#{review.status}.png" -%> <%= review.status.capitalize -%> + <%= image_tag "status/#{review.status}.png" -%> <%= message(review.status.downcase).capitalize -%> </td> <td class="key"> - Severity: + <%= message('severity') -%>: </td> <td class="val"> - <%= image_tag "priority/#{review.severity}.png" -%> <%= review.severity.capitalize -%> + <%= image_tag "priority/#{review.severity}.png" -%> <%= message(review.severity.downcase).capitalize -%> </td> </tr> <tr> <td class="key"> - Assignee: + <%= message('assignee') -%>: </td> <td class="val"> <span id="assignForm"> @@ -68,7 +68,7 @@ </span> </td> <td class="key"> - Author: + <%= message('author') -%>: </td> <td class="val"> <%= h(review.user.name) -%> @@ -76,13 +76,13 @@ </tr> <tr> <td class="key"> - Created: + <%= message('created') -%>: </td> <td class="val"> <%= l(review.created_at, :format => "%m/%b/%y %H:%M") -%> </td> <td class="key"> - Updated: + <%= message('updated') -%>: </td> <td class="val"> <%= l(review.updated_at, :format => "%m/%b/%y %H:%M") -%> @@ -91,7 +91,7 @@ <% if review.rule %> <tr> <td class="key"> - Rule: + <%= message('rule') -%>: </td> <td class="val" colspan="3"> <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => review.rule.key, :layout => 'false' -%>"><%= h(review.rule.name) -%></a> @@ -100,7 +100,7 @@ <% end %> <tr> <td class="key"> - File: + <%= message('file') -%>: </td> <td class="val" colspan="3"> <%= qualifier_icon(@review.resource) -%> @@ -129,12 +129,12 @@ <div class="discussionComment"> <h4> <%= image_tag("reviews/comment.png") -%> <b><%= comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(comment.created_at) -%>) - <% if is_last_comment && current_user %> + <% if is_last_comment && current_user && !review.isClosed? %> <span class="actions" id="editActions"> <%= image_tag("sep12.png") -%> - <%= link_to_remote "Add comment", + <%= link_to_remote message('add_comment'), :url => { :controller => "reviews", :action => "comment_form", :id => review.id }, :update => "reviewForm", :complete => "$('rActions').hide();$('editActions').hide();$('reviewForm').show();$('commentText').focus();" -%> @@ -142,16 +142,16 @@ if current_user.id == comment.user_id %> - <%= link_to_remote "Edit", + <%= link_to_remote message('edit'), :url => { :controller => "reviews", :action => "comment_form", :comment_id => comment.id, :id => review.id }, :update => "lastComment", :complete => "$('rActions').hide();$('editActions').hide();$('commentText').focus();" -%> <% unless comment_index == 0 %> - <%= link_to_remote "Delete", + <%= link_to_remote message('delete'), :url => { :controller => "reviews", :action => "delete_comment", :comment_id => comment.id, :id => review.id }, :update => "review", - :confirm => "Do you want to delete this comment?" -%> + :confirm => message('reviews.do_you_want_to_delete_comment') -%> <% end %> <% end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb index f29909b57dc..5977b875884 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb @@ -5,11 +5,11 @@ <%= hidden_field_tag :id, params[:violation_id] -%> <%= user_autocomplete_field "assignee_login", "" -%> - <%= submit_to_remote "submit_btn", "Assign", + <%= submit_to_remote "submit_btn", message('assign'), :url => { :action => 'violation_assign' }, :update => "vId" + params[:violation_id] -%> - <%= link_to_remote 'Cancel', + <%= link_to_remote message('cancel'), :url => { :action => 'display_violation', :id => params[:violation_id] }, :update => "vId" + params[:violation_id] %> <script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb index b5324ab753b..20752d630fe 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb @@ -1,5 +1,5 @@ <% - button=(@comment ? 'Update comment' : 'Add comment') + button=(@comment ? message('update_comment') : message('add_comment')) %> <form method="POST" onsubmit="new Ajax.Updater('vId<%= params[:id] -%>', '<%= url_for :action => 'violation_save_comment' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});return false;"> @@ -18,11 +18,11 @@ :html => { :id => "submit_btn"+params[:id], :disabled => "true" }, :update => 'vId'+params[:id] -%> - <%= link_to_remote 'Cancel', :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%> + <%= link_to_remote message('cancel'), :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%> <% if @violation.review.nil? || @violation.review.comments.size==0 %> - <span>Assignee:</span> + <span><%= message('assignee') -%>:</span> <%= user_autocomplete_field "assignee_login", current_user.login -%> <% end %> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb index 3c4e89354a1..4d7fbe789e5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_false_positive_form.html.erb @@ -1,10 +1,10 @@ <% if params[:false_positive]=='true' - title = "Why is it a false-positive ?" - button = "Flag as false-positive" + title = message('reviews.why_false_positive') + button = message('reviews.flag_as_false_positive') else - title = "Why is it not a false-positive anymore ?" - button = "Unflag as false-positive" + title = message('reviews.why_not_false_positive') + button = message('reviews.unflag_as_false_positive') end %> <form method="POST" action="violation_flag_as_false_positive"> @@ -16,5 +16,5 @@ <textarea id="commentText<%= params[:id] -%>" rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn<%= params[:id] -%>').disabled='true'; else $('submit_btn<%= params[:id] -%>').disabled='';"></textarea> <%= submit_to_remote "submit_btn"+params[:id], button, :url => { :action => 'violation_flag_as_false_positive' }, :html => { :id => "submit_btn"+params[:id], :disabled => "true" }, :update => 'vId'+params[:id] -%> - <%= link_to_remote 'Cancel', :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%> + <%= link_to_remote message('cancel'), :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%> </form> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb index 74eca028c2b..d1ac7bc7891 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb @@ -22,7 +22,7 @@ function launchSearch(columnName, link) { } </script> <div id="reviews-search"> - <h1>Reviews</h1> + <h1><%= message('reviews') -%></h1> <% form_tag({:action => 'index'}, {:method => 'get'}) do %> <table id="reviews-form" class="header1"> <thead> @@ -33,30 +33,30 @@ function launchSearch(columnName, link) { <tbody> <tr> <td width="1%" nowrap> - <span class="note">Status</span><br/> + <span class="note"><%= message('status') -%></span><br/> <select size="6" name="statuses[]" multiple="multiple" id="statuses" class="withIcons"> - <option <%= 'selected' if @statuses.include?('') -%> value="">Any</option> - <option value="<%= Review::STATUS_OPEN -%>" class="status_open" <%= 'selected' if @statuses.include?(Review::STATUS_OPEN) -%>>Open</option> - <option value="<%= Review::STATUS_REOPENED -%>" class="status_reopened" <%= 'selected' if @statuses.include?(Review::STATUS_REOPENED) -%>>Reopened</option> - <option value="<%= Review::STATUS_RESOLVED -%>" class="status_resolved" <%= 'selected' if @statuses.include?(Review::STATUS_RESOLVED) -%>>Resolved</option> - <option value="<%= Review::STATUS_CLOSED -%>" class="status_closed" <%= 'selected' if @statuses.include?(Review::STATUS_CLOSED) -%>>Closed</option> + <option <%= 'selected' if @statuses.include?('') -%> value=""><%= message('any') -%></option> + <option value="<%= Review::STATUS_OPEN -%>" class="status_open" <%= 'selected' if @statuses.include?(Review::STATUS_OPEN) -%>><%= message('open') -%></option> + <option value="<%= Review::STATUS_REOPENED -%>" class="status_reopened" <%= 'selected' if @statuses.include?(Review::STATUS_REOPENED) -%>><%= message('reopened') -%></option> + <option value="<%= Review::STATUS_RESOLVED -%>" class="status_resolved" <%= 'selected' if @statuses.include?(Review::STATUS_RESOLVED) -%>><%= message('resolved') -%></option> + <option value="<%= Review::STATUS_CLOSED -%>" class="status_closed" <%= 'selected' if @statuses.include?(Review::STATUS_CLOSED) -%>><%= message('closed') -%></option> </select> </td> <td width="1%" nowrap> - <span class="note">Severity</span><br/> + <span class="note"><%= message('severity') -%></span><br/> <select size="6" name="severities[]" multiple="multiple" id="severities" class="withIcons"> - <option <%= 'selected' if @severities.include?('') -%> value="">Any</option> - <option value="<%= Severity::BLOCKER -%>" class="sev_BLOCKER" <%= 'selected' if @severities.include?(Severity::BLOCKER) -%>>Blocker</option> - <option value="<%= Severity::CRITICAL -%>" class="sev_CRITICAL" <%= 'selected' if @severities.include?(Severity::CRITICAL) -%>>Critical</option> - <option value="<%= Severity::MAJOR -%>" class="sev_MAJOR" <%= 'selected' if @severities.include?(Severity::MAJOR) -%>>Major</option> - <option value="<%= Severity::MINOR -%>" class="sev_MINOR" <%= 'selected' if @severities.include?(Severity::MINOR) -%>>Minor</option> - <option value="<%= Severity::INFO -%>" class="sev_INFO" <%= 'selected' if @severities.include?(Severity::INFO) -%>>Info</option> + <option <%= 'selected' if @severities.include?('') -%> value=""><%= message('any') -%></option> + <option value="<%= Severity::BLOCKER -%>" class="sev_BLOCKER" <%= 'selected' if @severities.include?(Severity::BLOCKER) -%>><%= message('blocker') -%></option> + <option value="<%= Severity::CRITICAL -%>" class="sev_CRITICAL" <%= 'selected' if @severities.include?(Severity::CRITICAL) -%>><%= message('critical') -%></option> + <option value="<%= Severity::MAJOR -%>" class="sev_MAJOR" <%= 'selected' if @severities.include?(Severity::MAJOR) -%>><%= message('major') -%></option> + <option value="<%= Severity::MINOR -%>" class="sev_MINOR" <%= 'selected' if @severities.include?(Severity::MINOR) -%>><%= message('minor') -%></option> + <option value="<%= Severity::INFO -%>" class="sev_INFO" <%= 'selected' if @severities.include?(Severity::INFO) -%>><%= message('info') -%></option> </select> </td> <td width="1%" nowrap> - <span class="note">Project</span><br/> + <span class="note"><%= message('project') -%></span><br/> <select size="6" name="projects[]" multiple="multiple" id="projects"> - <option <%= 'selected' if @projects.include?('') -%> value="">Any</option> + <option <%= 'selected' if @projects.include?('') -%> value=""><%= message('any') -%></option> <% projects_for_select.each do |project| name=project.name(true) %> @@ -65,20 +65,20 @@ function launchSearch(columnName, link) { </select> </td> <td width="1%" nowrap> - <span class="note">Created by</span><br/> + <span class="note"><%= message('created_by') -%></span><br/> <%= user_autocomplete_field "author_login", @author_login, { :class => "max-width" } -%> <br/> - <span class="note">Assigned to</span><br/> + <span class="note"><%= message('assigned_to') -%></span><br/> <%= user_autocomplete_field "assignee_login", @assignee_login, { :class => "max-width" } -%> <br/> <br/> <select name="false_positives" id="false_positives" onchange="if(this.value=='only' || this.value=='with') {$('assignee_login').value = ''; $('autocompleteText-assignee_login').value = ''; $('statuses').value = '';};"> - <option <%= 'selected' if @false_positives=='without' -%> value="without">Without false positives</option> - <option <%= 'selected' if @false_positives=='only' -%> value="only">Only false positives</option> + <option <%= 'selected' if @false_positives=='without' -%> value="without"><%= message('reviews.without_false_positives') -%></option> + <option <%= 'selected' if @false_positives=='only' -%> value="only"><%= message('reviews.only_false_positives') -%></option> </select> </td> <td width="1%" style="padding-left: 20px" nowrap> - <span class="note">Id</span><br/> + <span class="note"><%= message('identifier_abbreviated') -%></span><br/> <%= text_field_tag "review_id", @id, :size => 10, :onkeyup => "reviewIdFieldModified(this)" -%> <br/> <br/> @@ -87,7 +87,7 @@ function launchSearch(columnName, link) { <div style="width:100%; text-align: right"> <input type="hidden" name="sort" id="sort" value="<%= @sort -%>"/> <input type="hidden" name="asc" id="asc" value="<%= @asc -%>"/> - <%= submit_tag "Search", :id => 'submit_search' %> + <%= submit_tag message('search_verb'), :id => 'submit_search' %> </div> </td> <td> @@ -102,38 +102,38 @@ function launchSearch(columnName, link) { if @reviews && !@reviews.empty? %> <% if @false_positives=='only' %> - <div style="color:#777777; font-size:93%; padding: 4px 0px 4px 10px;">Showing <span class="falsePositive">false positives</span> only</div> + <div style="color:#777777; font-size:93%; padding: 4px 0px 4px 10px;"><span class="falsePositive"><%= message('reviews.showing_false_positives_only') -%></span></div> <% end %> <table id="reviews-list" class="data width100"> <thead> <tr> <th width="1%" nowrap> - <a href="#" onClick="launchSearch('status', this)">St.</a> + <a href="#" onClick="launchSearch('status', this)"><%= message('status_abbreviated') -%></a> <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'status' -%> </th> <th width="1%" nowrap> - <a href="#" onClick="launchSearch('id', this)">Id</a> + <a href="#" onClick="launchSearch('id', this)"><%= message('identifier_abbreviated') -%></a> <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'id' -%> </th> <th width="1%" nowrap> - <a href="#" onClick="launchSearch('severity', this)">Se.</a> + <a href="#" onClick="launchSearch('severity', this)"><%= message('severity_abbreviated') -%></a> <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'severity' -%> </th> <th> - <a href="#" onClick="launchSearch('title', this)">Title</a> + <a href="#" onClick="launchSearch('title', this)"><%= message('title') -%></a> <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'title' -%> </th> - <th width="1%">Project</th> - <th>Assignee</th> + <th width="1%"><%= message('project') -%></th> + <th><%= message('assignee') -%></th> <th> - <a href="#" onClick="launchSearch('updated_at', this)">Age</a> + <a href="#" onClick="launchSearch('updated_at', this)"><%= message('age') -%></a> <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'updated_at' -%> </th> </tr> </thead> <tfoot> <tr> - <td colspan="6"><%= @reviews.size -%> results + <td colspan="6"><%= @reviews.size -%> <%= message('results') -%> </tr> </tfoot> <tbody> @@ -142,11 +142,11 @@ function launchSearch(columnName, link) { comment = review.comments.last %> <tr class="<%= cycle('even', 'odd') -%>"> - <td><img src="<%= ApplicationController.root_context -%>/images/status/<%= review.status -%>.png" title="<%= review.status.capitalize -%>"/></td> + <td><img src="<%= ApplicationController.root_context -%>/images/status/<%= review.status -%>.png" title="<%= message(review.status.downcase).capitalize -%>"/></td> <td> <%= link_to h(review.id), :controller => "reviews", :action => "view", :id => review.id -%> </td> - <td><img src="<%= ApplicationController.root_context -%>/images/priority/<%= review.severity -%>.png" title="<%= review.severity.capitalize -%>"/></td> + <td><img src="<%= ApplicationController.root_context -%>/images/priority/<%= review.severity -%>.png" title="<%= message(review.severity.downcase).capitalize -%>"/></td> <td> <%= link_to h(review.title), :controller => "reviews", :action => "view", :id => review.id -%> <div class="comment-excerpt"> @@ -168,14 +168,14 @@ function launchSearch(columnName, link) { <% elsif @reviews %> - <p>No results</p> + <p><%= message('no_results') -%></p> <% end %> <% if @security_exclusions %> <br/> - <p class="notes">Due to security settings, some results are not being displayed.</p> + <p class="notes"><%= message('results_not_display_due_to_security') -%></p> <% end %> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb index 30520404489..120f3613207 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb @@ -20,9 +20,9 @@ <% if active_rule %> <% if active_rule.inherited? %> - <img src="<%= ApplicationController.root_context -%>/images/inherited.png" alt="Inherited from parent" title="Inherited from parent"/> + <img src="<%= ApplicationController.root_context -%>/images/inherited.png" alt="Inherited from parent" title="<%= message('rules_configuration.inherited_from_parent') -%>"/> <% elsif active_rule.overrides? %> - <img src="<%= ApplicationController.root_context -%>/images/overrides.png" alt="Overrides parent definition" title="Overrides parent definition"/> + <img src="<%= ApplicationController.root_context -%>/images/overrides.png" alt="Overrides parent definition" title="<%= message('rules_configuration.overrides_parent_definition') -%>"/> <% end %> <% end %> </form> @@ -45,19 +45,19 @@ </tbody> <% end %> <tr> - <td width="10%" nowrap class="left">Key: </td> + <td width="10%" nowrap class="left"><%= message('key') -%>: </td> <td class="left"><%= rule.plugin_rule_key -%></td> </tr> </table> <% if is_admin %> <% if rule.template? %> - <%= button_to "Copy rule", {:action => 'new', :id => profile.id, :rule_id => rule.id}, :id => "copy-#{u rule.key}" %> + <%= button_to message('rules_configuration.copy_rule'), {:action => 'new', :id => profile.id, :rule_id => rule.id}, :id => "copy-#{u rule.key}" %> <% end %> <% if rule.editable? %> - <%= button_to "Edit rule", :action => 'edit', :id => profile.id, :rule_id => rule.id %> + <%= button_to message('rules_configuration.edit_rule'), :action => 'edit', :id => profile.id, :rule_id => rule.id %> <% end %> <% if active_rule && active_rule.overrides? %> - <%= button_to "Revert to parent definition", :overwrite_params => {:action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id} %><br/> + <%= button_to message('rules_configuration.revert_to_parent_definition'), :overwrite_params => {:action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id} %><br/> <% end %> <% end %> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb index c695a0218b7..0e011d5322e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule_param.html.erb @@ -26,7 +26,7 @@ <span id="<%= span_id %>"><%= (param_value.length < 50) ? textfield : textarea %></span> <% if !read_only %> - <%= submit_tag 'update' %> + <%= submit_tag message('update_verb') %> <img src="<%= ApplicationController.root_context -%>/images/loading.gif" style="display:none;" id="param_loading_<%= parameter.id -%>"> <% if active_parameter and active_parameter.errors.size>0 %> <span class="error"><%= active_parameter.errors.on 'value' %></span> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/edit.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/edit.html.erb index de04a3f4e4b..b80e0565774 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/edit.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/edit.html.erb @@ -1,4 +1,4 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> <%= render :partial => 'profiles/tabs', :locals => {:new_tab => 'Edit rule'} %> @@ -21,17 +21,17 @@ <form method="POST" action="<%= url_for :action => 'update', :id => @profile.id, :rule_id => @rule.id -%>"> <table width="100%" class="spaced"> <tr> - <td width="1%" nowrap>Template:</td> + <td width="1%" nowrap><%= message('template') -%>:</td> <td class="sep"> </td> <td><%= h @rule.parent.name -%></td> </tr> <tr> - <td width="1%" nowrap>Name:</td> + <td width="1%" nowrap><%= message('name') -%>:</td> <td class="sep"> </td> <td><input type="text" name="rule[name]" size="80" value="<%= h @rule.name -%>"></input></td> </tr> <tr> - <td width="1%" nowrap>Default severity:</td> + <td width="1%" nowrap><%= message('default_severity') -%>:</td> <td class="sep"> </td> <td> <select name="rule[priority]"> @@ -54,14 +54,14 @@ <td class="sep"> </td> <td valign="top"> <textarea name="rule[description]" cols="80" rows="10" style="vertical-align: baseline"><%= @rule.description -%></textarea> - <span class="small">HTML is allowed.</span> + <span class="small"><%= message('rules_configuration.html_allowed') -%></span> </td> </tr> <tr> <td colspan="3"> - <input type="submit" value="Update"></input> - <input type="submit" value="Delete" onclick="return deleteRule()" class="red-button"></input> - <a href="<%= url_for :action => 'index', :id => @profile.id -%>">Cancel</a> + <input type="submit" value="<%= message('update_verb') -%>"></input> + <input type="submit" value="<%= message('delete') -%>" onclick="return deleteRule()" class="red-button"></input> + <a href="<%= url_for :action => 'index', :id => @profile.id -%>"><%= message('cancel') -%></a> </td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb index 2dab50846d1..484fce0b348 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb @@ -26,7 +26,7 @@ } </script> -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Coding rules'} %> @@ -35,7 +35,7 @@ <% if is_admin? && @profile.provided? %> <div class="line-info note marginbottom10"> - This profile can not be updated but it can be used as a template for your own configuration. Just copy it from the profiles page. + <%= message('rules_configuration.profile_cant_be_updated_description') -%> </div> <% end %> @@ -44,30 +44,30 @@ <table class="spaced" id="search_table"> <tr> <td class="left" valign="top" width="1%" nowrap> - <span class="note">Name/Key</span><br/> + <span class="note"><%= message('name') -%>/<%= message('key') -%></span><br/> <%= text_field_tag "searchtext", @searchtext, :id => 'searchtext' %> </td> <td class="left" valign="top" width="1%" nowrap> - <span class="note">Plugin</span><br/> + <span class="note"><%= message('plugin') -%></span><br/> <%= select_tag "plugins", options_for_select(@select_plugins, @plugins), :id => 'search_plugin', :multiple => true, :size => 6 %> </td> <td class="left" valign="top" width="1%" nowrap> - <span class="note">Severity</span><br/> + <span class="note"><%= message('severity') -%></span><br/> <%= select_tag "priorities", options_for_select(@select_priority, @priorities), :id => 'search_priority', :multiple => true, :size => 6 %> </td> <td class="left" valign="top" width="1%" nowrap> - <span class="note">Status</span><br/> + <span class="note"><%= message('status') -%></span><br/> <%= select_tag "rule_status", options_for_select(@select_status, @status), :id => 'search_status', :size => 6 %> </td> <% if @profile.inherited? %> <td class="left" valign="top" width="1%" nowrap> - <span class="note">Inheritance</span><br/> + <span class="note"><%= message('inheritance') -%></span><br/> <%= select_tag "inheritance", options_for_select(@select_inheritance, @inheritance), :id => 'search_inheritance', :size => 6 %> </td> <% end %> <td class="left" valign="top" > <br/> - <%= submit_tag "Search", :id => 'submit_search' %> + <%= submit_tag message('search_verb'), :id => 'submit_search' %> </td> </tr> </table> @@ -77,41 +77,41 @@ <ul style="float: right" class="horizontal"> <li class="marginleft10"> <div class="csv"> - <a href="<%= url_for(:controller => 'api/rules', :action => 'index', :language => @profile.language, :profile => @profile.name, :plugins => @plugins.join(','), :status => @status, :inheritance => @inheritance, :searchtext => @searchtext, :priorities => @priorities.join(','), :format => 'csv') -%>" onClick="return downloadCsv()" id="download-link" class="">Download</a> + <a href="<%= url_for(:controller => 'api/rules', :action => 'index', :language => @profile.language, :profile => @profile.name, :plugins => @plugins.join(','), :status => @status, :inheritance => @inheritance, :searchtext => @searchtext, :priorities => @priorities.join(','), :format => 'csv') -%>" onClick="return downloadCsv()" id="download-link" class=""><%= message('download_verb') -%></a> </div> </li> <% if enable_modification %> <li class="marginleft10"> - <div class="bulk-edit">Bulk Change: + <div class="bulk-edit"><%= message('bulk_change') -%>: <form action="<%= ApplicationController.root_context -%>/rules_configuration/bulk_edit" method="POST" style="display: inline;vertical-align: middle" id="bulk-form"> <input type="hidden" name="id" value="<%= @profile.id -%>"/> <input type="hidden" name="bulk_rule_ids" value="<%= @rules.map{|r| r.id}.join(',') -%>"/> <select name="bulk_action" onChange="submitBulkForm()" style="height: 16px;margin: 0; padding: 0;vertical-align: top"> <option value="" selected></option> - <option value="activate">Activate all</option> - <option value="deactivate">Deactivate all</option> + <option value="activate"><%= message('activate_all') -%></option> + <option value="deactivate"><%= message('deactivate_all') -%></option> </select> </form> </div> </li> <% end %> </ul> - <h2><%= @rules.size %> results - <% if @hidden_actives && @hidden_actives>0 %><span class="small">[<a href="<%= url_for params.merge({:rule_status => ''}) -%>" id="active-rules-link">+<%= @hidden_actives -%> found in active rules</a>]</span><% end %> - <% if @hidden_inactives && @hidden_inactives>0 %><span class="small">[<a href="<%= url_for params.merge({:rule_status => ''}) -%>" id="inactive-rules-link">+<%= @hidden_inactives -%> found in inactive rules</a>]</span><% end %> + <h2><%= @rules.size %> <%= message('results').downcase -%> + <% if @hidden_actives && @hidden_actives>0 %><span class="small">[<a href="<%= url_for params.merge({:rule_status => ''}) -%>" id="active-rules-link">+<%= message('rules_configuration.x_found_in_active_rules', :params => @hidden_actives) -%></a>]</span><% end %> + <% if @hidden_inactives && @hidden_inactives>0 %><span class="small">[<a href="<%= url_for params.merge({:rule_status => ''}) -%>" id="inactive-rules-link">+<%= message('rules_configuration.x_found_in_inactive_rules', :params => @hidden_inactives) -%></a>]</span><% end %> </h2> </div> <table class="data width100 marginbottom10" id="result_table"> <thead> <tr> - <th class="left" nowrap>Active/Severity</th> - <th class="left">Name <span style="font-weight: normal">[<%= link_to_function("expand/collapse", "toggle_rules()") %>]</span></th> - <th class="right">Plugin</th> + <th class="left" nowrap><%= message('active') -%>/<%= message('severity') -%></th> + <th class="left"><%= message('name') -%> <span style="font-weight: normal">[<%= link_to_function(message('rules_configuration.expand_collapse'), "toggle_rules()") %>]</span></th> + <th class="right"><%= message('plugin') -%></th> </tr> </thead> <tbody> <% if @rules.empty? %> -<tr><td colspan="3" class="even">No results.</td></tr> +<tr><td colspan="3" class="even"><%= message('no_results') -%>.</td></tr> <% end %> <% # avoid executing several times the method is_admin?() diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/new.html.erb index 7fd07ac3f0d..fc3374104f0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/new.html.erb @@ -1,23 +1,23 @@ -<h1 class="marginbottom10"><%= link_to 'Quality profiles', :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> -<%= render :partial => 'profiles/tabs', :locals => {:new_tab => 'New rule'} %> +<%= render :partial => 'profiles/tabs', :locals => {:new_tab => message('rules_configuration.tab.new_rule')} %> <div class="tabs-panel marginbottom10 background-gray"> <form method="POST" action="<%= url_for :action => 'create', :id => @profile.id, :rule_id => @rule.id -%>"> <table width="100%" class="spaced"> <tr> - <td width="1%" nowrap>Template:</td> + <td width="1%" nowrap><%= message('template') -%>:</td> <td class="sep"> </td> <td><%= h @rule.name -%></td> </tr> <tr> - <td width="1%" nowrap>Name:</td> + <td width="1%" nowrap><%= message('name') -%>:</td> <td class="sep"> </td> <td><input type="text" name="rule[name]" size="80"></input></td> </tr> <tr> - <td width="1%" nowrap>Default severity:</td> + <td width="1%" nowrap><%= message('default_severity') -%>:</td> <td class="sep"> </td> <td> <select name="rule[priority]"> @@ -36,16 +36,16 @@ </tr> <% end %> <tr> - <td width="1%" nowrap style="vertical-align: top">Description:</td> + <td width="1%" nowrap style="vertical-align: top"><%= message('description') -%>:</td> <td class="sep"> </td> <td valign="top"> <textarea name="rule[description]" cols="80" rows="10" style="vertical-align: baseline"></textarea> - <span class="small">HTML is allowed.</span> + <span class="small"><%= message('rules_configuration.html_allowed') -%></span> </td> </tr> <tr> <td colspan="3"> - <input type="submit" value="Create"></input> <a href="<%= url_for :action => 'index', :id => @profile.id -%>">Cancel</a> + <input type="submit" value="<%= message('create') -%>"></input> <a href="<%= url_for :action => 'index', :id => @profile.id -%>"><%= message('cancel') -%></a> </td> </tr> </table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/login.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/login.html.erb index b4a6ccb4897..697a71e35ed 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/login.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/login.html.erb @@ -3,7 +3,7 @@ <td align="center"> <div id="login_form"> <form action="<%= url_for :controller => 'sessions', :action => 'login' -%>" method="post"> - <h3><%= label_tag 'login' %></h3> + <h3><%= label_tag message('login') %></h3> <p> <%= text_field_tag 'login', '', {:maxlength => 40, :size => 30, :disabled => false} %> @@ -11,15 +11,15 @@ <br/><span class="desc">Not a member? <%= link_to 'Sign up', :controller => 'users', :action => 'new' -%> for an account.</span> <% end %> </p> - <h3><%= label_tag 'password' %></h3> + <h3><%= label_tag message('password') %></h3> <p> <%= password_field_tag 'password', nil, :size => 30 %> </p> <p> - <%= check_box_tag 'remember_me', '1', @remember_me %> <%= label_tag 'remember_me', 'Remember me on this computer' %> + <%= check_box_tag 'remember_me', '1', @remember_me %> <%= label_tag 'remember_me', message('sessions.remember_me') %> </p> <p> - <%= submit_tag 'Log in' %> or <a href="<%= home_path -%>" class="action">Cancel</a> + <%= submit_tag message('sessions.log_in') %> or <a href="<%= home_path -%>" class="action"><%= message('cancel') -%></a> </p> </form> <% if flash[:loginerror] %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/new.html.erb index b5705d7ff98..7153b891a25 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/sessions/new.html.erb @@ -7,22 +7,22 @@ <div class="notice"><%= flash[:notice] %></div> <% end %> - <h3><%= label_tag 'login' %></h3> + <h3><%= label_tag message('login') %></h3> <p> <%= text_field_tag 'login', '', {:maxlength => 40, :size => 30, :disabled => false} %> <% if Property.value('sonar.allowUsersToSignUp')=='true' %> <br/><span class="desc">Not a member? <%= link_to 'Sign up', :controller => 'users', :action => 'new' -%> for an account.</span> <% end %> </p> - <h3><%= label_tag 'password' %></h3> + <h3><%= label_tag message('password') %></h3> <p> <%= password_field_tag 'password', nil, :size => 30 %> </p> <p> - <%= check_box_tag 'remember_me', '1', @remember_me %> <%= label_tag 'remember_me', 'Remember me on this computer' %> + <%= check_box_tag 'remember_me', '1', @remember_me %> <%= label_tag 'remember_me', message('sessions.remember_me') %> </p> <p> - <%= submit_tag 'Log in' %> or <a href="<%= home_path -%>" class="action">Cancel</a> + <%= submit_tag message('sessions.log_in') %> <a href="<%= home_path -%>" class="action"><%= message('cancel') -%></a> </p> </form> <% if flash[:loginerror] %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb index e4bc30eb961..d0d7ad83c44 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_plugins.html.erb @@ -55,7 +55,7 @@ </tbody> </table> <br/> - <%= submit_tag('save parameters') %> + <%= submit_tag('Save parameters') %> </td> <td class="column"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb index 752a50ae471..a641423752c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/timemachine/index.html.erb @@ -78,16 +78,16 @@ <thead> <tr> <th valign="top" nowrap="nowrap" style="text-align: left"> - Show date + <%= message('time_machine.show_date') -%> <div class="yui-skin-sam" style="display: inline;"> - <a href="#" id="calendar_link" class="nolink"><%= image_tag('calendar_view_day.png', :alt => 'Calendar') %></a> + <a href="#" id="calendar_link" class="nolink"><%= image_tag('calendar_view_day.png', :alt => message('calendar')) %></a> <div id="calContainer"> </div> </div><br/> <% selectable_events = @project.events_with_snapshot.select{|event| !(@sids.include?(event.snapshot_id))} unless selectable_events.empty? %> - Show event + <%= message('time_machine.show_event') -%> <select id="select_label" onchange="selectSnapshot(this.options[this.selectedIndex].value, true)"> <option value=""> </option> <% @@ -107,7 +107,7 @@ <b><%= event.fullname %></b> <br/> <% end %> - <a href="#" onClick="unselectSnapshot(<%= snapshot.id -%>, true)" class="action">hide</a> + <a href="#" onClick="unselectSnapshot(<%= snapshot.id -%>, true)" class="action"><%= message('hide').downcase -%></a> </th> <% end %> <th> </th> @@ -150,7 +150,7 @@ </tr> <% end %> <tr> - <td class="title"><br/>Distributions</td> + <td class="title"><br/><%= message('time_machine.distributions') -%></td> <% @snapshots.each_with_index do |snapshot, index| %> <td align="right" valign="bottom"> <% current_color = ChartsController::CHART_COLORS[index % ChartsController::CHART_COLORS.size ] %> @@ -176,7 +176,7 @@ chart_id = "distribution_#{row.metric.key}" %> <div style="float:left;width: 400px;text-align:center;padding-bottom: 25px;"> - <%= chart(chart_url, :id => chart_id, :alt => 'Distribution chart', :width => 360, :height => 150) -%><br/> + <%= chart(chart_url, :id => chart_id, :alt => message('time_machine.distribution_chart'), :width => 360, :height => 150) -%><br/> <b><%= row.metric.short_name -%></b> </div> <% end %> @@ -185,9 +185,9 @@ <tfoot> <tr> <td colspan="<%= @snapshots.size + 2 -%>"> - <input type="submit" value="Compare on chart" /> + <input type="submit" value="<%= message('time_machine.compare_on_chart') -%>" /> <% if is_admin? %> - <a href="#" onClick="collectSelectedMetrics();$('chart_defaults_form').submit();return false;" class="action">Set as default (for all users)</a> + <a href="#" onClick="collectSelectedMetrics();$('chart_defaults_form').submit();return false;" class="action"><%= message('time_machine.set_as_default_for_all_users') -%></a> <% end %> </td> </tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/users/_autocomplete.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/users/_autocomplete.html.erb index 3f43d346192..182a0994d7f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/users/_autocomplete.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/users/_autocomplete.html.erb @@ -4,6 +4,6 @@ @users.each do |user| user_name = user.name %> - <li id="<%= h(user.login) -%>"><strong><%= h(user_name)[0..@char_count-1] -%></strong><%= h(user_name)[@char_count..user_name.size-1] -%> <i><%= "(me)" if current_user_login == user.login -%></i></li> + <li id="<%= h(user.login) -%>"><strong><%= h(user_name)[0..@char_count-1] -%></strong><%= h(user_name)[@char_count..user_name.size-1] -%> <i><%= "(#{message('me').downcase})" if current_user_login == user.login -%></i></li> <% end %> </ul> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb index 866363428b6..f7ea9750355 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb @@ -7,6 +7,7 @@ <tr> <th class="left">Login</th> <th class="left">Name</th> + <th class="left">Email</th> <th class="left nosort">Groups</th> <th class="left nosort" nowrap>Operations</th> </tr> @@ -17,6 +18,7 @@ <tr id="user-<%= u user.login -%>"> <td class="left" valign="top"><%=user.login %></td> <td class="left" valign="top"><%=user.name %></td> + <td class="left" valign="top"><%=user.email %></td> <td class="left" valign="top"> <%= user.groups.sort.map(&:name).join(', ') %> (<%= link_to "select", {:action => 'select_group', :id => user.id}, :id => "select-#{u user.login}" %>) </td> @@ -61,6 +63,9 @@ <td class="left" valign="top">Name:<br/><%= f.text_field :name, :size => 30, :maxLength => 200 %></td> </tr> <tr> + <td class="left" valign="top">Email:<br/><%= f.text_field :email, :size => 30, :maxLength => 100 %></td> + </tr> + <tr> <td class="left" valign="top">Password:<br/><%= f.password_field :password, :size => 30, :maxLength => 50 %></td> </tr> <tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/config/routes.rb b/sonar-server/src/main/webapp/WEB-INF/config/routes.rb index 02d72fb7868..178dd80df2f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/config/routes.rb +++ b/sonar-server/src/main/webapp/WEB-INF/config/routes.rb @@ -12,6 +12,7 @@ ActionController::Routing::Routes.draw do |map| api.resources :user_properties, :only => [:index, :show, :create, :destroy], :requirements => { :id => /.*/ } api.resources :projects, :only => [:index, :destroy], :requirements => { :id => /.*/ } api.resources :favorites, :only => [:index, :show, :create, :destroy], :requirements => { :id => /.*/ } + api.resources :manual_measures, :only => [:index, :create, :destroy], :requirements => { :id => /.*/ } api.resources :reviews, :only => [:index, :show, :create], :member => { :add_comment => :put, :reassign => :put, diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb index bd930663577..80976a2a65b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb @@ -65,12 +65,6 @@ class InitialSchema < ActiveRecord::Migration t.column :description, :text end - create_table :parameters do |t| - t.column :param_key, :string, :null => false, :limit => 100, :null => false - t.column :value, :decimal, :null => false, :precision => 30, :scale => 20 - t.column :value2, :decimal, :null => true, :precision => 30, :scale => 20 - end - create_table :rule_failures do |t| t.column :snapshot_id, :integer, :null => false t.column :rule_id, :integer, :null => false diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb index 269022642c2..2f56659b79b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/048_create_async_measure_snapshots_table.rb @@ -23,11 +23,11 @@ class CreateAsyncMeasureSnapshotsTable < ActiveRecord::Migration create_table :async_measure_snapshots do |t| t.column :project_measure_id, :integer, :null => true t.column :measure_date, :datetime, :null => true - t.column :snapshot_id, :integer, :null => true + t.column :snapshot_id, :integer, :null => true t.column :snapshot_date, :datetime, :null => true - t.column :metric_id, :integer, :null => true - t.column :project_id, :integer, :null => true - end + t.column :metric_id, :integer, :null => true + t.column :project_id, :integer, :null => true + end add_index :async_measure_snapshots, :snapshot_id, :name => 'async_m_s_snapshot_id' add_index :async_measure_snapshots, :project_measure_id, :name => 'async_m_s_measure_id' add_index :async_measure_snapshots, [:project_id, :metric_id], :name => 'async_m_s_project_metric' diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb index a30b36ad7f2..140b7c90213 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb @@ -77,10 +77,9 @@ class CreateDashboards < ActiveRecord::Migration dashboard.widgets.build(:widget_key => 'description', :name => 'Description', :column_index => 1, :row_index => 6, :configured => true) dashboard.widgets.build(:widget_key => 'rules', :name => 'Rules', :column_index => 2, :row_index => 1, :configured => true) dashboard.widgets.build(:widget_key => 'alerts', :name => 'Alerts', :column_index => 2, :row_index => 2, :configured => true) - dashboard.widgets.build(:widget_key => 'custom_measures', :name => 'Custom measures', :column_index => 2, :row_index => 3, :configured => true) - dashboard.widgets.build(:widget_key => 'file_design', :name => 'File design', :column_index => 2, :row_index => 4, :configured => true) - dashboard.widgets.build(:widget_key => 'package_design', :name => 'Package design', :column_index => 2, :row_index => 5, :configured => true) - dashboard.widgets.build(:widget_key => 'ckjm', :name => 'CKJM', :column_index => 2, :row_index => 6, :configured => true) + dashboard.widgets.build(:widget_key => 'file_design', :name => 'File design', :column_index => 2, :row_index => 3, :configured => true) + dashboard.widgets.build(:widget_key => 'package_design', :name => 'Package design', :column_index => 2, :row_index => 4, :configured => true) + dashboard.widgets.build(:widget_key => 'ckjm', :name => 'CKJM', :column_index => 2, :row_index => 5, :configured => true) dashboard.save dashboard diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/async_measure_snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/210_drop_parameters_table.rb index 2f37204dded..f9ac8869054 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/async_measure_snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/210_drop_parameters_table.rb @@ -17,32 +17,18 @@ # License along with Sonar; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # -class AsyncMeasureSnapshot < ActiveRecord::Base - - belongs_to :async_measure, :foreign_key => 'project_measure_id', :class_name => "ProjectMeasure" - belongs_to :snapshot - def self.search(sids, metric_ids=nil) - sql='async_measure_snapshots.snapshot_id IN (:sids)' - hash={:sids => sids} - if metric_ids - sql+=' AND async_measure_snapshots.metric_id IN (:mids)' - hash[:mids]=metric_ids - end - async_measures=AsyncMeasureSnapshot.find(:all, - :include => ['async_measure'], - :conditions => [sql, hash]) +# +# Sonar 2.10 +# +class DropParametersTable < ActiveRecord::Migration - result=[] - async_measures.each do |am| - clone=am.async_measure.clone - clone.snapshot_id=am.snapshot_id - result<<clone + def self.up + begin + drop_table('parameters') + rescue + # ignore, it's a fresh install end - result end - def measure - async_measure - end -end
\ No newline at end of file +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/i18n_controller.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/211_create_manual_measures.rb index c5ec6fd0702..3f1e2ba687e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/i18n_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/211_create_manual_measures.rb @@ -18,38 +18,22 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # -require "json" - -class I18nController < ApplicationController - - def index - render :text => "Use one of the following:<br><ul>" + - "<li>/i18n/unknown_keys?format=text|json</li>" + - "</ul>" - end - - # - # GET /i18n/unknown_keys - # - def unknown_keys - output = "" - properties = i18n_manager.unknown_keys - - properties.keys.sort.each { |key| output += "#{key}=#{properties[key]}\n" } - - output = "# No unknown keys" if output.empty? - - respond_to do |format| - format.json { render :json => JSON(properties) } - format.xml { render :xml => xml_not_supported } - format.text { render :text => output } +# +# Sonar 2.10 +# +class CreateManualMeasures < ActiveRecord::Migration + + def self.up + create_table 'manual_measures' do |t| + t.column 'metric_id', :integer, :null => false + t.column 'resource_id', :integer, :null => true + t.column 'value', :decimal, :null => true, :precision => 30, :scale => 20 + t.column 'text_value', :string, :null => true, :limit => 4000 + t.column 'user_login', :string, :null => true, :limit => 40 + t.column 'description', :string, :null => true, :limit => 4000 + t.timestamps end + alter_to_big_primary_key('manual_measures') end - private - - def i18n_manager - java_facade.getComponentByClassname('core', 'org.sonar.plugins.core.i18n.I18nManager') - end - -end
\ No newline at end of file +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb new file mode 100644 index 00000000000..be05b3d0a39 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb @@ -0,0 +1,55 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class MoveAsyncMeasures < ActiveRecord::Migration + + class ManualMeasure < ActiveRecord::Base + end + + class ProjectMeasure < ActiveRecord::Base + end + + class AsyncMeasureSnapshot < ActiveRecord::Base + belongs_to :measure, :foreign_key => 'project_measure_id', :class_name => "ProjectMeasure" + end + + def self.up + deprecated_measures=AsyncMeasureSnapshot.find(:all, :include => 'measure') + + say_with_time "Moving #{deprecated_measures.size} measures" do + deprecated_measures.each do |dm| + ManualMeasure.create( + :resource_id => dm.project_id, + :metric_id => dm.measure.metric_id, + :value => dm.measure.value, + :text_value => dm.measure.text_value, + :created_at => dm.measure_date, + :updated_at => dm.measure_date, + :url => dm.measure.url, + :description => dm.measure.description + ) + end + end + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/213_drop_async_measures_table.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/213_drop_async_measures_table.rb new file mode 100644 index 00000000000..7346d954978 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/213_drop_async_measures_table.rb @@ -0,0 +1,33 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class DropAsyncMeasuresTable < ActiveRecord::Migration + + def self.up + remove_index('async_measure_snapshots', :name => 'async_m_s_snapshot_id') + remove_index('async_measure_snapshots', :name => 'async_m_s_measure_id') + remove_index('async_measure_snapshots', :name => 'async_m_s_project_metric') + drop_table('async_measure_snapshots') + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/214_add_index_on_manual_measures.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/214_add_index_on_manual_measures.rb new file mode 100644 index 00000000000..3c9babea7b2 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/214_add_index_on_manual_measures.rb @@ -0,0 +1,30 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class AddIndexOnManualMeasures < ActiveRecord::Migration + + def self.up + add_index('manual_measures', 'resource_id', :name => 'manual_measures_resource_id') + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/215_create_notifications.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/215_create_notifications.rb new file mode 100644 index 00000000000..ed8196464e3 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/215_create_notifications.rb @@ -0,0 +1,33 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class CreateNotifications < ActiveRecord::Migration + + def self.up + create_table 'notifications' do |t| + t.column 'created_at', :datetime, :null => true + t.column 'data', :binary, :null => true + end + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/216_set_nullable_rule_name.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/216_set_nullable_rule_name.rb new file mode 100644 index 00000000000..90d558ff388 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/216_set_nullable_rule_name.rb @@ -0,0 +1,37 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.10 +# +class SetNullableRuleName < ActiveRecord::Migration + + def self.up + add_column(:rules, :temp_name, :string, :limit => 200, :null => true) + Rule.reset_column_information + + Rule.update_all('temp_name=name') + + remove_column(:rules, :name) + rename_column(:rules, :temp_name, :name) + Rule.reset_column_information + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/lib/resourceable.rb b/sonar-server/src/main/webapp/WEB-INF/lib/resourceable.rb index a880840fde5..341d249bbcc 100644 --- a/sonar-server/src/main/webapp/WEB-INF/lib/resourceable.rb +++ b/sonar-server/src/main/webapp/WEB-INF/lib/resourceable.rb @@ -37,16 +37,16 @@ module Resourceable QUALIFIER_LIB='LIB' QUALIFIERS=[QUALIFIER_VIEW,QUALIFIER_SUBVIEW,QUALIFIER_PROJECT,QUALIFIER_MODULE,QUALIFIER_DIRECTORY,QUALIFIER_PACKAGE,QUALIFIER_FILE,QUALIFIER_CLASS,QUALIFIER_UNIT_TEST_CLASS,QUALIFIER_LIB] QUALIFIER_NAMES={ - QUALIFIER_VIEW => 'View', - QUALIFIER_SUBVIEW => 'Sub-view', - QUALIFIER_PROJECT => 'Project', - QUALIFIER_MODULE => 'Sub-project', - QUALIFIER_DIRECTORY => 'Directory', - QUALIFIER_PACKAGE => 'Package', - QUALIFIER_FILE => 'File', - QUALIFIER_CLASS => 'Class', - QUALIFIER_UNIT_TEST_CLASS => 'Unit test', - QUALIFIER_LIB => 'Library' + QUALIFIER_VIEW => 'view', + QUALIFIER_SUBVIEW => 'sub_view', + QUALIFIER_PROJECT => 'project', + QUALIFIER_MODULE => 'sub_project', + QUALIFIER_DIRECTORY => 'directory', + QUALIFIER_PACKAGE => 'package', + QUALIFIER_FILE => 'file', + QUALIFIER_CLASS => 'class', + QUALIFIER_UNIT_TEST_CLASS => 'unit_test', + QUALIFIER_LIB => 'library' } def set? scope==SCOPE_SET diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index 32347f77aff..39f88114558 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -639,11 +639,11 @@ table.form td { padding: 2px 5px; vertical-align: top; } -table.form td.first { - min-width: 120px; +table.form td.keyCell { + width: 140px; text-align: right; font-weight: bold; - vertical-align: middle; + vertical-align: top; } table.form td img { vertical-align: bottom; @@ -670,6 +670,7 @@ div.operations { } ul.operations { float: right; + height: 20px; list-style-type: none; margin: 0; background-color: #ECECEC; @@ -1329,7 +1330,7 @@ option.sev_BLOCKER { /* ------------------- HELP ------------------- */ .help { border: 1px solid #DDD; - background-color: #ECECEC; + background-color: #F4F4F4; color: #444; padding: 5px; } @@ -1872,6 +1873,12 @@ div.break30 { .width100 { width: 100%; } +textarea.width100 { + width: 100%; + -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ + -moz-box-sizing: border-box; /* Firefox, other Gecko */ + box-sizing: border-box; /* Opera/IE 8+ */ +} ul.horizontal { list-style-type: none; } diff --git a/sonar-server/src/test/java/org/sonar/server/database/JndiDatabaseConnectorTest.java b/sonar-server/src/test/java/org/sonar/server/database/JndiDatabaseConnectorTest.java index 27e55256fc7..37e28fb7b5d 100644 --- a/sonar-server/src/test/java/org/sonar/server/database/JndiDatabaseConnectorTest.java +++ b/sonar-server/src/test/java/org/sonar/server/database/JndiDatabaseConnectorTest.java @@ -27,18 +27,15 @@ import org.junit.Test; import org.sonar.api.database.DatabaseProperties; import org.sonar.jpa.entity.SchemaMigration; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.util.Hashtable; import javax.naming.Context; import javax.naming.spi.InitialContextFactory; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.util.Hashtable; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.*; public class JndiDatabaseConnectorTest { diff --git a/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java b/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java new file mode 100644 index 00000000000..c75a702b3cf --- /dev/null +++ b/sonar-server/src/test/java/org/sonar/server/notifications/NotificationServiceTest.java @@ -0,0 +1,223 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.server.notifications; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import org.apache.commons.configuration.BaseConfiguration; +import org.apache.commons.configuration.Configuration; +import org.junit.Before; +import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; +import org.sonar.api.notifications.NotificationDispatcher; +import org.sonar.core.notifications.DefaultNotificationManager; +import org.sonar.jpa.entity.NotificationQueueElement; + +public class NotificationServiceTest { + + private static String USER_SIMON = "simon"; + private static String USER_EVGENY = "evgeny"; + + private NotificationChannel emailChannel; + private NotificationChannel gtalkChannel; + + private NotificationDispatcher commentOnReviewAssignedToMe; + private String assignee; + private NotificationDispatcher commentOnReviewCreatedByMe; + private String creator; + + private DefaultNotificationManager manager; + private NotificationService service; + + @Before + public void setUp() { + emailChannel = mock(NotificationChannel.class); + when(emailChannel.getKey()).thenReturn("email"); + + gtalkChannel = mock(NotificationChannel.class); + when(gtalkChannel.getKey()).thenReturn("gtalk"); + + commentOnReviewAssignedToMe = mock(NotificationDispatcher.class); + when(commentOnReviewAssignedToMe.getKey()).thenReturn("comment on review assigned to me"); + doAnswer(new Answer<Object>() { + public Object answer(InvocationOnMock invocation) throws Throwable { + ((NotificationDispatcher.Context) invocation.getArguments()[1]).addUser(assignee); + return null; + } + }).when(commentOnReviewAssignedToMe).dispatch(any(Notification.class), any(NotificationDispatcher.Context.class)); + + commentOnReviewCreatedByMe = mock(NotificationDispatcher.class); + when(commentOnReviewCreatedByMe.getKey()).thenReturn("comment on review created by me"); + doAnswer(new Answer<Object>() { + public Object answer(InvocationOnMock invocation) throws Throwable { + ((NotificationDispatcher.Context) invocation.getArguments()[1]).addUser(creator); + return null; + } + }).when(commentOnReviewCreatedByMe).dispatch(any(Notification.class), any(NotificationDispatcher.Context.class)); + + NotificationDispatcher[] dispatchers = new NotificationDispatcher[] { commentOnReviewAssignedToMe, commentOnReviewCreatedByMe }; + NotificationChannel[] channels = new NotificationChannel[] { emailChannel, gtalkChannel }; + manager = mock(DefaultNotificationManager.class); + Configuration configuration = new BaseConfiguration(); + configuration.setProperty("sonar.notifications.delay", "1"); // delay 1 second + service = spy(new NotificationService(configuration, manager, dispatchers, channels)); + doReturn(false).when(manager).isEnabled(any(String.class), any(String.class), any(String.class)); + } + + @Test + public void shouldPeriodicallyProcessQueue() throws Exception { + NotificationQueueElement queueElement = mock(NotificationQueueElement.class); + Notification notification = mock(Notification.class); + when(queueElement.getNotification()).thenReturn(notification); + when(manager.getFromQueue()).thenReturn(queueElement).thenReturn(null).thenReturn(queueElement).thenReturn(null).thenReturn(queueElement).thenReturn(null); + doNothing().when(service).deliver(any(Notification.class)); + + service.start(); + Thread.sleep(1500); // sleep 1.5 second to process queue + service.stop(); + + verify(service, times(3)).deliver(notification); // 3 times - 1 on start, 1 after delay, 1 on stop + } + + /** + * Given: + * Simon wants to receive notifications by email on comments for reviews assigned to him or created by him. + * + * When: + * Freddy adds comment to review created by Simon and assigned to Simon. + * + * Then: + * Only one notification should be delivered to Simon by Email. + */ + @Test + public void scenario1() { + doReturn(true).when(manager).isEnabled(USER_SIMON, "email", "comment on review assigned to me"); + doReturn(true).when(manager).isEnabled(USER_SIMON, "email", "comment on review created by me"); + + Notification notification = mock(Notification.class); + creator = USER_SIMON; + assignee = USER_SIMON; + + service.deliver(notification); + + verify(emailChannel, atLeast(1)).getKey(); + verify(gtalkChannel, atLeast(1)).getKey(); + verify(emailChannel).deliver(notification, USER_SIMON); + verifyNoMoreInteractions(emailChannel); + verifyNoMoreInteractions(gtalkChannel); + } + + /** + * Given: + * Evgeny wants to receive notification by GTalk on comments for reviews created by him. + * Simon wants to receive notification by Email on comments for reviews assigned to him. + * + * When: + * Freddy adds comment to review created by Evgeny and assigned to Simon. + * + * Then: + * Two notifications should be delivered - one to Simon by Email and another to Evgeny by GTalk. + */ + @Test + public void scenario2() { + doReturn(true).when(manager).isEnabled(USER_EVGENY, "gtalk", "comment on review created by me"); + doReturn(true).when(manager).isEnabled(USER_SIMON, "email", "comment on review assigned to me"); + + Notification notification = mock(Notification.class); + creator = USER_EVGENY; + assignee = USER_SIMON; + + service.deliver(notification); + + verify(emailChannel, atLeast(1)).getKey(); + verify(gtalkChannel, atLeast(1)).getKey(); + verify(emailChannel).deliver(notification, USER_SIMON); + verify(gtalkChannel).deliver(notification, USER_EVGENY); + verifyNoMoreInteractions(emailChannel); + verifyNoMoreInteractions(gtalkChannel); + } + + /** + * Given: + * Simon wants to receive notifications by Email and GTLak on comments for reviews assigned to him. + * + * When: + * Freddy adds comment to review created by Evgeny and assigned to Simon. + * + * Then: + * Two notifications should be delivered to Simon - one by Email and another by GTalk. + */ + @Test + public void scenario3() { + doReturn(true).when(manager).isEnabled(USER_SIMON, "email", "comment on review assigned to me"); + doReturn(true).when(manager).isEnabled(USER_SIMON, "gtalk", "comment on review assigned to me"); + + Notification notification = mock(Notification.class); + creator = USER_EVGENY; + assignee = USER_SIMON; + + service.deliver(notification); + + verify(emailChannel, atLeast(1)).getKey(); + verify(gtalkChannel, atLeast(1)).getKey(); + verify(emailChannel).deliver(notification, USER_SIMON); + verify(gtalkChannel).deliver(notification, USER_SIMON); + verifyNoMoreInteractions(emailChannel); + verifyNoMoreInteractions(gtalkChannel); + } + + /** + * Given: + * Nobody wants to receive notifications. + * + * When: + * Freddy adds comment to review created by Evgeny and assigned to Simon. + * + * Then: + * No notifications. + */ + @Test + public void scenario4() { + Notification notification = mock(Notification.class); + creator = USER_EVGENY; + assignee = USER_SIMON; + + service.deliver(notification); + + verify(emailChannel, atLeast(1)).getKey(); + verify(gtalkChannel, atLeast(1)).getKey(); + verifyNoMoreInteractions(emailChannel); + verifyNoMoreInteractions(gtalkChannel); + } + +} diff --git a/sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java b/sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java new file mode 100644 index 00000000000..3cd20d65b5c --- /dev/null +++ b/sonar-server/src/test/java/org/sonar/server/notifications/reviews/ReviewsNotificationManagerTest.java @@ -0,0 +1,81 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.server.notifications.reviews; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; + +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationManager; + +import com.google.common.collect.Maps; + +public class ReviewsNotificationManagerTest { + + private Notification notification; + private ReviewsNotificationManager manager; + + @Before + public void setUp() { + NotificationManager delegate = mock(NotificationManager.class); + doAnswer(new Answer() { + public Object answer(InvocationOnMock invocation) throws Throwable { + notification = (Notification) invocation.getArguments()[0]; + return null; + } + }).when(delegate).scheduleForSending(any(Notification.class)); + manager = new ReviewsNotificationManager(delegate); + } + + @Test + public void shouldScheduleNotification() { + Map<String, String> oldValues = Maps.newHashMap(); + Map<String, String> newValues = Maps.newHashMap(); + newValues.put("project", "Sonar"); + newValues.put("resource", "org.sonar.server.ui.DefaultPages"); + newValues.put("title", "Utility classes should not have a public or default constructor."); + newValues.put("creator", "olivier"); + newValues.put("assignee", "godin"); + oldValues.put("assignee", "simon"); + manager.notifyChanged(1L, "freddy", oldValues, newValues); + assertThat(notification, notNullValue()); + assertThat(notification.getType(), is("review-changed")); + assertThat(notification.getFieldValue("reviewId"), is("1")); + assertThat(notification.getFieldValue("author"), is("freddy")); + assertThat(notification.getFieldValue("project"), is("Sonar")); + assertThat(notification.getFieldValue("resource"), is("org.sonar.server.ui.DefaultPages")); + assertThat(notification.getFieldValue("title"), is("Utility classes should not have a public or default constructor.")); + assertThat(notification.getFieldValue("creator"), is("olivier")); + assertThat(notification.getFieldValue("assignee"), is("godin")); + assertThat(notification.getFieldValue("old.assignee"), is("simon")); + assertThat(notification.getFieldValue("new.assignee"), is("godin")); + } + +} diff --git a/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java b/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java index fe150e2b754..c03934a3940 100644 --- a/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java +++ b/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java @@ -22,6 +22,7 @@ package org.sonar.server.ui; import org.hamcrest.core.Is; import org.junit.Test; import org.sonar.api.i18n.I18n; +import org.sonar.core.i18n.RuleI18nManager; import java.util.Locale; @@ -39,7 +40,7 @@ public class JRubyI18nTest { @Test public void shouldCacheLocales() { - JRubyI18n i18n = new JRubyI18n(mock(I18n.class)); + JRubyI18n i18n = new JRubyI18n(mock(I18n.class), mock(RuleI18nManager.class)); assertThat(i18n.getLocalesByRubyKey().size(), Is.is(0)); i18n.getLocale("fr"); |