-
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 #6265 from dmarcoux/show_staging_projects_on_stagi…
…ng_workflow_page Show staging projects on staging workflow page
- Loading branch information
Showing
13 changed files
with
255 additions
and
58 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/api/app/assets/stylesheets/webui2/collapse-component.scss
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,13 @@ | ||
[data-toggle="collapse"] { | ||
&[aria-expanded="false"] { | ||
.collapser { | ||
display: none; | ||
} | ||
} | ||
|
||
&[aria-expanded="true"] { | ||
.expander { | ||
display: none; | ||
} | ||
} | ||
} |
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
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,86 @@ | ||
module Webui::Staging::WorkflowHelper | ||
def build_progress(staging_project) | ||
final = to_build = 0 | ||
|
||
staging_project.building_repositories.each do |repository| | ||
to_build += repository[:tobuild] | ||
final += repository[:final] | ||
end | ||
|
||
total = to_build + final | ||
|
||
return 100 if total == 0 | ||
# if we have building repositories, make sure we don't exceed 99 | ||
[final * 100 / total, 99].min | ||
end | ||
|
||
def review_progress(staging_project) | ||
staged_requests_numbers = staging_project.staged_requests.pluck(:number) | ||
total = Review.where(bs_request: staging_project.staged_requests).size | ||
missing = staging_project.missing_reviews.count { |missing_review| staged_requests_numbers.include?(missing_review[:request]) } | ||
|
||
100 - missing * 100 / total | ||
end | ||
|
||
def testing_progress(staging_project) | ||
notdone = allchecks = 0 | ||
|
||
# Note: The status_reports are defined via a has many through relation. Since within the | ||
# status report context the bs request relation is polymorphic, we have to call | ||
# includes with the polymorphic name ('checkable'). | ||
staging_project.status_reports.includes(:checkable).each do |report| | ||
notdone += report.checks.where(state: 'pending').size | ||
allchecks += report.checks.size + report.missing_checks.size | ||
end | ||
|
||
return 100 if allchecks == 0 | ||
100 - notdone * 100 / allchecks | ||
end | ||
|
||
def progress(staging_project) | ||
case staging_project.overall_state | ||
when :building | ||
link_to project_monitor_url(staging_project.name) do | ||
"#{build_progress(staging_project)} %" | ||
end | ||
when :review | ||
"#{review_progress(staging_project)} %" | ||
when :testing | ||
"#{testing_progress(staging_project)} %" | ||
end | ||
end | ||
|
||
def requests(staging_project) | ||
number_of_requests = staging_project.classified_requests.size | ||
|
||
return 'None' if number_of_requests == 0 | ||
|
||
requests_visible_by_default = 10 | ||
requests_links = staging_project.classified_requests.map do |request| | ||
css = 'ready' | ||
css = 'review' if request[:missing_reviews].present? | ||
css = 'obsolete' if request[:state].in?(BsRequest::OBSOLETE_STATES) | ||
|
||
link_to(request_show_path(request[:number]), class: 'request') do | ||
content_tag(:span, request[:package], class: "badge state-#{css}") | ||
end | ||
end | ||
|
||
if number_of_requests <= requests_visible_by_default | ||
return safe_join(requests_links) | ||
end | ||
|
||
output = safe_join(requests_links[0, requests_visible_by_default]) | ||
|
||
output += link_to('#', class: 'collapsed', 'data-toggle': 'collapse', href: ".collapse-#{staging_project.id}", | ||
role: 'button', aria: { expanded: 'false', controls: "collapse-#{staging_project.id}" }) do | ||
safe_join([ | ||
content_tag(:i, nil, class: 'fas fa-chevron-up collapser text-secondary ml-1 mr-1'), | ||
content_tag(:i, nil, class: 'fas fa-chevron-down expander text-secondary ml-1 mr-1') | ||
]) | ||
end | ||
output + content_tag(:div, class: "collapse collapse-#{staging_project.id}") do | ||
safe_join(requests_links[requests_visible_by_default..-1]) | ||
end | ||
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
10 changes: 9 additions & 1 deletion
10
src/api/app/views/webui2/webui/staging/workflows/_overall_state.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 |
---|---|---|
@@ -1 +1,9 @@ | ||
= project.name | ||
%span.badge{ class: "state-#{staging_project.overall_state}" } | ||
%span.badge.badge-light | ||
-# TODO: Link to the staging project show page | ||
= link_to(staging_project.staging_identifier, project_show_path(staging_project.staging_identifier)) | ||
%span | ||
%br | ||
= staging_project.overall_state | ||
%br | ||
= progress(staging_project) |
2 changes: 1 addition & 1 deletion
2
src/api/app/views/webui2/webui/staging/workflows/_packages_list.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 |
---|---|---|
@@ -1 +1 @@ | ||
Placeholder for the content | ||
= requests(staging_project) |
16 changes: 8 additions & 8 deletions
16
src/api/app/views/webui2/webui/staging/workflows/_problems.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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
:ruby | ||
max_problems = 5 | ||
project_class = project.name.tr(':', '_') | ||
project_class = staging_project.name.tr(':', '_') | ||
item_project_class = 'hidden-item-' + project_class | ||
|
||
- if project.problems.empty? | ||
- if staging_project.problems.empty? | ||
.text-center | ||
%i.fas.fa-check-circle.fa-2x.text-success | ||
- else | ||
%ul.list-group.list-group-flush | ||
= render partial: 'problems_item', locals: { project: project, index: 0...max_problems } | ||
= render partial: 'problems_item', locals: { staging_project: staging_project, index: 0...max_problems } | ||
|
||
- length = project.problems.length | ||
- length = staging_project.problems.length | ||
- if length > max_problems | ||
%span.collapse{ 'id': item_project_class } | ||
= render partial: 'problems_item', locals: { project: project, index: max_problems..-1 } | ||
= render partial: 'problems_item', locals: { staging_project: staging_project, index: max_problems..-1 } | ||
|
||
- number = length - max_problems | ||
%li.list-group-item.table-list-group-item | ||
%a.collapse-link{ 'data-toggle': 'collapse', href: "##{item_project_class}", 'aria-expanded': 'false' } | ||
%span.more See #{number} more | ||
%span.less See #{number} less | ||
%a{ 'data-toggle': 'collapse', href: "##{item_project_class}", 'aria-expanded': 'false' } | ||
%span.expander See #{number} more | ||
%span.collapser See #{number} less |
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
26 changes: 26 additions & 0 deletions
26
src/api/app/views/webui2/webui/staging/workflows/_staging_projects_table.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,26 @@ | ||
%table.table.table-striped.table-bordered.table-sm.dt-responsive.w-100#staging-projects-datatable | ||
%thead | ||
%tr.text-center | ||
%th Staging Project | ||
%th Requests | ||
%th Problems | ||
- if display_actions_column | ||
%th Actions | ||
%tbody | ||
- staging_projects.each do |staging_project| | ||
%tr | ||
%td.project | ||
= render partial: 'overall_state', locals: { staging_project: staging_project } | ||
%td.requests | ||
= render partial: 'packages_list', locals: { staging_project: staging_project } | ||
%td | ||
= render partial: 'problems', locals: { staging_project: staging_project } | ||
- if display_actions_column | ||
%td.text-center | ||
= link_to('#', data: { toggle: 'modal', target: "#confirm-modal-#{staging_project.id}" }, title: "Delete #{staging_project}") do | ||
%i.fas.fa-times-circle.text-danger | ||
|
||
= render partial: 'delete_staging_project_modal', locals: { staging_workflow: staging_workflow, staging_project: staging_project } | ||
|
||
- content_for :ready_function do | ||
$('#staging-projects-datatable').DataTable({ responsive: true }); |
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