aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/hbs/coding-rules/coding-rules-quality-profile-activation.hbs2
-rw-r--r--server/sonar-web/src/main/less/coding-rules.less7
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb28
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb30
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb16
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb22
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties2
7 files changed, 75 insertions, 32 deletions
diff --git a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-quality-profile-activation.hbs b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-quality-profile-activation.hbs
index 82c3c09a8fc..e407448a8bb 100644
--- a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-quality-profile-activation.hbs
+++ b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-quality-profile-activation.hbs
@@ -37,7 +37,7 @@
</tr>
{{#if isCustomRule}}
<tr class="property">
- <td colspan="2">{{t 'coding_rules.custom_rule.activation_notice'}}</td>
+ <td colspan="2" class="note">{{t 'coding_rules.custom_rule.activation_notice'}}</td>
{{else}}
{{#each params}}
<tr class="property">
diff --git a/server/sonar-web/src/main/less/coding-rules.less b/server/sonar-web/src/main/less/coding-rules.less
index 02220f1eaab..23f96841f69 100644
--- a/server/sonar-web/src/main/less/coding-rules.less
+++ b/server/sonar-web/src/main/less/coding-rules.less
@@ -3,11 +3,14 @@
@import (reference) 'ui';
@import (reference) 'navigator/config';
-@facetsHeight: 40px;
-
+@facetsHeight: 36px;
.coding-rules-page {
+ .navigator-facets {
+ min-height: 3 * @facetsHeight;
+ }
+
.navigator-results .spinner {
margin: @navigatorPadding;
}
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb
index 1828bff6877..8966df0f57a 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/comparison_controller.rb
@@ -21,7 +21,7 @@
class ComparisonController < ApplicationController
SECTION=Navigation::SECTION_HOME
-
+
def index
snapshots = []
resource_key = params[:resource]
@@ -30,7 +30,7 @@ class ComparisonController < ApplicationController
project = Project.by_key(resource_key)
return render_not_found('Project not found') unless project
- snapshots = project.events.select { |event| !event.snapshot_id.nil? && event.category==EventCategory::KEY_VERSION }[0..5].reverse.map {|e| e.snapshot}
+ snapshots = project.events.select { |event| !event.snapshot.nil? && event.category==EventCategory::KEY_VERSION }[0..5].reverse.map {|e| e.snapshot}
# if last snapshot is not in the list, add it at the end (=> might be the case for views or developers which do not have events)
last_snapshot = project.last_snapshot
unless snapshots.last == last_snapshot
@@ -46,15 +46,15 @@ class ComparisonController < ApplicationController
sids.each do |id|
selected_snapshots.each do |s|
snapshots << s if id==s.id.to_s
- end
+ end
end
end
- end
+ end
@snapshots = select_authorized(:user, snapshots)
-
+
metrics = get_params_as_array(:metrics)
if metrics.empty?
- metrics = [
+ metrics = [
'ncloc',
'complexity',
'comment_lines_density',
@@ -64,20 +64,20 @@ class ComparisonController < ApplicationController
]
end
@metrics = Metric.by_keys(metrics)
-
+
@metric_to_choose = Metric.all.select {|m| m.display? && !m.on_new_code? && !@metrics.include?(m)}.sort_by(&:short_name)
end
-
+
def versions
key = params[:resource]
sids = get_params_as_array(:sids)
-
+
unless key.blank?
resource = Project.by_key(params[:resource])
-
+
# we look for the events that are versions and that are not linked to snapshots already displayed on the page
@versions = resource.events.select { |event| !event.snapshot_id.nil? && event.category==EventCategory::KEY_VERSION && !sids.include?(event.snapshot_id.to_s) }
-
+
# check if the latest snapshot if suggested or not (and if not, suggest it as "LATEST" => this is used for views or developers which do not have events)
latest_snapshot_id = resource.last_snapshot.id
current_and_suggested_sids = sids + @versions.map {|e| e.snapshot_id.to_s}
@@ -85,13 +85,13 @@ class ComparisonController < ApplicationController
@versions.unshift Event.new(:name => Api::Utils.message('comparison.version.latest'), :snapshot_id => latest_snapshot_id)
end
end
-
+
render :partial => 'versions'
end
-
+
private
-
+
def get_params_as_array(name)
list = params[name]
if list.blank?
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
index 6956a1287eb..3b00a8a16b0 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
@@ -140,19 +140,37 @@ class ProfilesController < ApplicationController
render :partial => 'profiles/copy_form'
end
- # POST /profiles/copy/<id>?name=<name of new profile>
+ # POST /profiles/copy/<id>?name=<name of new profile>[&overwrite=<name of overwritten profile>]
def copy
verify_post_request
verify_ajax_request
require_parameters 'id'
- source_key=profile_id_to_key(params[:id].to_i)
+ source_id = params[:id].to_i
+ source_profile = Internal.quality_profiles.profile(source_id)
+
+ source_key=profile_id_to_key(source_id)
target_name = params['name']
- call_backend do
- Internal.qprofile_service.copyToName(source_key, target_name)
- flash[:notice]= message('quality_profiles.profile_x_not_activated', :params => target_name)
- render :text => 'ok', :status => 200
+ overwrite = (params['overwrite'] == target_name)
+ target_profile = nil
+
+ unless overwrite
+ target_profile = Internal.quality_profiles.profile(target_name, source_profile.language())
+ end
+
+ if target_profile.nil? || overwrite
+ call_backend do
+ Internal.qprofile_service.copyToName(source_key, target_name)
+ if overwrite
+ flash[:notice] = message('quality_profiles.copy_x_overwritten', :params => target_name)
+ else
+ flash[:notice] = message('quality_profiles.profile_x_not_activated', :params => target_name)
+ end
+ render :text => 'ok', :status => 200
+ end
+ else
+ render :text => message('quality_profiles.copy_overwrite_x', :params => target_name), :status => 409
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb
index 71a1b4463a1..78e2b2f6c8d 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/comparison/index.html.erb
@@ -93,7 +93,7 @@
});
</script>
</div>
-
+
<div id="resource_div" style="display: inline-block; margin-left: 30px">
<%= resource_select_tag 'new_resource', {
:resource_type_property => 'comparable',
@@ -147,14 +147,14 @@
});
</script>
</div>
-
+
</div>
<table class="data">
<thead>
-
+
<tr id="edit-columns-header">
- <th></th>
+ <th></th>
<%
last_index = @snapshots.size-1
@snapshots.each_with_index do |s, index|
@@ -184,9 +184,9 @@
</tr>
</table>
</th>
- <% end %>
+ <% end %>
<th></th>
- </tr>
+ </tr>
<tr id="resource-info-header">
<th></th>
<%
@@ -205,7 +205,7 @@
</th>
<% end %>
<th></th>
- </tr>
+ </tr>
</thead>
<tbody>
@@ -236,7 +236,7 @@
<%= format_measure s.measure(m) -%>
</td>
<% end %>
-
+
<td></td>
</tr>
<% end %>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb
index ab8a79f4247..71520b05840 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb
@@ -6,17 +6,37 @@
</div>
<div class="modal-body">
<div class="modal-error"/>
+ <div class="modal-warning"/>
<div class="modal-field">
<label for="name"><%= message 'quality_profiles.copy_new_name' -%> <em class="mandatory">*</em></label>
<input id="copy-name" name="name" type="text" size="50" maxlength="100" autofocus="autofocus"/>
</div>
</div>
<div class="modal-foot">
+ <input type="hidden" value="" name="overwrite" id="copy-overwrite"/>
<input type="submit" value="<%= h message('copy') -%>" id="copy-submit"/>
<a href="#" onclick="return closeModalWindow()" id="copy-cancel"><%= h message('cancel') -%></a>
</div>
</fieldset>
</form>
<script>
- $j("#copy-profile-form").modalForm();
+ $j("#copy-profile-form").modalForm({
+ error: function (xhr) {
+ if (xhr.status == 409) {
+ $j('#copy-profile-form .modal-error').hide();
+ var warningElt = $j('#copy-profile-form .modal-warning');
+ $j('#copy-overwrite').val($j('#copy-name').val());
+ $j('#copy-profile-form input[type=submit]').removeAttr('disabled');
+ warningElt.html(xhr.responseText);
+ warningElt.show();
+ } else {
+ $j('#copy-profile-form .modal-warning').hide();
+ var errorElt = $j('#copy-profile-form .modal-error');
+ $j('.loading-image').addClass("hidden");
+ $j('#copy-profile-form input[type=submit]').removeAttr('disabled');
+ errorElt.html(xhr.responseText);
+ errorElt.show();
+ }
+ }
+ });
</script>
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 331945e80e1..55ebb3441c7 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -1636,6 +1636,8 @@ quality_profiles.remove_projects_confirm_message=Are you sure that you want to d
quality_profiles.remove_projects_confirm_button=Remove All
quality_profiles.copy_x_title=Copy Profile {0}
quality_profiles.copy_new_name=New name
+quality_profiles.copy_overwrite_x=You are about to copy this quality profile into the existing "{0}" profile, which will fully overwrite it. Please confirm the name if you want to overwrite, or choose another name.
+quality_profiles.copy_x_overwritten=Profile '{0}' has been overwritten.
quality_profiles.restore_built_in_profiles=Restore Built-in Profiles
quality_profiles.restore_built_in_profiles_confirmation=Are you sure you want to restore '{0}' profile(s) for '{1}' ?
quality_profiles.including=including