Skip to content

Commit

Permalink
Add staging project show page
Browse files Browse the repository at this point in the history
Show staging project and its status and checks inside staging workflow.

Co-authored-by: David Kang <dkang@suse.com>
Co-authored-by: Eduardo Navarro <enavarro@suse.com>
Co-authored-by: Victor Pereira <vpereira@suse.com>
  • Loading branch information
4 people committed Nov 21, 2018
1 parent e69abf8 commit 9a93fbc
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 11 deletions.
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
12 changes: 12 additions & 0 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ def unassign_managers_group(managers)
relationships.find_by(group: managers, role: role).try(:destroy!)
end

def current_status_reports
repositories.map(&:current_status_report) + repository_architectures.map(&:current_status_report)
end

def all_checks
current_status_reports.map(&:checks).flatten
end

def all_missing_checks
current_status_reports.map(&:missing_checks).flatten
end

private

def cache_problems
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
35 changes: 35 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,35 @@
- @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
.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.all_checks,
missing_checks: @staging_project.all_missing_checks }
.col-xl-2
= render partial: 'webui/staging/shared/legend'
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
locals: { staging_workflow: @staging_workflow, staging_projects: @staging_projects, display_actions_column: false })

.col-xl-2
= render partial: 'legend'
= render partial: 'webui/staging/shared/legend'
= render partial: 'infos', locals: { staging_workflow: @staging_workflow, empty_projects: @empty_projects,
unassigned_requests: @unassigned_requests, more_unassigned_requests: @more_unassigned_requests,
ready_requests: @ready_requests, more_ready_requests: @more_ready_requests,
Expand Down
2 changes: 1 addition & 1 deletion src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def self.public_or_about_path?(request)
get 'published/' => 'source#index', via: :get

resources :staging_workflows, except: :index, controller: 'webui/staging/workflows', constraints: cons do
resources :staging_projects, only: [:create, :destroy], controller: 'webui/staging/projects', param: :project_name, constraints: cons
resources :staging_projects, only: [:create, :destroy, :show], controller: 'webui/staging/projects', param: :project_name, constraints: cons
resources :excluded_requests, controller: 'webui/staging/excluded_requests'
end

Expand Down

0 comments on commit 9a93fbc

Please sign in to comment.