Skip to content

Commit

Permalink
Merge pull request #6288 from saraycp/show_staging_project
Browse files Browse the repository at this point in the history
Add staging project show page
  • Loading branch information
bgeuken committed Nov 21, 2018
2 parents e69abf8 + bfb609f commit 15442d7
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 78 deletions.
125 changes: 62 additions & 63 deletions src/api/app/assets/stylesheets/webui2/staging-workflow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,95 +19,94 @@ ul .table-list-group-item {
background-color: transparent;
}

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

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

> span.badge {
@extend .m-1;
}
> span.badge {
@extend .m-1;
}
}

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

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

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

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

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

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

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

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

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

&.requests {
@extend .w-50;
&.requests {
@extend .w-50;

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

&:hover {
text-decoration: none;
}
&:hover {
text-decoration: none;
}

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

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

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

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

a, div.collapse, div.collapsing {
float: left;
}
a, div.collapse, div.collapsing {
float: left;
}
}
}
8 changes: 7 additions & 1 deletion src/api/app/controllers/webui/staging/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class ProjectsController < WebuiController

before_action :require_login
before_action :set_staging_workflow
after_action :verify_authorized
after_action :verify_authorized, except: :show
before_action :set_webui2_views

def create
authorize @staging_workflow
Expand All @@ -22,6 +23,11 @@ def create
redirect_to edit_staging_workflow_path(@staging_workflow)
end

def show
@staging_project = @staging_workflow.staging_projects.find_by(name: params[:project_name])
@project = @staging_workflow.project
end

def destroy
authorize @staging_workflow

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Webui::Staging::WorkflowsController < Webui::WebuiController
layout 'webui2/webui'

before_action :require_login, except: [:show]
before_action :set_bootstrap_views
before_action :set_webui2_views
before_action :set_project, only: [:new, :create]
before_action :set_staging_workflow, except: [:new, :create]
after_action :verify_authorized, except: [:show, :new]
Expand Down Expand Up @@ -84,10 +84,6 @@ def update

private

def set_bootstrap_views
prepend_view_path('app/views/webui2')
end

def set_staging_workflow
@staging_workflow = ::Staging::Workflow.find_by(id: params[:id])
return if @staging_workflow
Expand Down
9 changes: 8 additions & 1 deletion src/api/app/controllers/webui/webui_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ def choose_layout
def switch_to_webui2
if switch_to_webui2?
@switch_to_webui2 = true
prepend_view_path('app/views/webui2')

set_webui2_views

prefixed_action_name = "webui2_#{action_name}"
send(prefixed_action_name) if action_methods.include?(prefixed_action_name)
return true
Expand All @@ -315,4 +317,9 @@ def set_pending_announcement
return if Announcement.last.in?(User.current.announcements)
@pending_announcement = Announcement.last
end

# NOTE: remove when bootstrap migration is done (related to switch_to_webui2)
def set_webui2_views
prepend_view_path('app/views/webui2')
end
end
9 changes: 9 additions & 0 deletions src/api/app/helpers/webui/staging/project_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Webui::Staging::ProjectHelper
def icon_for_checks(checks, missing_checks)
return 'fa-eye text-info' if missing_checks.present?
return 'fa-check-circle text-primary' if checks.blank?
return 'fa-eye text-info' if checks.any?(&:pending?)
return 'fa-check-circle text-primary' if checks.all?(&:success?)
'fa-exclamation-circle text-danger'
end
end
24 changes: 24 additions & 0 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module Staging
class StagingProject < Project
has_many :staged_requests, class_name: 'BsRequest', foreign_key: :staging_project_id, dependent: :nullify
has_many :status_reports, through: :repositories, inverse_of: :checkable
has_many :checks, through: :status_reports
has_many :status_reports_for_architectures, source: :status_reports, through: :repository_architectures, inverse_of: :checkable
has_many :checks_for_architectures, through: :status_reports_for_architectures, source: :checks

belongs_to :staging_workflow, class_name: 'Staging::Workflow'

default_scope { where.not(staging_workflow: nil) }
Expand Down Expand Up @@ -100,6 +104,14 @@ def unassign_managers_group(managers)
relationships.find_by(group: managers, role: role).try(:destroy!)
end

def current_checks
relevant_checks + relevant_checks_for_architectures
end

def current_missing_checks
(relevant_status_reports + relevant_status_reports_for_architectures).map(&:missing_checks).flatten
end

private

def cache_problems
Expand Down Expand Up @@ -133,10 +145,22 @@ def build_state
:acceptable
end

def relevant_checks
@relevant_checks ||= checks.where(status_reports: { uuid: repositories.map(&:build_id) })
end

def relevant_checks_for_architectures
@relevant_checks_for_architectures ||= checks_for_architectures.where(status_reports: { uuid: repository_architectures.map(&:build_id) })
end

def relevant_status_reports
@relevant_status_reports ||= status_reports.where(uuid: repositories.map(&:build_id))
end

def relevant_status_reports_for_architectures
@relevant_status_reports_for_architectures ||= status_reports_for_architectures.where(uuid: repository_architectures.map(&:build_id))
end

def missing_checks?
relevant_status_reports.any? { |report| report.missing_checks.present? }
end
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/status/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def pending?
state == 'pending'
end

def success?
state == 'success'
end

def failed?
%w[error failure].include?(state)
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/views/webui2/webui/project/_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
= tab_link('Users', project_users_path(project))
// This link is intentionally hidden, only users that access to the staging workflow show will see it
// TODO: show it if the project have a staging_workflow attached when this feature will be released
- if controller_name == 'staging_workflows'
- if controller_path.starts_with?('webui/staging/')
%li.nav-item
= tab_link('Staging', request.url, controller_name == 'staging_workflows')
= tab_link('Staging', request.url, true)
- unless project.defines_remote_instance? || project.is_maintenance?
%li.nav-item
= tab_link('Subprojects', project_subprojects_path(project))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= render partial: 'webui/staging/workflows/breadcrumb_items'
- if controller_name == 'projects' && action_name == 'show'
%li.breadcrumb-item.active{ 'aria-current' => 'page' }
= @staging_project.name
16 changes: 16 additions & 0 deletions src/api/app/views/webui2/webui/staging/projects/_checks.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%td.p-2.w-25.font-weight-bold
%i.mr-2.fas{ class: icon_for_checks(checks, missing_checks) }
Checks
%td.p-2
- if checks.blank? && missing_checks.blank?
None
- else
%ul
- missing_checks.each do |name|
%li
%span.check-pending
#{name} (Expected - Waiting for status to be reported)
- checks.each do |check|
%li
= link_to "#{check.name} (#{check.state} - #{time_ago_in_words(check.updated_at)} ago)", check.url,
class: "check-#{check.state}", title: "#{check.short_description} (#{check.updated_at})"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%td.p-2.w-25.font-weight-bold
%i.mr-2.fas{ class: items.empty? ? 'fa-check-circle text-primary' : 'fa-exclamation-triangle text-warning' }
= type.humanize
%td.p-2
- if items.empty?
None
- else
- items.each_with_index do |item, index|
= succeed "#{',' if index < items.size - 1}" do
:ruby
case type
when 'untracked_requests', 'obsolete_requests'
link_to("##{item.number} (#{item.state})", request_show_path(item.number))
when 'missing_reviews'
link_to("#{item[:package]} by #{item[:by]}", request_show_path(item[:request]))
when 'building_repositories'
link_to("#{item['repository']}-#{item['arch']} (#{item['state']})",
project_repository_state_path(project: @staging_project.name, repository: item['repository']))
when 'broken_packages'
link_to("#{item[:package]} (#{item[:state]})", package_show_path(project: item[:project], package: item[:package]))
end
37 changes: 37 additions & 0 deletions src/api/app/views/webui2/webui/staging/projects/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- @pagetitle = @staging_project.name

.row
.col-xl-10
.card.mb-3
= render(partial: 'webui2/webui/project/tabs', locals: { project: @staging_project })
.card-body
%h3= @pagetitle
%h4.mt-4 Packages
.requests#staging-project-package-list
= render partial: 'webui/staging/shared/packages_list', locals: { staging_project: @staging_project }
.card.mb-3
%h5.card-header Status
.card-body
%table.table.table-striped.table-borderless.table-sm.dt-responsive.w-100
%tbody
%tr
= render partial: 'status_items',
locals: { staging_project: @staging_project, items: @staging_project.untracked_requests, type: 'untracked_requests' }
%tr
= render partial: 'status_items',
locals: { staging_project: @staging_project, items: @staging_project.staged_requests.obsolete, type: 'obsolete_requests' }
%tr
= render partial: 'status_items',
locals: { staging_project: @staging_project, items: @staging_project.missing_reviews, type: 'missing_reviews' }
%tr
= render partial: 'status_items',
locals: { staging_project: @staging_project, items: @staging_project.building_repositories, type: 'building_repositories' }
%tr
= render partial: 'status_items',
locals: { staging_project: @staging_project, items: @staging_project.broken_packages, type: 'broken_packages' }
%tr
= render partial: 'checks',
locals: { checks: @staging_project.current_checks,
missing_checks: @staging_project.current_missing_checks }
.col-xl-2
= render partial: 'webui/staging/shared/legend'
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
%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))
= link_to(staging_project.staging_identifier, staging_workflow_staging_project_path(staging_workflow, staging_project.name))
%span
%br
= staging_project.overall_state
Expand Down

0 comments on commit 15442d7

Please sign in to comment.