diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-03-14 15:56:02 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-03-14 15:57:01 +0100 |
commit | 8445821b4b17c24102ac018d9c9e500dbda27d63 (patch) | |
tree | e004c8bc51d56bcd9530efdbbe7a2038c1ed7cfe /sonar-server/src/main/webapp | |
parent | 676fc571499ea4e4c3e5beb01baea1f76608f8ff (diff) | |
download | sonarqube-8445821b4b17c24102ac018d9c9e500dbda27d63.tar.gz sonarqube-8445821b4b17c24102ac018d9c9e500dbda27d63.zip |
SONAR-4095
SONAR-4093
- Replace all alert related message with quality gate related messages
- Allow selection of quality gate from project settings
Diffstat (limited to 'sonar-server/src/main/webapp')
4 files changed, 65 insertions, 0 deletions
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 b98b3a9c22f..4281e4c8376 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 @@ -107,6 +107,41 @@ class ProjectController < ApplicationController redirect_to :action => 'profile', :id => project end + # GET /project/qualitygate?id=<project id> + def qualitygate + require_parameters :id + @project_id = Api::Utils.project_id(params[:id]) + access_denied unless (is_admin?(@project_id) || has_role?(:profileadmin)) + # Need to display breadcrumb + @project = Project.by_key(@project_id) + + call_backend do + @all_quality_gates = Internal.quality_gates.list().to_a + @selected_qgate = Property.value('sonar.qualitygate', @project, '').to_i + end + end + + # POST /project/set_qualitygate?id=<project id>[&qgate_id=<qgate id>] + def set_qualitygate + verify_post_request + + project_id = params[:id].to_i + qgate_id = params[:qgate_id].to_i + previous_qgate_id = params[:previous_qgate_id].to_i + + ### TODO pass previous qgate to be able to dissociate + + call_backend do + if qgate_id == 0 + Internal.quality_gates.dissociateProject(previous_qgate_id, project_id) + else + Internal.quality_gates.associateProject(qgate_id, project_id) + end + end + + redirect_to :action => 'qualitygate', :id => project_id + end + def key @project = get_current_project(params[:id]) @snapshot = @project.last_snapshot diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb index d65915d4e35..0e8a352e3b1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb @@ -70,6 +70,10 @@ class Internal component(Java::OrgSonarServerQualityprofile::QProfiles.java_class) end + def self.quality_gates + component(Java::OrgSonarServerQualitygate::QualityGates.java_class) + end + def self.profile_backup component(Java::OrgSonarServerQualityprofile::QProfileBackup.java_class) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_menu_resource_settings.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_menu_resource_settings.html.erb index cfa9b3407ce..5f61df3902f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_menu_resource_settings.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_menu_resource_settings.html.erb @@ -10,6 +10,9 @@ <% if (@project.project?) %> <li><a href="<%= ApplicationController.root_context -%>/project/profile/<%= @project.id -%>"><%= message('project_quality_profiles.page') -%></a></li> <% end %> + <% if (@project.project?) %> + <li><a href="<%= ApplicationController.root_context -%>/project/qualitygate/<%= @project.id -%>"><%= message('project_quality_gate.page') -%></a></li> + <% end %> <% if is_admin %> <li><a href="<%= ApplicationController.root_context -%>/manual_measures/index/<%= @project.id -%>"><%= message('manual_measures.page') -%></a></li> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/qualitygate.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/qualitygate.html.erb new file mode 100644 index 00000000000..4d620706d01 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/qualitygate.html.erb @@ -0,0 +1,23 @@ +<h1 class="admin-page-title"><%= message('project_quality_gate.page') -%></h1> +<p class="admin-page-description"><%= message('project_quality_gate.page.description') -%></p> + +<form method="POST" action="<%= ApplicationController.root_context -%>/project/set_qualitygate"> + <input type="hidden" name="id" value="<%= @project_id -%>"/> + <input type="hidden" name="previous_qgate_id" value="<%= @selected_qgate -%>"/> + + <select id="select-qgate" name="qgate_id"> + <option value="" <%= "selected='selected'" unless @selected_qgate -%>><%= message 'project_quality_gate.default_qgate' -%></option> + <% puts @selected_qgate %> + <optgroup> + <% + qgates = Api::Utils.insensitive_sort(@all_quality_gates) { |qgate| qgate.name } + qgates.each do |qgate| + %> + <option value="<%= qgate.id -%>" <%= "selected='selected'" if @selected_qgate && (@selected_qgate == qgate.id) -%>><%= h qgate.name -%></option> + <% puts qgate.name, qgate.id == @selected_qgate %> + <% end %> + </optgroup> + </select> + + <%= submit_tag message('update_verb'), :id => "submit", :disable_with => message('updating') %> +</form> |