Skip to content

Commit

Permalink
Remove Bento helpers for projects
Browse files Browse the repository at this point in the history
Now that we are only using the new web interface, we want to get rid
of all the helpers only used with Bento.

Remove also unused escape_list helper.
  • Loading branch information
eduardoj committed Sep 3, 2019
1 parent 8694e2f commit 3c717c9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 147 deletions.
83 changes: 0 additions & 83 deletions src/api/app/helpers/webui/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,6 @@ def pulse_period(range)
"#{start_time.strftime("%B, #{start_time.day.ordinalize} %Y")}#{end_time.strftime("%B, #{end_time.day.ordinalize} %Y")}"
end

def show_status_comment(comment, package, firstfail, comments_to_clear)
status_comment_html = ''.html_safe
if comment
# TODO: Port _to_remote helpers to jQuery
status_comment_html = ERB::Util.h(comment)
if !firstfail
if User.possibly_nobody.can_modify?(@project)
status_comment_html += ' '.html_safe + link_to(image_tag('comment_delete.png', size: '16x16', alt: 'Clear'),
{ action: :clear_failed_comment, project: @project,
package: package, update: valid_xml_id("comment_#{package}") },
remote: true)
comments_to_clear << package
end
elsif User.possibly_nobody.can_modify?(@project)
status_comment_html += ' '.html_safe
status_comment_html += link_to(image_tag('comment_edit.png', alt: 'Edit'),
{ action: 'edit_comment_form', comment: comment,
package: package, project: @project,
update: valid_xml_id("comment_edit_#{package}") },
remote: true)
end
elsif firstfail
if User.possibly_nobody.can_modify?(@project)
status_comment_html += " <span class='unknown_failure'>Unknown build failure ".html_safe +
link_to(image_tag('comment_edit.png', size: '16x16', alt: 'Edit'),
{ action: 'edit_comment_form', comment: '', package: package,
project: @project, update: valid_xml_id("comment_edit_#{package}") },
remote: true)
status_comment_html += '</span>'.html_safe
else
status_comment_html += "<span class='unknown_failure'>Unknown build failure</span>".html_safe
end
end
status_comment_html + "<span id='".html_safe + valid_xml_id("comment_edit_#{package}") + "'></span>".html_safe
end

def project_bread_crumb(*args)
@crumb_list = [link_to('Projects', project_list_public_path)]
return if @spider_bot
Expand Down Expand Up @@ -89,53 +53,6 @@ def rebuild_time_col(package)
link_to(h(package), controller: '/webui/package', action: :show, project: @project, package: package) + ' ' + format_seconds(btime)
end

# bento_only
def short_incident_name(incident)
re = Regexp.new("#{@project.name}\:(.*)")
match = incident.name.match(re)
return match[1] if match.length > 1
match[0]
end

def patchinfo_rating_color(rating)
Patchinfo::RATING_COLORS[rating.to_s] || ''
end

def patchinfo_category_color(category)
Patchinfo::CATEGORY_COLORS[category.to_s] || ''
end

def incident_issue_color(patchinfo_issues, package_issues)
return 'red' if package_issues.zero?
return 'green' if patchinfo_issues == package_issues
return 'olive' if patchinfo_issues < package_issues
return 'red'
end

def remove_parent_name(project_name, parent_name)
project_name.slice(parent_name.length + 1, project_name.length)
end

STATE_ICONS = {
'new' => 'flag_green',
'review' => 'flag_yellow',
'declined' => 'flag_red'
}.freeze

def map_request_state_to_flag(state)
STATE_ICONS[state.to_s] || ''
end

def escape_list(list)
# The input list is not html_safe because it's
# user input which we should never trust!!!
list.map do |p|
"['".html_safe +
escape_javascript(p) +
"']".html_safe
end.join(',').html_safe
end

def show_package_actions?
return false if @is_maintenance_project
return false if @project.defines_remote_instance?
Expand Down
64 changes: 0 additions & 64 deletions src/api/spec/helpers/webui/project_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
require 'rails_helper'

RSpec.describe Webui::ProjectHelper, type: :helper do
describe '#show_status_comment' do
skip
end

describe '#project_bread_crumb' do
let(:project) { create(:project_with_package) }

Expand Down Expand Up @@ -66,64 +62,4 @@
describe '#rebuild_time_col' do
skip
end

describe '#short_incident_name' do
skip
end

describe '#patchinfo_rating_color' do
it 'returns the right color' do
expect(patchinfo_rating_color('important')).to eq('red')
end

it 'returns no color for an inexistent rating' do
expect(patchinfo_rating_color(nil)).to eq('')
end
end

describe '#patchinfo_category_color' do
it 'returns the right color' do
expect(patchinfo_category_color('security')).to eq('maroon')
end

it 'returns no color for an inexistent category' do
expect(patchinfo_rating_color(nil)).to eq('')
end
end

describe '#incident_issue_color' do
it 'returns red if there are no patchinfo issues' do
expect(incident_issue_color(0, 0)).to eq('red')
end

it 'returns green if package and patchinfo have the same amount of issues' do
expect(incident_issue_color(20, 20)).to eq('green')
end

it 'returns olive if there are more package issues than patchinfo issues' do
expect(incident_issue_color(20, 30)).to eq('olive')
end

it 'returns red if there are more patchinfo issues than package issues' do
expect(incident_issue_color(30, 20)).to eq('red')
end
end

describe '#map_request_state_to_flag' do
it 'returns the right flag' do
expect(map_request_state_to_flag('new')).to eq('flag_green')
end

it 'returns no flag if passed nothing' do
expect(map_request_state_to_flag(nil)).to eq('')
end
end

describe '#escape_list' do
it 'html escapes an array of strings' do
input = ['<p>home:Iggy</p>', '<p>This is a paragraph</p>']
output = "['&lt;p&gt;home:Iggy&lt;\\/p&gt;'],['&lt;p&gt;This is a paragraph&lt;\\/p&gt;']"
expect(escape_list(input)).to eq(output)
end
end
end

0 comments on commit 3c717c9

Please sign in to comment.