Skip to content

Commit

Permalink
List requests of a staging project on the index page
Browse files Browse the repository at this point in the history
This provides a list of staged requests for each staging project.
When there are more than 5 requests the additional requests are hidden
and can be shown via a link.

Co-authored-by: Dany Marcoux <dmarcoux@suse.com>
  • Loading branch information
bgeuken and Dany Marcoux committed Nov 19, 2018
1 parent 0433229 commit 0983ffa
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 13 deletions.
13 changes: 13 additions & 0 deletions src/api/app/assets/stylesheets/webui2/collapse-component.scss
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;
}
}
}
89 changes: 89 additions & 0 deletions src/api/app/assets/stylesheets/webui2/staging-workflow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,92 @@ ul .table-list-group-item {
.collapse-link[aria-expanded="true"] .more{
display: none;
}

#staging-projects-datatable {
td {
span.badge {
font-size: inherit;
font-weight: inherit;
}

&.project {
> span.badge {
@extend .w-100;
}

span.badge {
&.state-unacceptable {
@extend .badge-dark;
}

&.state-acceptable {
@extend .badge-success;
}

&.state-testing {
@extend .badge-info;
}

&.state-building {
@extend .badge-warning;

span {
@extend .text-dark;
}
}

&.state-failed {
@extend .badge-danger;
}

&.state-review {
@extend .badge-secondary;
}

&.state-empty {
@extend .badge-light;
@extend .border;

span {
@extend .text-dark;
}
}
}
}

&.requests {
@extend .w-50;

a.request {
@extend .text-white;
padding: 0 0.125rem 0.25rem;

&:hover {
text-decoration: none;
}

span.badge {
&.state-ready {
@extend .badge-success;
}

&.state-review {
@extend .badge-warning;
}

&.state-obsolete {
@extend .badge-info;
}

&.state-untracked {
@extend .badge-dark;
}
}
}

a, div.collapse, div.collapsing {
float: left;
}
}
}
}
3 changes: 2 additions & 1 deletion src/api/app/assets/stylesheets/webui2/webui2.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
@import 'diff';
@import 'package-show';
@import 'staging-workflow';
@import 'repositories';
@import 'collapse-component';

html {
overflow-y: scroll !important;
}
@import 'repositories';
34 changes: 34 additions & 0 deletions src/api/app/helpers/webui/staging/workflow_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,38 @@ def progress(staging_project)
"#{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
15 changes: 15 additions & 0 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ def staging_identifier
name[/.*:Staging:(.*)/, 1]
end

def classified_requests
requests = (requests_to_review | staged_requests.includes(:reviews)).map do |request|
{
number: request.number,
state: request.state,
package: request.first_target_package,
request_type: request.bs_request_actions.first.type,
missing_reviews: missing_reviews.select { |review| review[:request] == request.number },
tracked: requests_to_review.include?(request)
}
end

requests.sort_by { |request| request[:package] }
end

def untracked_requests
requests_to_review - staged_requests
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
- # TODO: Make this a link
= staging_project.staging_identifier
%br
= staging_project.overall_state
%br
= progress(staging_project)
%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)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Placeholder for the content
= requests(staging_project)
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
%tr.text-center
%th Staging Project
%th Requests
%th Problems
%th Actions

%tbody
- @staging_workflow.staging_projects.each do |staging_project|
%tr
%td.text-center
%td.project
= render partial: 'overall_state', locals: { staging_project: staging_project }
%td
%td.requests
= render partial: 'packages_list', locals: { staging_project: staging_project }
%td
= render partial: 'problems', locals: { staging_project: staging_project }
%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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
%table.table.table-striped.table-bordered.table-sm.dt-responsive.w-100#staging-projects-datatable
%thead
%tr.text-center
%th Project
%th Staging Project
%th Requests
%th Problems
%tbody
- @staging_projects.each do |staging_project|
%tr
%td.text-center
%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 }

Expand Down

0 comments on commit 0983ffa

Please sign in to comment.