]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1352 Display new metrics in alert quality profile page
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 6 Dec 2012 16:19:47 +0000 (17:19 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 6 Dec 2012 16:19:47 +0000 (17:19 +0100)
sonar-server/src/main/webapp/WEB-INF/app/helpers/alerts_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_edit.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/alerts/_new.html.erb

index 247d46f8ce27084c11f76d329d8b971500721706..fa338a0617b952879f810f19484521601bb16dab 100644 (file)
@@ -88,7 +88,18 @@ module AlertsHelper
     end
   end
 
-  def period_select_options(alert, index)
+  def period_select_options(alert)
+    if alert.metric
+      select = ''
+      select << period_select_option(alert, nil) if !alert.metric.name.start_with?("new_")
+      for index in 1..3 do
+        select << period_select_option(alert, index)
+      end
+      select
+    end
+  end
+
+  def period_select_option(alert, index)
     if index
       selected = (alert.period == index ? 'selected' : '')
       "<option value='#{index}' #{selected}>&Delta; #{Api::Utils.period_label(index)}</option>"
index c539bdc0c8f649978ca78f35889b795e986e26ca..7accf673e7228448589576d7247ebd96664a61d2 100644 (file)
@@ -6,10 +6,7 @@
   </td>
   <td width="10%" nowrap>
     <select id="alert_period" name="alert[period]">
-      <%= period_select_options(alert, nil) -%>
-      <%= period_select_options(alert, 1) -%>
-      <%= period_select_options(alert, 2) -%>
-      <%= period_select_options(alert, 3) -%>
+      <%= period_select_options(alert) -%>
     </select>
   </td>
   <td width="10%" nowrap>
index 82af723cb1abe70af3e0b0b2801b991110eff710..34c80e49e8843d042b685feef03a47caf2d38756 100644 (file)
@@ -16,7 +16,7 @@
       <% Metric.domains.each do |domain| %>
       <optgroup label="<%= h domain -%>">
         <%# 'new_' metrics excluded due to SONAR-2396 %>
-        <% Metric.by_domain(domain).select{ |m| m.alertable? && !m.name.start_with?("new_") }.each do |metric| %>
+        <% Metric.by_domain(domain).select{ |m| m.alertable? }.each do |metric| %>
           <option value="<%= metric.id -%>" <%= 'selected' if @alert.metric_id==metric.id -%>><%= metric.short_name %></option>
         <% end %>
       </optgroup>
 
   <td width="10%" valign="top">
     <select id="alert_period" name="alert[period]">
-      <% if !@alert.metric.nil? %>
-        <%= period_select_options(@alert, nil) -%>
-        <%= period_select_options(@alert, 1) -%>
-        <%= period_select_options(@alert, 2) -%>
-        <%= period_select_options(@alert, 3) -%>
-      <% end %>
+      <%= period_select_options(@alert) -%>
     </select>
   </td>