2012-03-22 17:11:12 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2012-03-18 08:20:31 +00:00
|
|
|
module BuildListsHelper
|
|
|
|
def build_list_status_color(status)
|
|
|
|
if [BuildList::BUILD_PUBLISHED, BuildServer::SUCCESS].include? status
|
2012-03-19 08:39:46 +00:00
|
|
|
return 'success'
|
2012-03-18 08:20:31 +00:00
|
|
|
end
|
|
|
|
if [BuildServer::BUILD_ERROR, BuildServer::PLATFORM_NOT_FOUND,
|
2012-04-17 19:18:39 +01:00
|
|
|
BuildServer::PROJECT_NOT_FOUND, BuildServer::PROJECT_VERSION_NOT_FOUND,
|
|
|
|
BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH].include? status
|
2012-03-19 08:39:46 +00:00
|
|
|
return 'error'
|
2012-03-18 08:20:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
'nocolor'
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_list_item_status_color(status)
|
|
|
|
if BuildServer::SUCCESS == status
|
|
|
|
return 'success'
|
|
|
|
end
|
|
|
|
if [BuildServer::DEPENDENCIES_ERROR, BuildServer::BUILD_ERROR, BuildList::Item::GIT_ERROR].include? status
|
|
|
|
return 'error'
|
|
|
|
end
|
|
|
|
|
|
|
|
''
|
|
|
|
end
|
2012-07-06 00:05:47 +01:00
|
|
|
|
|
|
|
def build_list_classified_update_types
|
|
|
|
advisoriable = BuildList::RELEASE_UPDATE_TYPES.map do |el|
|
|
|
|
[el, {:class => 'advisoriable'}]
|
|
|
|
end
|
|
|
|
nonadvisoriable = (BuildList::UPDATE_TYPES - BuildList::RELEASE_UPDATE_TYPES).map do |el|
|
|
|
|
[el, {:class => 'nonadvisoriable'}]
|
|
|
|
end
|
|
|
|
|
|
|
|
return advisoriable + nonadvisoriable
|
|
|
|
end
|
2012-07-09 21:43:01 +01:00
|
|
|
|
2012-11-12 16:23:11 +00:00
|
|
|
def build_list_version_link(bl, str_version = false)
|
2012-12-03 18:09:36 +00:00
|
|
|
hash_size=5
|
2012-11-12 16:23:11 +00:00
|
|
|
if bl.commit_hash.present?
|
2012-12-03 17:43:24 +00:00
|
|
|
if bl.last_published_commit_hash.present?
|
2012-12-03 18:09:36 +00:00
|
|
|
link_to "#{shortest_hash_id bl.last_published_commit_hash, hash_size}...#{shortest_hash_id bl.commit_hash, hash_size}",
|
2012-12-03 17:43:24 +00:00
|
|
|
diff_path(bl.project.owner, bl.project, bl.last_published_commit_hash) + "...#{bl.commit_hash}"
|
|
|
|
else
|
2012-12-03 18:09:36 +00:00
|
|
|
link_to str_version ? "#{shortest_hash_id bl.commit_hash, hash_size}" : shortest_hash_id(bl.commit_hash, hash_size),
|
2012-12-03 17:43:24 +00:00
|
|
|
commit_path(bl.project.owner, bl.project, bl.commit_hash)
|
|
|
|
end
|
2012-07-09 21:43:01 +01:00
|
|
|
else
|
2012-11-12 16:23:11 +00:00
|
|
|
bl.project_version
|
2012-07-09 21:43:01 +01:00
|
|
|
end
|
|
|
|
end
|
2012-08-13 22:41:15 +01:00
|
|
|
|
2012-12-04 03:07:18 +00:00
|
|
|
def product_build_list_version_link(bl, str_version = false)
|
|
|
|
if bl.commit_hash.present?
|
|
|
|
link_to str_version ? "#{shortest_hash_id bl.commit_hash} ( #{bl.project_version} )" : shortest_hash_id(bl.commit_hash),
|
|
|
|
commit_path(bl.project.owner, bl.project, bl.commit_hash)
|
|
|
|
else
|
|
|
|
bl.project_version
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-13 22:41:15 +01:00
|
|
|
def container_url
|
2012-12-03 17:17:20 +00:00
|
|
|
if @build_list.new_core?
|
|
|
|
@build_list.container_path
|
|
|
|
else
|
|
|
|
"http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe
|
|
|
|
end
|
2012-08-13 22:41:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def build_list_log_url(log_type)
|
2012-08-17 09:23:49 +01:00
|
|
|
"http://#{request.host_with_port}/#{@build_list.fs_log_path(log_type)}".html_safe
|
2012-08-13 22:41:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def log_reload_time_options
|
|
|
|
t = I18n.t("layout.build_lists.log.reload_times").map { |i| i.reverse }
|
|
|
|
|
|
|
|
options_for_select(t, t.first).html_safe
|
|
|
|
end
|
2012-08-17 09:23:49 +01:00
|
|
|
|
|
|
|
def log_reload_lines_options
|
|
|
|
options_for_select([100, 200, 500, 1000, 1500, 2000], 1000).html_safe
|
|
|
|
end
|
2012-03-18 08:20:31 +00:00
|
|
|
end
|