-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6477 from bgeuken/project_status_in_bootstrap
Project status in bootstrap
- Loading branch information
Showing
13 changed files
with
225 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
module Webui::Projects::StatusHelper | ||
def parse_status(package) | ||
comments_to_clear = [] | ||
outs = [] | ||
icon = 'ok' | ||
sortkey = "9-ok-#{package['name']}" | ||
|
||
if package['requests_from'].empty? | ||
package['problems'].sort.each do |problem| | ||
if problem == 'different_changes' | ||
age = distance_of_time_in_words_to_now(package['develmtime'].to_i) | ||
outs << link_to("Different changes in devel project (since #{age})", | ||
package_rdiff_path(project: package['develproject'], package: package['develpackage'], oproject: @project.name, opackage: package['name'])) | ||
sortkey = "5-changes-#{package['develmtime']}-#{package['name']}" | ||
icon = 'changes' | ||
elsif problem == 'different_sources' | ||
age = distance_of_time_in_words_to_now(package['develmtime'].to_i) | ||
outs << link_to("Different sources in devel project (since #{age})", package_rdiff_path(project: package['develproject'], package: package['develpackage'], | ||
oproject: @project.name, opackage: package['name'])) | ||
sortkey = "6-changes-#{package['develmtime']}-#{package['name']}" | ||
icon = 'changes' | ||
elsif problem == 'diff_against_link' | ||
outs << link_to('Linked package is different', package_rdiff_path(oproject: package['lproject'], opackage: package['lpackage'], | ||
project: @project.name, package: package['name'])) | ||
sortkey = "7-changes#{package['name']}" | ||
icon = 'changes' | ||
elsif problem.match?(/^error-/) | ||
outs << link_to(c[6..-1], package_show_path(project: package['develproject'], package: package['develpackage'])) | ||
sortkey = "1-problem-#{package['name']}" | ||
icon = 'error' | ||
elsif problem == 'currently_declined' | ||
outs << link_to("Current sources were declined: request #{package['currently_declined']}", | ||
request_show_path(number: package['currently_declined'])) | ||
sortkey = "2-declines-#{package['name']}" | ||
icon = 'error' | ||
else | ||
outs << link_to(c, package_show_path(project: package['develproject'], package: package['develpackage'])) | ||
sortkey = "1-changes-#{package['name']}" | ||
icon = 'error' | ||
end | ||
end | ||
end | ||
package['requests_to'].each do |number| | ||
# rubocop:disable Rails/OutputSafety | ||
outs.unshift("Request #{link_to(number, request_show_path(number: number))} to #{h(package['develproject'])}".html_safe) | ||
# rubocop:enable Rails/OutputSafety | ||
icon = 'changes' | ||
sortkey = "3-request-#{999_999 - number}-#{package['name']}" | ||
end | ||
package['requests_from'].each do |number| | ||
# rubocop:disable Rails/OutputSafety | ||
outs.unshift("Request #{link_to(number, request_show_path(number: number))} to #{h(@project.name)}".html_safe) | ||
# rubocop:enable Rails/OutputSafety | ||
icon = 'changes' | ||
sortkey = "2-drequest-#{999_999 - number}-#{package['name']}" | ||
end | ||
# ignore the upstream version if there are already changes pending | ||
if package['upstream_version'] && sortkey.nil? | ||
if package['upstream_url'] | ||
outs << "New upstream version #{link_to(package['upstream_version'], package['upstream_url'])} available" | ||
else | ||
outs << "New upstream version #{package['upstream_version']} available" | ||
end | ||
sortkey = "8-outdated-#{package['name']}" | ||
end | ||
if package['firstfail'] | ||
# rubocop:disable Rails/OutputSafety | ||
url = package_live_build_log_path(arch: h(package['failedarch']), repository: h(package['failedrepo']), | ||
project: h(@project.name), package: h(package['name'])) | ||
outs.unshift("#{link_to('Fails', url)} since #{distance_of_time_in_words_to_now(package['firstfail'].to_i)}".html_safe) | ||
# rubocop:enable Rails/OutputSafety | ||
|
||
icon = 'error' | ||
sortkey = "1-fails-#{Time.now.to_i - package['firstfail']}-#{package['name']}" | ||
elsif package['failedcomment'] | ||
comments_to_clear << package['failedcomment'] | ||
end | ||
|
||
{ summary: outs, sortkey: sortkey, icon_type: icon, comments_to_clear: comments_to_clear } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
$('#<%= valid_xml_id("comment_#{@package}") %>').html('<%= escape_javascript(render(:partial => 'edit_comment')) %>'); | ||
$('#<%= valid_xml_id("comment_#{@package}") %>').html('<%= escape_javascript(render(:partial => 'edit_comment', comment: @comment, project: @project)) %>'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
$('#<%= params[:update] %>').replaceWith('<%= escape_javascript(render(:partial => 'edit_comment_form')) %>'); | ||
$('#<%= params[:update] %>'). | ||
replaceWith('<%= escape_javascript(render(partial: 'edit_comment_form', comment: @comment, project: @project, error: @error)) %>'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/api/app/views/webui2/webui/project/_edit_comment.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%div | ||
|
||
- if error | ||
%i.fa.fa-exclamation-triangle.text-warning | ||
= error | ||
|
||
= render partial: 'webui2/webui/project/status_comment', locals: { package_name: package_name, editable: true, comment: comment, project: project } | ||
|
4 changes: 4 additions & 0 deletions
4
src/api/app/views/webui2/webui/project/_edit_comment_form.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
= form_tag({ action: :edit_comment, project: params[:project], package: params[:package] }, id: 'edit_comment_form', remote: true) do | ||
= text_field_tag('text', params[:comment]) | ||
= hidden_field_tag('last_comment', params[:comment]) | ||
= submit_tag 'Save', class: 'btn btn-sm btn-primary' |
15 changes: 15 additions & 0 deletions
15
src/api/app/views/webui2/webui/project/_status_comment.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- if comment | ||
= h(comment) | ||
- if User.current.can_modify?(project.api_obj) | ||
- if editable | ||
= link_to(edit_comment_form_path(project: project, package: package_name, comment: comment), remote: true) do | ||
%i.fas.fa-edit.text-secondary | ||
= link_to(clear_failed_comment_path(project: project, package: package_name), remote: true) do | ||
%i.fas.fa-times-circle.text-danger | ||
|
||
- elsif editable | ||
%span.unknown_failure | ||
Unknown build failure | ||
- if User.current.can_modify?(project.api_obj) | ||
= link_to(edit_comment_form_path(project: project, package: package_name, comment: ''), remote: true) do | ||
%i.fas.fa-edit.text-secondary |
4 changes: 4 additions & 0 deletions
4
src/api/app/views/webui2/webui/project/clear_failed_comment.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$('#flash').html("<%= escape_javascript(render(layout: false, partial: 'layouts/webui2/flash', object: flash)) %>"); | ||
$('td[data-package-name="<%= params[:package] %>"]'). | ||
html('<%= escape_javascript(render(partial: 'webui2/webui/project/edit_comment', locals: { | ||
package_name: params[:package], editable: true, comment: 'Unknown build failure', project: @project })) %>'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$('td[data-package-name="<%= @package.name %>"]'). | ||
html('<%= escape_javascript(render(partial: 'edit_comment', locals: { package_name: @package.name, editable: true, comment: @comment, project: @project })) %>'); |
2 changes: 2 additions & 0 deletions
2
src/api/app/views/webui2/webui/project/edit_comment_form.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$('td[data-package-name="<%= params[:package] %>"]'). | ||
html('<%= escape_javascript(render(partial: 'edit_comment_form')) %>'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
:ruby | ||
@pagetitle = "Status of #{@project}" | ||
parsed_result = {} | ||
|
||
.card | ||
= render partial: 'tabs', locals: { project: @project } | ||
|
||
.card-body | ||
%h3 | ||
= @pagetitle | ||
|
||
= form_tag(project_status_path, method: :get) do | ||
= hidden_field_tag(:project, @project.name) | ||
= hidden_field_tag(:limit_to_fails, 'false', id: 'fails_hidden') | ||
= hidden_field_tag(:include_versions, 'false', id: 'versions_hidden') | ||
- if @develprojects.size > 2 | ||
.form-group | ||
= label_tag(:filter_devel, 'Devel project:') | ||
.col-sm-10 | ||
= select_tag(:filter_devel, options_for_select(@develprojects, @current_develproject), class: 'form-control') | ||
.custom-control.custom-checkbox | ||
= check_box_tag(:ignore_pending, true, @ignore_pending, class: 'custom-control-input') | ||
= label_tag(:ignore_pending, "Ignore packages with pending requests to #{@project.name}", class: 'custom-control-label') | ||
.custom-control.custom-checkbox | ||
= check_box_tag(:limit_to_fails, true, @limit_to_fails, class: 'custom-control-input') | ||
= label_tag(:limit_to_fails, 'Limit to currently failing packages', class: 'custom-control-label') | ||
.custom-control.custom-checkbox | ||
= check_box_tag(:include_versions, true, @include_versions, class: 'custom-control-input') | ||
= label_tag(:include_versions, 'Include version updates', class: 'custom-control-label') | ||
= submit_tag('Filter results', class: 'btn btn-sm btn-primary px-4 mt-2') | ||
|
||
- if @packages.present? | ||
.mt-4 | ||
%p | ||
Displaying #{@packages.size} packages that need handling, including: | ||
#{@packages.count { |p| p['firstfail'].to_i > 0 }} not building, | ||
#{@packages.count { |p| !p['problems'].empty? }} with a diff in the devel project, | ||
#{@packages.count { |p| !p['requests_to'].empty? || !p['requests_from'].empty? }} with a pending request. | ||
|
||
- show_devel_project = @packages.any? { |p| p['develproject'].present? } | ||
|
||
%table.responsive.table.table-striped.table-bordered.w-100#status-table | ||
%thead | ||
%tr | ||
%th | ||
Name | ||
- if show_devel_project | ||
%th | ||
Devel project | ||
%th | ||
Summary | ||
%th | ||
Comments | ||
%tbody | ||
- @packages.each do |package| | ||
- parsed_result = parse_status(package) | ||
|
||
%tr | ||
%td.nowrap | ||
- case parsed_result[:icon_type] | ||
- when 'error' | ||
%i.fa.fa-exclamation-circle.text-danger{ title: 'Error' } | ||
- when 'ok' | ||
%i.fa.fa-check-circle.text-success{ title: 'Ok' } | ||
- else | ||
%i.fa.fa-info-circle.text-info{ title: 'Info' } | ||
= link_to(truncate(package['name']), package_show_path(project: @project.name, package: package['name'])) | ||
- if show_devel_project | ||
%td | ||
- if package['develproject'] | ||
= link_to(truncate(package['develproject']), package_show_path(project: package['develproject'], package: package['name'])) | ||
%td | ||
%span.d-none | ||
= parsed_result[:sortkey] | ||
- parsed_result[:summary].each do |summary| | ||
= summary | ||
%br | ||
%td{ data: { package_name: package['name'] } } | ||
= render partial: 'status_comment', locals: { package_name: package['name'], editable: package['firstfail'].present?, | ||
comment: package['failedcomment'], project: @project } | ||
|
||
- content_for :ready_function do | ||
$('#status-table').dataTable({ 'iDisplayLength': 50, responsive: true, 'columnDefs': [ { 'width': '20%', 'targets': 0 } ] }); | ||
|
||
- if User.current.can_modify?(@project) && parsed_result[:comments_to_clear].present? | ||
= link_to("Clear all comments of not failing packages (#{parsed_result[:comments_to_clear].join(',')})", | ||
action: :clear_failed_comment, project: @project.name, package: parsed_result[:comments_to_clear]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters