aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java5
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java42
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb5
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb2
6 files changed, 54 insertions, 5 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java
index c03e994f470..bf2632f271f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java
@@ -34,7 +34,10 @@ public final class DefaultResourceTypes extends ExtensionProvider implements Bat
public ResourceTypeTree provide() {
return ResourceTypeTree.builder()
- .addType(ResourceType.builder(Qualifiers.PROJECT).setProperty("deletable", "true").build())
+ .addType(ResourceType.builder(Qualifiers.PROJECT)
+ .setProperty("deletable", "true")
+ .setProperty("modifiable_history", "true")
+ .build())
.addType(ResourceType.builder(Qualifiers.MODULE).build())
.addType(ResourceType.builder(Qualifiers.DIRECTORY).build())
.addType(ResourceType.builder(Qualifiers.PACKAGE).build())
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index 28ea72edd23..47692382715 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -884,7 +884,7 @@ manual_rules.should_provide_real_description=Rule created on the fly. A descript
#
#------------------------------------------------------------------------------
-project_history.page_title=Handle events and delete quality snapshots from project history
+project_history.top_title=Handle events and delete quality snapshots from history
project_history.col.year=Year
project_history.col.month=Month
project_history.col.day=Day
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
index 9249f275cad..29cbb2287dd 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
@@ -41,6 +41,7 @@ import com.google.common.collect.Maps;
* <ul>
* <li>"deletable": if set to "true", then this resource can be deleted/purged.</li>
* <li>"availableForFilters": if set to "true", then this resource can be displayed in the filters results</li>
+ * <li>"modifiable_history": if set to "true", then the history of this resource may be modified (deletion of snapshots, modification of events, ...)</li>
* </ul>
*
* @since 2.14
@@ -49,17 +50,26 @@ import com.google.common.collect.Maps;
@Immutable
public final class ResourceType {
+ /**
+ * Builder used to create {@link ResourceType} objects.
+ */
public static class Builder {
private String qualifier;
private String iconPath;
private boolean hasSourceCode = false;
private Map<String, String> properties = Maps.newHashMap();
+ /**
+ * Creates a new {@link Builder}
+ * @param qualifier
+ */
public Builder(String qualifier) {
this.qualifier = qualifier;
}
/**
+ * Relative path of the icon used to represent the resource type.
+ *
* @param iconPath path to icon, relative to context of web-application (e.g. "/images/q/DIR.png")
*/
public Builder setIconPath(@Nullable String iconPath) {
@@ -76,12 +86,17 @@ public final class ResourceType {
return this;
}
+ /**
+ * Tells that the resources of this type will have source code.
+ */
public Builder hasSourceCode() {
this.hasSourceCode = true;
return this;
}
/**
+ * Sets a property on the resource type. See the description of {@link ResourceType} class for more information.
+ *
* @since 2.15
*/
public Builder setProperty(String key, String value) {
@@ -91,6 +106,9 @@ public final class ResourceType {
return this;
}
+ /**
+ * Creates an instance of {@link ResourceType} based on all information given to the builder.
+ */
public ResourceType build() {
if (Strings.isNullOrEmpty(iconPath)) {
iconPath = "/images/q/" + qualifier + ".png";
@@ -99,6 +117,10 @@ public final class ResourceType {
}
}
+ /**
+ * Creates a new {@link Builder}
+ * @param qualifier
+ */
public static Builder builder(String qualifier) {
Preconditions.checkNotNull(qualifier);
Preconditions.checkArgument(qualifier.length() <= 10, "Qualifier is limited to 10 characters");
@@ -118,12 +140,19 @@ public final class ResourceType {
}
/**
- * Qualifier is the unique key
+ * Qualifier is the unique key.
+ *
+ * @return the qualifier
*/
public String getQualifier() {
return qualifier;
}
+ /**
+ * Returns the relative path of the icon used to represent the resource type
+ *
+ * @return the relative path.
+ */
public String getIconPath() {
return iconPath;
}
@@ -137,11 +166,19 @@ public final class ResourceType {
return availableForFilters == null ? false : availableForFilters.booleanValue();
}
+ /**
+ * Tells whether resources of this type has source code or not.
+ *
+ * @return true if the type has source code
+ */
public boolean hasSourceCode() {
return hasSourceCode;
}
/**
+ * Returns the value of the property for this resource type.
+ *
+ * @return the String value of the property, or NULL if the property hasn't been set.
* @since 2.15
*/
public String getStringProperty(String key) {
@@ -150,6 +187,9 @@ public final class ResourceType {
}
/**
+ * Returns the value of the property for this resource type.
+ *
+ * @return the Boolean value of the property. If the property hasn't been set, False is returned.
* @since 2.15
*/
public Boolean getBooleanProperty(String key) {
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 b6f6d7917ff..69d70119bf6 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
@@ -54,7 +54,8 @@ class ProjectController < ApplicationController
not_found("Project not found") unless @project
access_denied unless is_admin?(@project)
- if !(@project.project? || @project.view? || @project.subview?)
+ # NOTE: we keep "@project.view? || @project.subview?" in the test for backward compatibility with the Views plugin
+ unless java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'modifiable_history') || @project.view? || @project.subview?
redirect_to :action => 'index', :id => params[:id]
end
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 6c185e58ea8..45cb68609fd 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
@@ -89,6 +89,11 @@
<% 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 -%>"><%= message('project_roles.page') -%></a></li>
+ <% end %>
+ <%
+ # NOTE: we keep "@project.view? || @project.subview?" in the test for backward compatibility with the Views plugin
+ if (controller.java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'modifiable_history') || @project.view? || @project.subview?)
+ %>
<li class="<%= 'selected' if request.request_uri.include?('/project/history') -%>">
<a href="<%= ApplicationController.root_context -%>/project/history/<%= @project.id -%>"><%= message('project_history.page') -%></a></li>
<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb
index 5f019607b55..0099ef7c69d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb
@@ -16,7 +16,7 @@
}
</style>
-<h1><%= message('project_history.page_title') -%></h1>
+<h1><%= message('project_history.top_title') -%></h1>
<br/>
<table id="project-history" class="data" style="width:1%">