diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-06-01 00:01:05 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-06-01 19:31:28 +0400 |
commit | 94c39df6941f641936159e3d3bed0d2bd6120c07 (patch) | |
tree | 83252f316744ae3ecdee60b008141b47be680c00 | |
parent | b41cf6f330551a3ffc247249fdfda45a095fb46c (diff) | |
download | sonarqube-94c39df6941f641936159e3d3bed0d2bd6120c07.tar.gz sonarqube-94c39df6941f641936159e3d3bed0d2bd6120c07.zip |
SONAR-1922 Improve UI for profile changelog
* Removed useless version column from Quality Profiles page.
* To improve readability - version of profile displayed in a dedicated
column on Changelog page, otherwise it can be difficult to determine
version associated to a row.
* Allowed to select both versions to compare.
* CSS attribute "word-wrap" was set to "break-word" to decrease width of
table, when parameter value too huge. Tested in Chromimum 12.0.742.68
and in Firefox 3.6.17.
* Version of profile was added to widget.
* Save and show username instead of login.
17 files changed, 118 insertions, 137 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb index a7d1b64bdc2..1891e837e47 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/description.html.erb @@ -21,7 +21,7 @@ %> <tr> <td>Profile:</td> - <td id="resource_profile"><%= link_to profile_measure.data, {:controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i}, :id => 'profile_link' -%></td> + <td id="resource_profile"><%= link_to profile_measure.data, {:controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i}, :id => 'profile_link' -%> (version <%= format_measure('profile_version', :default => '1') -%>)</td> </tr> <% end %> <% if Project::SCOPE_SET==@project.scope %> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java index 20b0ee861c0..13f8818d0bc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java @@ -19,8 +19,6 @@ */ package org.sonar.api.batch; -import org.apache.commons.lang.builder.EqualsBuilder; - import com.google.common.collect.Lists; import org.apache.commons.lang.builder.ToStringBuilder; import org.sonar.api.measures.Metric; @@ -233,10 +231,4 @@ public class TimeMachineQuery { .append("to", to) .toString(); } - - @Override - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleChange.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleChange.java index a3b95213220..e9373e73bc8 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleChange.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRuleChange.java @@ -19,37 +19,30 @@ */ package org.sonar.api.rules; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.sonar.api.database.BaseIdentifiable; import org.sonar.api.profiles.RulesProfile; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import javax.persistence.*; + /** * A class to map a RuleChange to the hibernate model - * + * * @since 2.9 */ @Entity @Table(name = "active_rule_changes") public class ActiveRuleChange extends BaseIdentifiable { - @Column(name = "user_login", updatable = false, nullable = false) - private String modifierLogin; + @Column(name = "user_name", updatable = false, nullable = false) + private String userName; @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "profile_id", updatable = false, nullable = false) @@ -80,12 +73,12 @@ public class ActiveRuleChange extends BaseIdentifiable { @Column(name = "new_severity", updatable = false, nullable = true) @Enumerated(EnumType.ORDINAL) private RulePriority newSeverity; - + @OneToMany(mappedBy = "activeRuleChange", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE }) private List<ActiveRuleParamChange> activeRuleParamChanges = new ArrayList<ActiveRuleParamChange>(); - public ActiveRuleChange(String modifierLogin, RulesProfile profile, Rule rule) { - this.modifierLogin = modifierLogin; + public ActiveRuleChange(String userName, RulesProfile profile, Rule rule) { + this.userName = userName; this.rulesProfile = profile; this.profileVersion = profile.getVersion(); this.rule = rule; @@ -150,8 +143,8 @@ public class ActiveRuleChange extends BaseIdentifiable { return activeRuleParamChanges; } - public String getModifierLogin() { - return modifierLogin; + public String getUserName() { + return userName; } public ActiveRuleChange setParameterChange(String key, String oldValue, String newValue) { @@ -176,7 +169,7 @@ public class ActiveRuleChange extends BaseIdentifiable { ActiveRuleChange rhs = (ActiveRuleChange) obj; return new EqualsBuilder() .appendSuper(super.equals(obj)) - .append(modifierLogin, rhs.modifierLogin) + .append(userName, rhs.userName) .append(rulesProfile, rhs.rulesProfile) .append(rule, rhs.rule) .append(date, rhs.date) @@ -188,7 +181,7 @@ public class ActiveRuleChange extends BaseIdentifiable { @Override public int hashCode() { return new HashCodeBuilder(41, 33) - .append(modifierLogin) + .append(userName) .append(rulesProfile) .append(rule) .append(date) @@ -203,7 +196,7 @@ public class ActiveRuleChange extends BaseIdentifiable { .append("id", getId()) .append("profile", rulesProfile) .append("rule", rule) - .append("modifier", modifierLogin) + .append("modifier", userName) .append("changed at", date) .append("enabled", enabled) .append("new severity", newSeverity) diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java index 4c96afe019e..63d1d996cc9 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java @@ -19,6 +19,7 @@ */ package org.sonar.server.configuration; +import org.apache.commons.lang.ObjectUtils; import org.codehaus.plexus.util.StringUtils; import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.ResourceModel; @@ -94,7 +95,7 @@ public class ProfilesManager extends BaseDao { // Managing inheritance of profiles - public ValidationMessages changeParentProfile(Integer profileId, String parentName, String userLogin) { + public ValidationMessages changeParentProfile(Integer profileId, String parentName, String userName) { ValidationMessages messages = ValidationMessages.create(); RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId); if (profile != null && !profile.getProvided()) { @@ -107,13 +108,13 @@ public class ProfilesManager extends BaseDao { // Deactivate all inherited rules if (oldParent != null) { for (ActiveRule activeRule : oldParent.getActiveRules()) { - deactivate(profile, activeRule.getRule(), userLogin); + deactivate(profile, activeRule.getRule(), userName); } } // Activate all inherited rules if (newParent != null) { for (ActiveRule activeRule : newParent.getActiveRules()) { - activateOrChange(profile, activeRule, userLogin); + activateOrChange(profile, activeRule, userName); } } profile.setParentName(newParent == null ? null : newParent.getName()); @@ -126,51 +127,51 @@ public class ProfilesManager extends BaseDao { /** * Rule was activated */ - public void activated(int profileId, int activeRuleId, String userLogin) { + public void activated(int profileId, int activeRuleId, String userName) { ActiveRule activeRule = getSession().getEntity(ActiveRule.class, activeRuleId); RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId); - ruleEnabled(profile, activeRule, userLogin); + ruleEnabled(profile, activeRule, userName); // Notify child profiles - activatedOrChanged(profileId, activeRuleId, userLogin); + activatedOrChanged(profileId, activeRuleId, userName); } /** * Rule param was changed */ - public void ruleParamChanged(int profileId, int activeRuleId, String paramKey, String oldValue, String newValue, String userLogin) { + public void ruleParamChanged(int profileId, int activeRuleId, String paramKey, String oldValue, String newValue, String userName) { ActiveRule activeRule = getSession().getEntity(ActiveRule.class, activeRuleId); RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId); - ruleParamChanged(profile, activeRule.getRule(), paramKey, oldValue, newValue, userLogin); + ruleParamChanged(profile, activeRule.getRule(), paramKey, oldValue, newValue, userName); // Notify child profiles - activatedOrChanged(profileId, activeRuleId, userLogin); + activatedOrChanged(profileId, activeRuleId, userName); } /** * Rule severity was changed */ - public void ruleSeverityChanged(int profileId, int activeRuleId, RulePriority oldSeverity, RulePriority newSeverity, String userLogin) { + public void ruleSeverityChanged(int profileId, int activeRuleId, RulePriority oldSeverity, RulePriority newSeverity, String userName) { ActiveRule activeRule = getSession().getEntity(ActiveRule.class, activeRuleId); RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId); - ruleSeverityChanged(profile, activeRule.getRule(), oldSeverity, newSeverity, userLogin); + ruleSeverityChanged(profile, activeRule.getRule(), oldSeverity, newSeverity, userName); // Notify child profiles - activatedOrChanged(profileId, activeRuleId, userLogin); + activatedOrChanged(profileId, activeRuleId, userName); } /** * Rule was activated/changed in parent profile. */ - private void activatedOrChanged(int parentProfileId, int activeRuleId, String userLogin) { + private void activatedOrChanged(int parentProfileId, int activeRuleId, String userName) { ActiveRule parentActiveRule = getSession().getEntity(ActiveRule.class, activeRuleId); if (parentActiveRule.isInherited()) { parentActiveRule.setInheritance(ActiveRule.OVERRIDES); getSession().saveWithoutFlush(parentActiveRule); } for (RulesProfile child : getChildren(parentProfileId)) { - activateOrChange(child, parentActiveRule, userLogin); + activateOrChange(child, parentActiveRule, userName); } getSession().commit(); } @@ -178,12 +179,12 @@ public class ProfilesManager extends BaseDao { /** * Rule was deactivated in parent profile. */ - public void deactivated(int parentProfileId, int deactivatedRuleId, String userLogin) { + public void deactivated(int parentProfileId, int deactivatedRuleId, String userName) { ActiveRule parentActiveRule = getSession().getEntity(ActiveRule.class, deactivatedRuleId); RulesProfile profile = getSession().getEntity(RulesProfile.class, parentProfileId); - ruleDisabled(profile, parentActiveRule, userLogin); + ruleDisabled(profile, parentActiveRule, userName); for (RulesProfile child : getChildren(parentProfileId)) { - deactivate(child, parentActiveRule.getRule(), userLogin); + deactivate(child, parentActiveRule.getRule(), userName); } getSession().commit(); } @@ -201,7 +202,7 @@ public class ProfilesManager extends BaseDao { return false; } - public void revert(int profileId, int activeRuleId, String userLogin) { + public void revert(int profileId, int activeRuleId, String userName) { RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId); ActiveRule oldActiveRule = getSession().getEntity(ActiveRule.class, activeRuleId); if (oldActiveRule != null && oldActiveRule.doesOverride()) { @@ -214,10 +215,10 @@ public class ProfilesManager extends BaseDao { getSession().saveWithoutFlush(newActiveRule); // Compute change - ruleChanged(profile, oldActiveRule, newActiveRule, userLogin); + ruleChanged(profile, oldActiveRule, newActiveRule, userName); for (RulesProfile child : getChildren(profile)) { - activateOrChange(child, newActiveRule, userLogin); + activateOrChange(child, newActiveRule, userName); } getSession().commit(); @@ -235,9 +236,9 @@ public class ProfilesManager extends BaseDao { /** * Deal with creation of ActiveRuleChange item when a rule param is changed on a profile */ - private void ruleParamChanged(RulesProfile profile, Rule rule, String paramKey, String oldValue, String newValue, String userLogin) { + private void ruleParamChanged(RulesProfile profile, Rule rule, String paramKey, String oldValue, String newValue, String userName) { incrementProfileVersionIfNeeded(profile); - ActiveRuleChange rc = new ActiveRuleChange(userLogin, profile, rule); + ActiveRuleChange rc = new ActiveRuleChange(userName, profile, rule); if (!StringUtils.equals(oldValue, newValue)) { rc.setParameterChange(paramKey, oldValue, newValue); getSession().saveWithoutFlush(rc); @@ -247,10 +248,10 @@ public class ProfilesManager extends BaseDao { /** * Deal with creation of ActiveRuleChange item when a rule severity is changed on a profile */ - private void ruleSeverityChanged(RulesProfile profile, Rule rule, RulePriority oldSeverity, RulePriority newSeverity, String userLogin) { + private void ruleSeverityChanged(RulesProfile profile, Rule rule, RulePriority oldSeverity, RulePriority newSeverity, String userName) { incrementProfileVersionIfNeeded(profile); - ActiveRuleChange rc = new ActiveRuleChange(userLogin, profile, rule); - if (oldSeverity != newSeverity) { + ActiveRuleChange rc = new ActiveRuleChange(userName, profile, rule); + if (!ObjectUtils.equals(oldSeverity, newSeverity)) { rc.setOldSeverity(oldSeverity); rc.setNewSeverity(newSeverity); getSession().saveWithoutFlush(rc); @@ -260,9 +261,9 @@ public class ProfilesManager extends BaseDao { /** * Deal with creation of ActiveRuleChange item when a rule is changed (severity and/or param(s)) on a profile */ - private void ruleChanged(RulesProfile profile, ActiveRule oldActiveRule, ActiveRule newActiveRule, String userLogin) { + private void ruleChanged(RulesProfile profile, ActiveRule oldActiveRule, ActiveRule newActiveRule, String userName) { incrementProfileVersionIfNeeded(profile); - ActiveRuleChange rc = new ActiveRuleChange(userLogin, profile, newActiveRule.getRule()); + ActiveRuleChange rc = new ActiveRuleChange(userName, profile, newActiveRule.getRule()); if (oldActiveRule.getSeverity() != newActiveRule.getSeverity()) { rc.setOldSeverity(oldActiveRule.getSeverity()); @@ -284,9 +285,9 @@ public class ProfilesManager extends BaseDao { /** * Deal with creation of ActiveRuleChange item when a rule is enabled on a profile */ - private void ruleEnabled(RulesProfile profile, ActiveRule newActiveRule, String userLogin) { + private void ruleEnabled(RulesProfile profile, ActiveRule newActiveRule, String userName) { incrementProfileVersionIfNeeded(profile); - ActiveRuleChange rc = new ActiveRuleChange(userLogin, profile, newActiveRule.getRule()); + ActiveRuleChange rc = new ActiveRuleChange(userName, profile, newActiveRule.getRule()); rc.setEnabled(true); rc.setNewSeverity(newActiveRule.getSeverity()); if (newActiveRule.getRule().getParams() != null) { @@ -303,9 +304,9 @@ public class ProfilesManager extends BaseDao { /** * Deal with creation of ActiveRuleChange item when a rule is disabled on a profile */ - private void ruleDisabled(RulesProfile profile, ActiveRule disabledRule, String userLogin) { + private void ruleDisabled(RulesProfile profile, ActiveRule disabledRule, String userName) { incrementProfileVersionIfNeeded(profile); - ActiveRuleChange rc = new ActiveRuleChange(userLogin, profile, disabledRule.getRule()); + ActiveRuleChange rc = new ActiveRuleChange(userName, profile, disabledRule.getRule()); rc.setEnabled(false); rc.setOldSeverity(disabledRule.getSeverity()); if (disabledRule.getRule().getParams() != null) { @@ -319,7 +320,7 @@ public class ProfilesManager extends BaseDao { getSession().saveWithoutFlush(rc); } - private void activateOrChange(RulesProfile profile, ActiveRule parentActiveRule, String userLogin) { + private void activateOrChange(RulesProfile profile, ActiveRule parentActiveRule, String userName) { ActiveRule oldActiveRule = profile.getActiveRule(parentActiveRule.getRule()); if (oldActiveRule != null) { if (oldActiveRule.isInherited()) { @@ -337,21 +338,21 @@ public class ProfilesManager extends BaseDao { getSession().saveWithoutFlush(newActiveRule); if (oldActiveRule != null) { - ruleChanged(profile, oldActiveRule, newActiveRule, userLogin); + ruleChanged(profile, oldActiveRule, newActiveRule, userName); } else { - ruleEnabled(profile, newActiveRule, userLogin); + ruleEnabled(profile, newActiveRule, userName); } for (RulesProfile child : getChildren(profile)) { - activateOrChange(child, newActiveRule, userLogin); + activateOrChange(child, newActiveRule, userName); } } - private void deactivate(RulesProfile profile, Rule rule, String userLogin) { + private void deactivate(RulesProfile profile, Rule rule, String userName) { ActiveRule activeRule = profile.getActiveRule(rule); if (activeRule != null) { if (activeRule.isInherited()) { - ruleDisabled(profile, activeRule, userLogin); + ruleDisabled(profile, activeRule, userName); removeActiveRule(profile, activeRule); } else { activeRule.setInheritance(null); @@ -360,7 +361,7 @@ public class ProfilesManager extends BaseDao { } for (RulesProfile child : getChildren(profile)) { - deactivate(child, rule, userLogin); + deactivate(child, rule, userName); } } } 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 8b8cf857bbb..3d0a621fec8 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 @@ -229,29 +229,29 @@ public final class JRubyFacade { getProfilesManager().deleteProfile((int) profileId); } - public ValidationMessages changeParentProfile(int profileId, String parentName, String userLogin) { - return getProfilesManager().changeParentProfile(profileId, parentName, userLogin); + public ValidationMessages changeParentProfile(int profileId, String parentName, String userName) { + return getProfilesManager().changeParentProfile(profileId, parentName, userName); } - public void ruleActivated(int parentProfileId, int activeRuleId, String userLogin) { - getProfilesManager().activated(parentProfileId, activeRuleId, userLogin); + public void ruleActivated(int parentProfileId, int activeRuleId, String userName) { + getProfilesManager().activated(parentProfileId, activeRuleId, userName); } - public void ruleParamChanged(int parentProfileId, int activeRuleId, String paramKey, String oldValue, String newValue, String userLogin) { - getProfilesManager().ruleParamChanged(parentProfileId, activeRuleId, paramKey, oldValue, newValue, userLogin); + public void ruleParamChanged(int parentProfileId, int activeRuleId, String paramKey, String oldValue, String newValue, String userName) { + getProfilesManager().ruleParamChanged(parentProfileId, activeRuleId, paramKey, oldValue, newValue, userName); } - public void ruleSeverityChanged(int parentProfileId, int activeRuleId, int oldSeverityId, int newSeverityId, String userLogin) { + public void ruleSeverityChanged(int parentProfileId, int activeRuleId, int oldSeverityId, int newSeverityId, String userName) { getProfilesManager().ruleSeverityChanged(parentProfileId, activeRuleId, RulePriority.values()[oldSeverityId], - RulePriority.values()[newSeverityId], userLogin); + RulePriority.values()[newSeverityId], userName); } - public void ruleDeactivated(int parentProfileId, int deactivatedRuleId, String userLogin) { - getProfilesManager().deactivated(parentProfileId, deactivatedRuleId, userLogin); + public void ruleDeactivated(int parentProfileId, int deactivatedRuleId, String userName) { + getProfilesManager().deactivated(parentProfileId, deactivatedRuleId, userName); } - public void revertRule(int profileId, int activeRuleId, String userLogin) { - getProfilesManager().revert(profileId, activeRuleId, userLogin); + public void revertRule(int profileId, int activeRuleId, String userName) { + getProfilesManager().revert(profileId, activeRuleId, userName); } public List<Footer> getWebFooters() { 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 555a8adc02f..3d9cbeaf1ac 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 @@ -205,20 +205,27 @@ class ProfilesController < ApplicationController def changelog @profile = Profile.find(params[:id]) - @versions = ActiveRuleChange.find(:all, :select => 'profile_version, MAX(change_date) AS change_date', :conditions => ['profile_id=?', @profile.id], :group => 'profile_version') - @versions.sort! { |a,b| b.profile_version <=> a.profile_version } + versions = ActiveRuleChange.find(:all, :select => 'profile_version, MAX(change_date) AS change_date', :conditions => ['profile_id=?', @profile.id], :group => 'profile_version') + versions.sort! { |a,b| b.profile_version <=> a.profile_version } - if @versions.empty? - @last_version = 1 - else - @last_version = @versions[0].profile_version - @past_versions = @versions[1, @versions.length] + if !versions.empty? + last_version = versions[0].profile_version if params[:since].blank? - @since_version = @last_version - 1 + @since_version = last_version - 1 else @since_version = params[:since].to_i end - @changes = ActiveRuleChange.find(:all, :conditions => ['profile_id=? and profile_version>?', @profile.id, @since_version], :order => 'id desc') + if params[:to].blank? + @to_version = last_version + else + @to_version = params[:to].to_i + end + if @since_version > @to_version + @since_version, @to_version = @to_version, @since_version + 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| ["version " + u.profile_version.to_s + " (" + u.change_date.strftime("%Y/%m/%d %H:%M:%S") + ")", u.profile_version]} | [["no version", 0]]; end end @@ -232,9 +239,9 @@ class ProfilesController < ApplicationController id = params[:id].to_i parent_name = params[:parent_name] if parent_name.blank? - messages = java_facade.changeParentProfile(id, nil, current_user.login) + messages = java_facade.changeParentProfile(id, nil, current_user.name) else - messages = java_facade.changeParentProfile(id, parent_name, current_user.login) + messages = java_facade.changeParentProfile(id, parent_name, current_user.name) end flash_validation_messages(messages) redirect_to :action => 'inheritance', :id => id 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 b5de168305e..4f108f13706 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 @@ -84,7 +84,7 @@ class RulesConfigurationController < ApplicationController def revert_rule id = params[:id].to_i rule_id = params[:active_rule_id].to_i - java_facade.revertRule(id, rule_id, current_user.login) + java_facade.revertRule(id, rule_id, current_user.name) redirect_to request.query_parameters.merge({:action => 'index', :id => params[:id], :commit => nil}) end @@ -106,7 +106,7 @@ class RulesConfigurationController < ApplicationController if priority.blank? # deactivate the rule if active_rule - java_facade.ruleDeactivated(profile.id, active_rule.id, current_user.login) + java_facade.ruleDeactivated(profile.id, active_rule.id, current_user.name) active_rule.destroy active_rule=nil end @@ -124,9 +124,9 @@ class RulesConfigurationController < ApplicationController active_rule.failure_level=Sonar::RulePriority.id(priority) active_rule.save! if activated - java_facade.ruleActivated(profile.id, active_rule.id, current_user.login) + java_facade.ruleActivated(profile.id, active_rule.id, current_user.name) else - java_facade.ruleSeverityChanged(profile.id, active_rule.id, old_severity, active_rule.failure_level, current_user.login) + java_facade.ruleSeverityChanged(profile.id, active_rule.id, old_severity, active_rule.failure_level, current_user.name) end end if active_rule @@ -300,12 +300,12 @@ class RulesConfigurationController < ApplicationController active_param.save active_param.valid? active_param.reload - java_facade.ruleParamChanged(profile.id, active_rule.id, rule_param.name, old_value, value, current_user.login) + java_facade.ruleParamChanged(profile.id, active_rule.id, rule_param.name, old_value, value, current_user.name) elsif !active_param.nil? old_value = active_param.value active_param.destroy active_param = nil - java_facade.ruleParamChanged(profile.id, active_rule.id, rule_param.name, old_value, nil, current_user.login) + java_facade.ruleParamChanged(profile.id, active_rule.id, rule_param.name, old_value, nil, current_user.name) end end render :partial => 'rule_param', :object => nil, @@ -323,7 +323,7 @@ class RulesConfigurationController < ApplicationController count = rules_to_activate.size rules_to_activate.each do |rule| active_rule = profile.active_rules.create(:rule => rule, :failure_level => rule.priority) - java_facade.ruleActivated(profile.id, active_rule.id, current_user.login) + java_facade.ruleActivated(profile.id, active_rule.id, current_user.name) end end count @@ -333,7 +333,7 @@ class RulesConfigurationController < ApplicationController count=0 profile.active_rules.each do |ar| if rule_ids.include?(ar.rule_id) && !ar.inheritance.present? - java_facade.ruleDeactivated(profile.id, ar.id, current_user.login) + java_facade.ruleDeactivated(profile.id, ar.id, current_user.name) ar.destroy count+=1 end 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 979c550f135..d1cfc1635c4 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 @@ -2,22 +2,23 @@ <%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'changelog'} %> <div class="tabs-panel marginbottom10"> - <% if @versions.empty? %> + <% if @select_versions.nil? %> No changes has been done on this quality profile. <% else %> - <% if !@past_versions.empty? %> - <% form_tag({:action => 'changelog'}, {:method => 'post'}) do %> - <%= hidden_field_tag "id", @profile.id %> - Changelog between last version (<%= @versions[0].change_date.strftime("%Y/%m/%d %H:%M:%S") %>) and - <%= select_tag "since", options_for_select(@past_versions.map {|u| ["version " + u.profile_version.to_s + " (" + u.change_date.strftime("%Y/%m/%d %H:%M:%S") + ")", u.profile_version]}, @since_version) %> - <%= submit_tag "Load", :id => 'submit_since'%> - <% end %> + <% form_tag({:action => 'changelog'}, {:method => 'post'}) do %> + <%= hidden_field_tag "id", @profile.id %> + Cahngelog between + <%= select_tag "since", options_for_select(@select_versions, @since_version) %> + and + <%= select_tag "to", options_for_select(@select_versions, @to_version) %> + <%= submit_tag "Load", :id => 'submit'%> <% end %> - <table class="data width100"> + <table class="data width100" style="word-wrap:break-word; table-layout: fixed;"> <thead> <tr> + <th>Profile version</th> <th>Date</th> <th>User</th> <th>Action</th> @@ -25,23 +26,13 @@ <th>Parameters</th> </tr> </thead> - <% current_version = -1 + <% @changes.each do |change| %> - <% if current_version != change.profile_version %> - <tr> - <td align="left" colspan="5"> - <div class="line-block"> - <h2>Version <%=change.profile_version%></h2> - </div> - </td> - </tr> - <% current_version = change.profile_version - end - %> - <tr class="<%= cycle 'even', 'odd', :name => change.profile_version -%>"> + <tr class="<%= cycle('even', 'odd') -%>"> + <td valign="top"><%= change.profile_version - 1 %> -> <%= change.profile_version %></td> <td valign="top"><%=change.change_date.strftime("%Y-%m-%d %H:%M:%S")%></td> - <td valign="top"><%=change.user_login%></td> + <td valign="top"><%=change.user_name%></td> <td valign="top"><%=change.action_text%></td> <td valign="top"><%=change.rule.name%></td> <td valign="top"> 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 c434bd19949..c3d2cf5104e 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 @@ -76,7 +76,6 @@ <thead> <tr> <th class="left">Name</th> - <th align="left">Version</th> <th class="right">Rules</th> <th class="right">Alerts</th> <th class="right">Projects</th> @@ -91,8 +90,6 @@ <tr class="<%= cycle 'even', 'odd', :name => language.getKey() -%>" id="<%= u profile.key %>"> <td><a href="<%= url_for :controller => 'rules_configuration', :action => 'index', :id => profile.id -%>" id="rules-<%= language.getKey() -%>-<%= u(profile.name) -%>"><%= h profile.name %></a></td> - <td align="left"><span id="version_<%= u profile.key -%>"><%= profile.version -%></span></td> - <td align="right"> <span id="activated_rules_<%= u profile.key -%>"><%= profile.count_active_rules -%></span> </td> diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/202_create_rule_changes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/202_create_rule_changes.rb index d9a03e5a72d..6d3e23f4106 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/202_create_rule_changes.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/202_create_rule_changes.rb @@ -25,7 +25,7 @@ class CreateRuleChanges < ActiveRecord::Migration def self.up create_table :active_rule_changes do |t| - t.column :user_login, :string, :limit => 40, :null => false + t.column :user_name, :string, :limit => 200, :null => false t.column :profile_id, :integer, :null => false t.column :profile_version, :integer, :null => false t.column :rule_id, :integer, :null => false diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile-result.xml index 62e8b337fec..179e151f058 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/changeParentProfile-result.xml @@ -1,5 +1,5 @@ <dataset> - <active_rule_changes id="1" user_login="admin" profile_id="2" profile_version="2" rule_id="1" enabled="true" old_severity="[null]" new_severity="2"/> + <active_rule_changes id="1" user_name="admin" profile_id="2" profile_version="2" rule_id="1" enabled="true" old_severity="[null]" new_severity="2"/> </dataset> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleActivated-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleActivated-result.xml index 9af4ad48837..ca2f4df610f 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleActivated-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleActivated-result.xml @@ -1,5 +1,5 @@ <dataset> - <active_rule_changes id="1" user_login="admin" profile_id="2" profile_version="2" rule_id="2" enabled="true" old_severity="[null]" new_severity="2"/> + <active_rule_changes id="1" user_name="admin" profile_id="2" profile_version="2" rule_id="2" enabled="true" old_severity="[null]" new_severity="2"/> </dataset> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleDeactivated-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleDeactivated-result.xml index 179a8ffd239..2edaf060432 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleDeactivated-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleDeactivated-result.xml @@ -1,6 +1,6 @@ <dataset> - <active_rule_changes id="1" user_login="admin" profile_id="2" profile_version="2" rule_id="2" enabled="false" old_severity="2" new_severity="[null]"/> + <active_rule_changes id="1" user_name="admin" profile_id="2" profile_version="2" rule_id="2" enabled="false" old_severity="2" new_severity="[null]"/> <active_rule_param_changes id="1" active_rule_change_id="1" rules_parameter_id="13" old_value="30" new_value="[null]"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleParamChanged-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleParamChanged-result.xml index 6704d22dea1..3c1672f4ac7 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleParamChanged-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleParamChanged-result.xml @@ -1,6 +1,6 @@ <dataset> - <active_rule_changes id="1" user_login="admin" profile_id="2" profile_version="2" rule_id="2" enabled="[null]" old_severity="[null]" new_severity="[null]"/> + <active_rule_changes id="1" user_name="admin" profile_id="2" profile_version="2" rule_id="2" enabled="[null]" old_severity="[null]" new_severity="[null]"/> <active_rule_param_changes id="1" active_rule_change_id="1" rules_parameter_id="13" old_value="20" new_value="30"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted-result.xml index 14b1c9d3c8b..653da410aa3 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleReverted-result.xml @@ -1,6 +1,6 @@ <dataset> - <active_rule_changes id="1" user_login="admin" profile_id="2" profile_version="2" rule_id="2" enabled="[null]" old_severity="3" new_severity="2"/> + <active_rule_changes id="1" user_name="admin" profile_id="2" profile_version="2" rule_id="2" enabled="[null]" old_severity="3" new_severity="2"/> <active_rule_param_changes id="1" active_rule_change_id="1" rules_parameter_id="13" old_value="30" new_value="[null]"/> <active_rule_param_changes id="2" active_rule_change_id="1" rules_parameter_id="14" old_value="100" new_value="50"/> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleSeverityChanged-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleSeverityChanged-result.xml index cd395478a45..22930c36abc 100644 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleSeverityChanged-result.xml +++ b/sonar-server/src/test/resources/org/sonar/server/configuration/RuleChangeTest/ruleSeverityChanged-result.xml @@ -1,5 +1,5 @@ <dataset> - <active_rule_changes id="1" user_login="admin" profile_id="2" profile_version="2" rule_id="2" enabled="[null]" old_severity="4" new_severity="3"/> + <active_rule_changes id="1" user_name="admin" profile_id="2" profile_version="2" rule_id="2" enabled="[null]" old_severity="4" new_severity="3"/> </dataset> diff --git a/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl b/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl index e8d80293808..d27879bd1aa 100644 --- a/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl +++ b/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl @@ -27,7 +27,7 @@ create table ACTIVE_RULES ( create table ACTIVE_RULE_CHANGES ( ID INTEGER not null, - USER_LOGIN VARCHAR(40) not null, + USER_NAME VARCHAR(200) not null, PROFILE_ID INTEGER not null, PROFILE_VERSION INTEGER not null, RULE_ID INTEGER not null, |