diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-12-23 16:36:15 +0100 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-12-23 16:36:56 +0100 |
commit | 5683b43c4c61953c67a05699aea95e1082d9a7a9 (patch) | |
tree | 8b3025ad31806dbef9c121bfe8abe5d6df195d65 | |
parent | 8bdc8f4b5b34358d6e5f99158001ff7a46314ba4 (diff) | |
download | sonarqube-5683b43c4c61953c67a05699aea95e1082d9a7a9.tar.gz sonarqube-5683b43c4c61953c67a05699aea95e1082d9a7a9.zip |
SONAR-2662 Display error message inline when no action plan available
When planning a review, if no action exists for the project, it is
best to write the message inline rather than opening a popup.
=> this also makes the code simpler.
7 files changed, 23 insertions, 18 deletions
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 257277f7a2f..5798be1507c 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 @@ -434,6 +434,7 @@ reviews.no_action_plan=None reviews.planned_for_x=Planned for {0} reviews.planned_for_label=Planned for reviews.an_action_plan_must_be_created_first=An action plan should be first created to plan the remediation effort of this violation. +reviews.hide_this_message=Hide this message reviews.filtered_by=Filtered by reviews.remove_this_filter=Remove this filter reviews.filtered_by.statuses=Status diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index 44523f2e747..fcdf4c7f532 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -321,7 +321,6 @@ class ResourceController < ApplicationController @global_violations=[] @expandable=(@lines!=nil) @filtered=!@expanded - @action_plans_size=ActionPlan.count_open_for_project_id(@snapshot.root_project_id) conditions='snapshot_id=?' values=[@snapshot.id] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb index 7be4ba432a5..9e72e9b3b3b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb @@ -36,10 +36,6 @@ class ActionPlan < ActiveRecord::Base ActionPlan.find :all, :conditions => ['status=? AND project_id=?', STATUS_OPEN, project_id], :order => :name end - def self.count_open_for_project_id(project_id) - ActionPlan.count :conditions => ['status=? AND project_id=?', STATUS_OPEN, project_id] - end - def user @user ||= begin diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_action_plan_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_action_plan_form.html.erb index c95966602cf..397fc5da372 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_action_plan_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_action_plan_form.html.erb @@ -1,3 +1,11 @@ +<% if @action_plans.empty? %> + + <span class="error"><%= message('reviews.an_action_plan_must_be_created_first') -%></span> + + <%= link_to_remote message('reviews.hide_this_message'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> + +<% else %> + <form method="POST"> <input type="hidden" name="id" value="<%= params[:id] -%>"/> @@ -19,3 +27,5 @@ <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%> </form> + +<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb index 8fc18e84b4f..c662654654e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb @@ -39,14 +39,10 @@ :update => "actionForm", :complete => "$('actionButtons').remove();$('actionForm').show();$('selectSeverity').focus();" -%> - <% if ActionPlan.count_open_for_project_id(@review.project_id)>0 %> - <%= button_to_remote message('reviews.link_to_action_plan'), + <%= button_to_remote message('reviews.link_to_action_plan'), :url => {:controller => "project_reviews", :action => "action_plan_form", :id => review.id}, :update => "actionForm", :complete => "$('actionButtons').remove();$('actionForm').show();$('selectSeverity').focus();" -%> - <% else %> - <input type="button" value="<%= message('reviews.link_to_action_plan') -%>" onclick="alert('<%= message('reviews.an_action_plan_must_be_created_first') -%>');"> - <% end %> <% end %> </div> <% end %> 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 5c02d39df2a..f8bbcfa6710 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 @@ -78,14 +78,7 @@ <% unless violation.review && violation.review.resolved? %> <%= button_to_function message('reviews.change_severity'), "sCSF(#{violation.id})", :name => 'bChangeSeverity' -%> - <% - @action_plans_size = ActionPlan.count_open_for_project_id(violation.snapshot.root_project_id) unless @action_plans_size - if @action_plans_size > 0 - %> - <%= button_to_function message('reviews.link_to_action_plan'), "sAPF(#{violation.id})", :name => 'bLinkActionPlan' -%> - <% else %> - <input type="button" value="<%= message('reviews.link_to_action_plan') -%>" onclick="alert('<%= message('reviews.an_action_plan_must_be_created_first') -%>');" name="bLinkActionPlan"> - <% end %> + <%= button_to_function message('reviews.link_to_action_plan'), "sAPF(#{violation.id})", :name => 'bLinkActionPlan' -%> <% end %> </div> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb index 6ce542a8d7d..40b778a5859 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb @@ -1,3 +1,11 @@ +<% if @action_plans.empty? %> + + <span class="error"><%= message('reviews.an_action_plan_must_be_created_first') -%></span> + + <%= link_to_function message('reviews.hide_this_message'), "cancelViolationAction(#{params[:id]})" -%> + +<% else %> + <form method="POST" action="violation_link_to_action_plan"> <input type="hidden" name="id" value="<%= params[:id] -%>"/> @@ -30,3 +38,5 @@ <%= link_to_function message('cancel'), "cancelViolationAction(#{params[:id]})" -%> </form> + +<% end %>
\ No newline at end of file |