@highlighted_resource=@resource
end
- @display_viewers = display_metric_viewers?(@highlighted_resource || @resource, @highlighted_metric.key)
+ @display_viewers = display_metric_viewers?(@highlighted_resource || @resource)
end
- def issues
- @rule=Rule.by_key_or_id(params[:rule])
-
- # variation measures
- if params[:period].present? && params[:period].to_i>0
- @period=params[:period].to_i
- metric_prefix = 'new_'
- else
- @period=nil
- metric_prefix = ''
- end
-
- @severity = params[:severity]
- @rule_severity = params[:rule_sev] || @severity
-
- if @rule && @rule_severity.blank?
- # workaround for SONAR-3255 : guess the severity
- @rule_severity=guess_rule_severity_for_issues_metric(@snapshot, @rule, metric_prefix)
- end
-
- if @rule_severity.present?
- # Filter resources by severity
- @metric = Metric::by_key("#{metric_prefix}#{@rule_severity.downcase}_violations")
- else
- @metric = Metric::by_key("#{metric_prefix}violations")
- end
-
- # selected resources
- if params[:rids]
- @selected_rids= params[:rids]
- elsif params[:resource]
- highlighted_resource=Project.by_key(params[:resource])
- @selected_rids=(highlighted_resource ? [highlighted_resource.id] : [])
- else
- @selected_rids=[]
- end
- @selected_rids=@selected_rids.map { |r| r.to_i }
-
- # options for Drilldown
- options={:exclude_zero_value => true, :period => @period}
- if @rule
- params[:rule]=@rule.key # workaround for SONAR-1767 : the javascript hash named "rp" in the HTML source must contain the rule key, but not the rule id
- options[:rule_id]=@rule.id
- end
-
- # load data
- @drilldown = Drilldown.new(@resource, @metric, @selected_rids, self, options)
-
- @highlighted_resource=@drilldown.highlighted_resource
- if @highlighted_resource.nil? && @drilldown.columns.empty?
- @highlighted_resource=@resource
- end
-
- #
- # Initialize filter by rule
- #
- if @severity.present?
- # Filter on severity -> filter rule measures by the selected metric
- @rule_measures = @snapshot.rule_measures(@metric)
- else
- # No filter -> loads all the rules
- metrics=[
- Metric.by_key("#{metric_prefix}blocker_violations"),
- Metric.by_key("#{metric_prefix}critical_violations"),
- Metric.by_key("#{metric_prefix}major_violations"),
- Metric.by_key("#{metric_prefix}minor_violations"),
- Metric.by_key("#{metric_prefix}info_violations")
- ]
- @rule_measures = @snapshot.rule_measures(metrics)
- end
- end
-
- # Deprecated in 3.6. Kept for backward-compatibility, for example with SQALE (http://jira.sonarsource.com/browse/SQALE-185)
- def violations
- redirect_to(params.merge({:action => 'issues'}))
- end
private
metric
end
- def select_subsnapshot(snapshot, sid)
- if sid
- snapshot.children.each do |subsnapshot|
- return subsnapshot if subsnapshot.id==sid.to_i
- end
- end
- nil
- end
-
- def array_to_hash_by_id(array)
- hash={}
- array.each do |s|
- hash[s.id]=s
- end
- hash
- end
-
- def display_metric_viewers?(resource, metric_key)
+ def display_metric_viewers?(resource)
return resource.file?
end
- def display_violation_viewers?(snapshot)
- return true if snapshot.file?
- snapshot.violations.size>0
- end
-
- def guess_rule_severity(snapshot, rule, metric_prefix)
- Severity::KEYS.each do |severity|
- if snapshot.rule_measure(Metric.by_key("#{metric_prefix}#{severity.downcase}_violations"), rule)
- return severity
- end
- end
- Severity::MAJOR
- end
-
- def guess_rule_severity_for_issues_metric(snapshot, rule, metric_prefix)
- Severity::KEYS.each do |severity|
- if snapshot.rule_measure(Metric.by_key("#{metric_prefix}#{severity.downcase}_violations"), rule)
- return severity
- end
- end
- Severity::MAJOR
- end
-
end
SECTION=Navigation::SECTION_RESOURCE
helper :dashboard
- helper UsersHelper, IssuesHelper
+ helper UsersHelper
def index
require_parameters 'id'
#
module IssuesHelper
- def column_html(issue_query, issues_result, column_label, column_tooltip, sort)
- filter_sort = issue_query.sort
- filter_asc = issue_query.asc
- html = h(column_label)
- unless issues_result.maxResultsReached()
- html = link_to_function(h(column_label), "refreshList('#{escape_javascript sort}',#{!filter_asc}, #{issue_query.pageIndex||1})", :title => h(column_tooltip))
- if sort == filter_sort
- html << (filter_asc ? ' <i class="icon-sort-asc"></i>' : ' <i class="icon-sort-desc"></i>')
- end
- end
- html
- end
-
def issue_filter_star(filter, is_favourite)
if is_favourite
style='icon-favorite'
options
end
- def user_labels(logins)
- logins.map do |login|
- if login=='<unassigned>'
- Api::Utils.message('unassigned')
- else
- user = Api.users.findByLogin(login)
- user ? "#{user.name} (#{user.login})" : login
- end
- end
- end
end
+++ /dev/null
-<% selected=(severity==@severity) %>
-<tr class="<%= css -%> <%= 'selected' if selected -%>">
- <td><i class="icon-severity-<%= severity.downcase -%>"></i></td>
- <td>
- <%= link_to message("severity.#{severity}"), {:controller => :drilldown, :action => :issues, :id => @resource.id, :severity => (selected ? nil : severity), :period => @period} %>
- </td>
- <td style="padding-left: 10px;" align="right" nowrap>
- <%= @period ? format_variation(measure, :index => @period, :style => 'light') : format_measure(measure) -%>
- </td>
- <td align="left">
- <% value = measure_or_variation_value(measure) %>
- <%= barchart(:width => 60, :percent => (value ? (100 * value / max).to_i : 0), :color => (@period_index ? '#cc0000' : '#777')) if max>0 %>
- </td>
-</tr>
+++ /dev/null
-<%
- if @issues_result.issues && !@issues_result.issues.empty?
- colspan = 6
-%>
- <div id="issues-list">
- <table class="data width100">
- <thead>
- <tr>
- <th width="1%" nowrap class="column-severity">
- <%= column_html(@issues_query, @issues_result, message('severity_abbreviated'), message('severity'), 'SEVERITY') %>
- </th>
- <th width="1%" nowrap class="column-status">
- <%= column_html(@issues_query, @issues_result, message('status'), message('status'), 'STATUS') %>
- </th>
- <th>
- <%= message('description') -%>
- </th>
- <th nowrap>
- <%= message('component') -%>
- </th>
- <th class="column-assignee">
- <%= column_html(@issues_query, @issues_result, message('issue_filter.header.assignee'), message('issue_filter.header.assignee'), 'ASSIGNEE') %>
- </th>
- <th width="1%" nowrap>
- <%= message('issue_filter.header.action_plan') -%>
- </th>
- <th width="1%" nowrap class="column-update-date">
- <%= column_html(@issues_query, @issues_result, message('issue_filter.header.update_date'), message('issue_filter.header.update_date'), 'UPDATE_DATE') %>
- </th>
- </tr>
- </thead>
- <tbody>
- <%
- @issues_result.issues.each do |issue|
- %>
- <tr class="<%= cycle('even', 'odd') -%>">
- <td width="1%" nowrap>
- <i class="icon-severity-<%= issue.severity.downcase -%>"></i>
- </td>
- <td>
- <%= message("issue.status.#{issue.status}") -%>
- <% if issue.resolution %>
- <span class="note" style="white-space: nowrap">[<%= message("issue.resolution.#{issue.resolution}") -%>]</span>
- <% end %>
- </td>
- <td>
- <a class='open-modal rule-modal issue-detail-link' modal-width='900' href='<%= url_for :controller => 'issue', :action => 'show', :id => issue.key, :modal => true -%>'>
- <%= h truncate(issue.message, :length => 100) -%></a>
- </td>
- <td>
- <% project = @issues_result.project(issue)
- component = @issues_result.component(issue) -%>
- <div class="subtitle"><%= h (truncate(project.name, :length => 100)) -%></div>
- <% if component %>
- <!-- Do not display component name when issue is on module -->
- <% if component.key != project.key %>
- <%= h component.longName() -%>
- <% end %>
- <% else %>
- <del><%= h issue.componentKey() %></del>
- <% end %>
- </td>
- <td>
- <%= h @issues_result.user(issue.assignee).name if issue.assignee -%>
- </td>
- <td>
- <%= h @issues_result.actionPlan(issue).name if issue.actionPlanKey() -%>
- </td>
- <td width="1%" nowrap>
- <%= human_short_date(Api::Utils.java_to_ruby_datetime(issue.updateDate())) -%>
- </td>
- </tr>
- <%
- end
- %>
- </tbody>
- <%= if @ajax_mode
- paginate_java(@issues_result.paging, :colspan => colspan, :id => 'issue-filter-foot', :include_loading_icon => true,
- :url_results => url_for({:controller => 'issues', :action => 'search'}.merge(params))) { |label, page_id|
- link_to_function label, "refreshList('#{@issues_query.sort}', #{@issues_query.asc}, #{page_id})"
- }
- else
- paginate_java(@issues_result.paging, :colspan => colspan, :id => 'issue-filter-foot', :include_loading_icon => true) { |label, page_id|
- link_to(label, params.merge({:pageIndex => page_id}))
- }
- end
- %>
- </table>
- </div>
-<%
- end
-%>
-
-<script type="text/javascript">
- var filterCriteria = <%= json_escape(@issues_query_params.to_json) -%>;
-
- function refreshList(sort, asc, page) {
- $j('#issue-filter-foot_pages').hide();
- $j('#issue-filter-foot_loading').show();
-
- filterCriteria['sort']=sort;
- filterCriteria['asc']=asc;
- filterCriteria['pageIndex']=page;
- var url = baseUrl + '/issues/search?' + $j.param(filterCriteria);
-
- <% if @ajax_mode %>
- $j('.issues-content').load(url, function () {
- // As issues will be loaded after open-modal has been processed by jQuery, we have to process manually modal classes
- processModal();
- });
- <% else %>
- window.location = url;
- <% end %>
- return false;
- }
-
- function processModal(){
- $j('.issues-content .open-modal').modal();
- }
-
- <% if @ajax_mode %>
- $j(document).ready(function() {
- processModal();
- });
- <% end %>
-</script>
+++ /dev/null
-<% if @issues_result && @issues_result.maxResultsReached() %>
- <p class="notes"><%= message('issue_filter.max_results_reached', :params => @issues_result.paging.total()) -%></p>
-<% end %>
-
-<% unless @issues_result.issues && !@issues_result.issues.empty? %>
- <p class="notes" style="padding: 5px;"><%= message('issue_filter.no_result') -%></p>
-<% end %>
-
-<% if logged_in? && !@first_search %>
- <div id="issue-filters-operations" class="line-block marginbottom10">
- <ul class="operations">
- <% if @filter && @filter.id %>
- <li><a id="copy" href="<%= url_for :action => 'copy_form', :id => @filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a></li>
- <% end %>
- <% if !@unchanged && @filter && @filter.id && @filter.user == current_user.login %>
- <li>
- <%= link_to message('save'), params.merge({:action => 'save', :id => @filter.id}), :class => 'link-action', :id => 'save', :method => :post -%>
- </li>
- <% end %>
- <% unless @filter %>
- <li>
- <a id="save-as" href="<%= url_for params.merge({:action => 'save_as_form'}) -%>" class="link-action open-modal"><%= message('save_as') -%></a>
- </li>
- <% end %>
- <% if @issues_result.issues && !@issues_result.issues.empty? %>
- <li class="last">
- <a id="bulk-change" href="<%= url_for params.merge({:action => 'bulk_change_form'}) -%>"
- class="link-action open-modal"><%= message('bulk_change') -%></a>
- </li>
- <% end %>
- </ul>
-
- <% if @filter && @filter.id && @filter.name.present? %>
- <div class="page_title" id="filter-title">
- <p>
- <span class="h3"><%= h @filter.name -%></span>
- <span class="note">
- <% if !@filter.shared %>
- [<%= message 'issue_filter.private' -%>]
- <% elsif @filter.user==current_user.login %>
- [<%= message 'issue_filter.shared_with_all_users' -%>]
- <% elsif @filter.user %>
- [<%= message 'shared_by' -%> <%= Api.users.findByLogin(@filter.user).name -%>]
- <% end %>
- </span>
- <% if @filter.user == current_user.login %>
- <a href="<%= url_for :action => 'edit_form', :id => @filter.id -%>" class="open-modal" id="edit-filter"><%= image_tag 'pencil-small.png', :alt => message('edit') -%></a>
- <% end %>
- </p>
- </div>
- <% end %>
- </div>
-<% end %>
+++ /dev/null
-<% if logged_in? && @issues_result.issues && !@issues_result.issues.empty? %>
- <div class="line-block marginbottom10">
- <div id="issue-filters-operations" style="padding-right: 5px; padding-top: 5px;">
- <ul class="operations">
- <li class="last">
- <a id="bulk-change" href="<%= url_for params.merge({:controller => 'issues', :action => 'bulk_change_form'}) -%>"
- class="link-action open-modal"><%= message('bulk_change') -%></a>
- </li>
- </ul>
- </div>
- </div>
-<% end %>
+++ /dev/null
-<div class="issues-content">
- <%= render :partial => 'operations' -%>
- <%= render :partial => 'list' -%>
-</div>
+++ /dev/null
-<div class="issues-content">
- <%
- if @issues_result.issues && !@issues_result.issues.empty?
- %>
- <%= render :partial => 'operations_ajax' -%>
- <%= render :partial => 'list' -%>
- <% else %>
- <%= render :partial => 'shared/no_issues' -%>
- <% end %>
-</div>