From 8445821b4b17c24102ac018d9c9e500dbda27d63 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Fri, 14 Mar 2014 15:56:02 +0100 Subject: [PATCH] SONAR-4095 SONAR-4093 - Replace all alert related message with quality gate related messages - Allow selection of quality gate from project settings --- .../resources/org/sonar/l10n/core.properties | 56 ++++++++----------- .../plugins/core/widgets/alerts.html.erb | 4 +- .../app/controllers/project_controller.rb | 35 ++++++++++++ .../webapp/WEB-INF/app/models/internal.rb | 4 ++ .../layouts/_menu_resource_settings.html.erb | 3 + .../app/views/project/qualitygate.html.erb | 23 ++++++++ 6 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/project/qualitygate.html.erb diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 8a11a25a530..20b713f8735 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -13,7 +13,6 @@ age=Age apply=Apply assigned_to_me=Assigned to me association=Association -alerts=Alerts all=All and=And any=Any @@ -183,7 +182,6 @@ added_since_previous_analysis_detailed=Added since previous analysis ({0}) added_since_previous_version=Added since previous version added_since_previous_version_detailed=Added since previous version ({0}) added_since_version=Added since version {0} -alerts_feed=Alerts feed all_violations=All violations all_issues=All issues are_you_sure=Are you sure? @@ -326,7 +324,7 @@ project_links.scm_dev=Developer connection #------------------------------------------------------------------------------ event.category.Version=Version -event.category.Alert=Alert +event.category.Alert=Quality Gate event.category.Profile=Profile event.category.Other=Other @@ -404,6 +402,8 @@ update_center.page=Update Center update_center.page.description=Install, uninstall and delete plugins. You can also download SonarQube updates from the System Updates tab on this page. project_quality_profiles.page=Quality Profiles project_quality_profiles.page.description=Choose which profile is associated with this project on a language-by-language basis. (Note that you will only need to select profiles for multiple languages for multi-language projects.) +project_quality_gate.page=Quality Gate +project_quality_gate.page.description=Choose which quality gate is associated with this project. bulk_deletion.page=Bulk Deletion bulk_deletion.page.description=Use this page to delete multiple projects at once. update_key.page=Update Key @@ -486,7 +486,7 @@ measure_filter.criteria.last_analysis=Last analysis measure_filter.criteria.metric=Metric measure_filter.criteria.metric.not_set=Not set measure_filter.criteria.project=Project -measure_filter.criteria.alert=Alert +measure_filter.criteria.alert=Quality Gate measure_filter.criteria.alert.error=Error measure_filter.criteria.alert.warn=Warning measure_filter.criteria.alert.ok=Ok @@ -503,7 +503,6 @@ measure_filter.new_search=New Search measure_filter.favourite_filters=Favourite Filters measure_filter.more_criteria=+ More Criteria measure_filter.languages=Languages -measure_filter.alert_levels=Alert levels measure_filter.filter_list=Measures Filters measure_filter.col.date=Last Analysis measure_filter.col.description=Description @@ -1007,10 +1006,11 @@ widgets.more=More widget.error_occurred_please_read_logs=An error occurred while trying to display the widget "{0}". Please contact the administrator. widget.unsupported_browser_warning=Your browser is out of date and does not support this widget. -widget.alerts.name=Alerts -widget.alerts.description=Displays current alerts on the project. -widget.alerts.no_alert=No alerts -widget.alerts.alerts=Alerts +widget.alerts.name=Quality Gate Summary +widget.alerts.description=Displays a summary of the project's quality gate status. +widget.alerts.no_alert=The project has passed the quality gate. +widget.alerts.warnings=The project has warnings on the following quality gate conditions: +widget.alerts.errors=The project failed the quality gate on the following conditions: widget.code_coverage.name=Unit Tests Coverage widget.code_coverage.description=Reports on units tests and code coverage by unit tests. @@ -1086,12 +1086,12 @@ widget.description.key=Key widget.description.language=Language widget.description.profile=Profile widget.description.profile_version_x=version {0} -widget.description.alerts=Alerts +widget.description.alerts=Displays a summary of the project's quality gate status. widget.description.alerts_rss_feed=RSS Feed widget.description.links=Links widget.events.name=Events -widget.events.description=Reports events on the project life cycle such as versions and alerts. +widget.events.description=Reports events on the project life cycle such as versions and quality gate status updates. widget.events.title=Events widget.events.all=All widget.events.no_event=No event @@ -1468,7 +1468,7 @@ project_history.col.time=Time project_history.col.events=Events project_history.col.action=Action project_history.col.version=Version -project_history.col.alert=Alert +project_history.col.alert=Quality Gate Status project_history.col.profile=Profile project_history.delete=Delete project_history.last_snapshot=Last snapshot @@ -1531,6 +1531,12 @@ update_key.no_key_to_update=No key contains the string to replace ("{0}"). #------------------------------------------------------------------------------ project_quality_profile.default_profile=Default +#------------------------------------------------------------------------------ +# +# PROJECT QUALITY GATE PAGE +# +#------------------------------------------------------------------------------ +project_quality_gate.default_qgate=Default #------------------------------------------------------------------------------ # @@ -1796,7 +1802,7 @@ notification.channel.EmailNotificationChannel=Email notification.dispatcher.information=Subscribe to following channels to be notified when the related events occur. A notification is never sent to the author of the event. notification.dispatcher.ChangesOnMyIssue=Changes in issues assigned to me or reported by me notification.dispatcher.NewIssues=New issues -notification.dispatcher.NewAlerts=New alerts +notification.dispatcher.NewAlerts=New quality gate status notification.dispatcher.NewFalsePositiveIssue=New false positives @@ -1811,17 +1817,7 @@ alerts.notes.description=

Only project measures are checked against thresholds alerts.notes.ok=at least one threshold is defined, no threshold is reached. alerts.notes.warn=at least one warning threshold is reached, no error threshold is reached. alerts.notes.error=at least one error threshold is reached. -alerts.new_alert=New alert -alerts.editing_alert=Editing alert -alerts.create_alert=Create alert alerts.select_metric=Select a metric -alerts.warning_threshold=Warning threshold -alerts.warning_tooltip=A warning is triggered when this value is reached. -alerts.error_threshold=Error threshold -alerts.error_tooltip=An error is triggered when this value is reached. -alerts.alert_created=Alert is created. -alerts.alert_updated=Alert is updated. -alerts.alert_deleted=Alert is deleted. alerts.operator.<=is less than alerts.operator.>=is greater than alerts.operator.\==equals @@ -1955,13 +1951,9 @@ metric_domain.Reviews=Reviews metric.accessors.name=Accessors metric.accessors.description=Accessors -metric.alert_status.name=Alert -metric.alert_status.description=Alert -metric.alert_status.abbreviation=A - -metric.quality_gate_status.name=Quality Gate Status -metric.quality_gate_status.description=The project status with regard to it's quality thresholds. -metric.quality_gate_status.abbreviation=QG +metric.alert_status.name=Quality Gate Status +metric.alert_status.description=The project status with regard to it's quality thresholds. +metric.alert_status.abbreviation=QG metric.classes.name=Classes metric.classes.description=Classes @@ -2478,8 +2470,8 @@ global_permissions.users=Users global_permissions.groups=Groups global_permissions.admin=Administer System global_permissions.admin.desc=Ability to perform all administration functions for the instance: global configuration and personalization of default dashboards. -global_permissions.profileadmin=Administer Quality Profiles -global_permissions.profileadmin.desc=Ability to perform any action on the quality profiles. +global_permissions.profileadmin=Administer Quality Profiles and Gates +global_permissions.profileadmin.desc=Ability to perform any action on the quality profiles and gates. global_permissions.shareDashboard=Share Dashboards And Filters global_permissions.shareDashboard.desc=Ability to share dashboards, issue filters and measure filters. global_permissions.scan=Execute Analysis diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb index dbf3dafdb9e..111522b1aee 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb @@ -3,8 +3,10 @@ css_class = "widget color_#{m.alert_status}" if m.alert_status==Metric::TYPE_LEVEL_OK label = "#{message('widget.alerts.no_alert')}." + elif m.alert_status==Metric::TYPE_LEVEL_WARN + label = "#{message('widget.alerts.warnings')}#{h(m.alert_text)}." else - label = "#{message('widget.alerts.alerts')} : #{h(m.alert_text)}." + label = "#{message('widget.alerts.errors')}#{h(m.alert_text)}." end %>

<%= format_measure(m) -%> <%= label -%>
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= + 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=[&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?) %>
  • <%= message('project_quality_profiles.page') -%>
  • <% end %> + <% if (@project.project?) %> +
  • <%= message('project_quality_gate.page') -%>
  • + <% end %> <% if is_admin %>
  • <%= message('manual_measures.page') -%>
  • <% 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 @@ +

    <%= message('project_quality_gate.page') -%>

    +

    <%= message('project_quality_gate.page.description') -%>

    + +
    + + + + + + <%= submit_tag message('update_verb'), :id => "submit", :disable_with => message('updating') %> +
    -- 2.39.5