-
Notifications
You must be signed in to change notification settings - Fork 435
/
buildresult_helper.rb
79 lines (70 loc) · 3.43 KB
/
buildresult_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
module Webui::BuildresultHelper
# NOTE: There is a JavaScript version of this method in project_monitor.js
def arch_repo_table_cell(repo, arch, package_name, status = nil, enable_help = true)
status ||= @statushash[repo][arch][package_name] || { 'package' => package_name }
status_id = valid_xml_id("id-#{package_name}_#{repo}_#{arch}")
link_title = status['details']
code = ''
theclass = ' '
if status['code']
code = status['code']
theclass = "build-state-#{code}"
# special case for scheduled jobs with constraints limiting the workers a lot
theclass = 'text-warning' if code == 'scheduled' && link_title.present?
end
if flipper_responsive?
return build_state(code: code, css_class: theclass, package_name: package_name, status_id: status_id, repo: repo, arch: arch)
end
capture do
if enable_help && status['code']
concat(tag.i(nil, class: ['fa', 'fa-question-circle', 'text-info', 'mr-1'],
data: { content: Buildresult.status_description(status['code']), placement: 'top', toggle: 'popover' }))
end
if code.in?(['-', 'unresolvable', 'blocked', 'excluded', 'scheduled'])
concat(link_to(code, 'javascript:void(0);', id: status_id, class: theclass, data: { content: link_title, placement: 'right', toggle: 'popover' }))
else
concat(link_to(code.gsub(/\s/, ' '),
package_live_build_log_path(project: @project.to_s, package: package_name, repository: repo, arch: arch),
data: { content: link_title, placement: 'right', toggle: 'popover' }, rel: 'nofollow', class: theclass))
end
end
end
# NOTE: reponsive_ux
def build_state(attr)
capture do
if attr[:code].in?(['-', 'unresolvable', 'blocked', 'excluded', 'scheduled'])
concat(link_to(attr[:code], 'javascript:void(0);', id: attr[:status_id], class: attr[:css_class]))
else
concat(link_to(attr[:code].gsub(/\s/, ' '),
package_live_build_log_path(project: @project.to_s, package: attr[:package_name], repository: attr[:repo], arch: attr[:arch]),
rel: 'nofollow', class: attr[:css_class]))
end
end
end
def repository_expanded?(collapsed_repositories, repository_name, key = 'project')
return collapsed_repositories[key].exclude?(repository_name) if collapsed_repositories[key]
true
end
def collapse_link(expanded, main_name, repository_name = nil)
collapse_id = repository_name ? "#{main_name}-#{repository_name}" : main_name
collapse_text = repository_name ? 'repository' : 'package'
link_to('#', aria: { controls: "collapse-#{collapse_id}", expanded: expanded }, class: 'px-2 ml-auto',
data: { toggle: 'collapse' }, href: ".collapse-#{collapse_id}", role: 'button') do
capture do
concat(tag.i(nil, class: ['fas', 'fa-chevron-left', 'expander'], title: "Show build results for this #{collapse_text}"))
concat(tag.i(nil, class: ['fas', 'fa-chevron-down', 'collapser'], title: "Hide build results for this #{collapse_text}"))
end
end
end
# Paints an rpmlog line green-ish when the line has a Warning and red when it has an error.
def colorize_line(line)
case line
when /\w+(?:\.\w+)+: W: /
tag.span(line.strip, style: 'color: olive;')
when /\w+(?:\.\w+)+: E: /
tag.span(line.strip, style: 'color: red;')
else
line.strip
end
end
end