Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/api/app/assets/stylesheets/webui/requests.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@
width: 35rem;
}

#request-actions-accordion {
.accordion-button {
background-color: var(--bs-tertiary-bg);
}

.request-actions-accordion-body {
max-height: 20rem;
overflow-y: scroll;
}
}

@include media-breakpoint-up(sm) {
.order-sm-1 {
order: 1;
Expand Down
19 changes: 6 additions & 13 deletions src/api/app/components/bs_request_action_description_component.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# This component renders the request action description based on the type of the action

class BsRequestActionDescriptionComponent < ApplicationComponent
attr_reader :action, :text_only
attr_reader :action

delegate :project_or_package_link, to: :helpers
delegate :user_with_realname_and_icon, to: :helpers
delegate :requester_str, to: :helpers
delegate :creator_intentions, to: :helpers

def initialize(action:, text_only: false)
def initialize(action:)
super()
@action = action
@text_only = text_only
end

# rubocop:disable Metrics/CyclomaticComplexity
Expand All @@ -24,29 +23,23 @@ def description
target_project_hash = { project: action.target_project, package: action.target_package, trim_to: nil }

source_and_target_component = BsRequestActionSourceAndTargetComponent.new(action.bs_request)

if text_only
source_container = source_and_target_component.source
target_container = source_and_target_component.target
else
source_container = project_or_package_link(source_project_hash)
target_container = project_or_package_link(target_project_hash)
end
source_container = project_or_package_link(source_project_hash)
target_container = project_or_package_link(target_project_hash)

source_and_target_container = source_and_target_component.combine(source_container, target_container)

description = case action.type
when 'submit'
'Submit %{source_and_target_container}' % { source_and_target_container: source_and_target_container }
when 'delete'
repository_content = text_only ? action.target_repository : link_to(action.target_repository, repositories_path(target_project_hash))
repository_content = link_to(action.target_repository, repositories_path(target_project_hash))
target_repository = "repository #{repository_content} for " if action.target_repository

'Delete %{target_repository}%{target_container}' %
{ target_repository: target_repository, target_container: target_container }
when 'add_role', 'set_bugowner'
'%{creator} wants %{requester} to %{task} for %{target_container}' % {
creator: text_only ? creator : user_with_realname_and_icon(creator),
creator: user_with_realname_and_icon(creator),
requester: requester_str(creator, action.person_name, action.group_name),
task: creator_intentions(action.role),
target_container: target_container
Expand Down
22 changes: 22 additions & 0 deletions src/api/app/components/bs_request_actions_component.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- if multiple_types? || any_types_has_many_multiple_actions?
.accordion#request-actions-accordion
- types.each_with_index do |(type, actions), index|
.accordion-item
.accordion-button{ class: index == 0 ? '' : 'collapsed',
data: { 'bs-toggle': 'collapse', 'bs-target': "#collapse-#{type}" },
aria: { 'expanded': index == 0, 'controls': "#collapse-#{type}" } }
%strong
= actions.count
= type.humanize.titleize
.accordion-collapse.collapse.ms-0{ class: index == 0 ? 'show' : '',
id: "collapse-#{type}",
'data-bs-parent': '#request-actions-accordion' }
.accordion-body.request-actions-accordion-body
- actions.each do |action|
.p-1
= render BsRequestActionDescriptionComponent.new(action: action)
- else
- types.map do |type, actions|
- actions.each do |action|
.pt-1
= render BsRequestActionDescriptionComponent.new(action: action)
19 changes: 19 additions & 0 deletions src/api/app/components/bs_request_actions_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This component renders the request description based on the type of the actions

class BsRequestActionsComponent < ApplicationComponent
attr_reader :bs_request, :types

def initialize(bs_request:)
super()
@bs_request = bs_request
@types = bs_request.bs_request_actions.group_by(&:type)
end

def multiple_types?
types.many?
end

def any_types_has_many_multiple_actions?
types.any? { |_type, actions| actions.count > 10 }
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This component renders the request description based on the type of the actions

class BsRequestDescriptionComponent < ApplicationComponent
class BsRequestSummaryDescriptionComponent < ApplicationComponent
attr_reader :bs_request, :types

delegate :project_or_package_link, to: :helpers
Expand Down
21 changes: 13 additions & 8 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@ class Webui::RequestController < Webui::WebuiController

before_action :require_login,
except: %i[show beta_show sourcediff diff request_action request_action_changes request_action_details inline_comment build_results
changes changes_diff mentioned_issues chart_build_results complete_build_results]
changes changes_diff mentioned_issues chart_build_results complete_build_results request_actions]
# requests do not really add much value for our page rank :)
before_action :lockout_spiders
before_action :require_request,
only: %i[changerequest show beta_show request_action request_action_changes request_action_details inline_comment build_results
changes changes_diff mentioned_issues chart_build_results complete_build_results]
before_action :set_actions, only: %i[inline_comment beta_show build_results changes changes_diff mentioned_issues chart_build_results complete_build_results request_action_changes request_action_details],
changes changes_diff mentioned_issues chart_build_results complete_build_results request_actions]
before_action :set_actions, only: %i[inline_comment beta_show build_results changes changes_diff mentioned_issues chart_build_results
complete_build_results request_action_changes request_action_details request_actions],
if: -> { Flipper.enabled?(:request_show_redesign, User.possibly_nobody) }
before_action :set_actions_deprecated, only: [:show]
before_action :set_action, only: %i[inline_comment beta_show build_results changes changes_diff mentioned_issues request_action_details request_action_changes],
if: -> { Flipper.enabled?(:request_show_redesign, User.possibly_nobody) }
before_action :set_influxdb_data_request_actions, only: %i[beta_show build_results changes changes_diff mentioned_issues],
before_action :set_influxdb_data_request_actions, only: %i[beta_show build_results changes changes_diff mentioned_issues request_actions],
if: -> { Flipper.enabled?(:request_show_redesign, User.possibly_nobody) }
before_action :set_superseded_request, only: %i[show beta_show request_action request_action_changes build_results changes changes_diff mentioned_issues]
before_action :set_superseded_request, only: %i[show beta_show request_action request_action_changes build_results changes changes_diff mentioned_issues request_actions]
before_action :check_ajax, only: :sourcediff
before_action :prepare_request_data, only: %i[beta_show build_results changes mentioned_issues],
before_action :prepare_request_data, only: %i[beta_show build_results changes mentioned_issues request_actions],
if: -> { Flipper.enabled?(:request_show_redesign, User.possibly_nobody) }
before_action :prepare_request_header_data, only: %i[beta_show build_results changes mentioned_issues],
before_action :prepare_request_header_data, only: %i[beta_show build_results changes mentioned_issues request_actions],
if: -> { Flipper.enabled?(:request_show_redesign, User.possibly_nobody) }
before_action :cache_diff_data, only: %i[changes request_action_changes],
if: -> { Flipper.enabled?(:request_show_redesign, User.possibly_nobody) }
before_action :check_beta_user_redirect, only: %i[beta_show build_results changes mentioned_issues changes_diff]
before_action :check_beta_user_redirect, only: %i[beta_show build_results changes mentioned_issues changes_diff request_actions]

after_action :verify_authorized, only: [:create]

Expand Down Expand Up @@ -331,6 +332,10 @@ def build_results
@buildable = @action.source_package || @project
end

def request_actions
@active_tab = 'actions'
end

def changes
@active_tab = 'changes'
end
Expand Down
6 changes: 1 addition & 5 deletions src/api/app/views/webui/request/_request_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
current_object: bs_request)

-# author + datetime + (if superseding -> "Superseds something")
.card-text.px-4.pb-4
.card-text.px-4
%p.fst-italic
Created by
= user_with_realname_and_icon(bs_request.creator)
Expand Down Expand Up @@ -70,10 +70,6 @@
This is a
%mark.text-light.bg-maintenance.text-nowrap.text Maintenance Release
request
.mt-4
%h5.mt-4
Actions
= render BsRequestDescriptionComponent.new(bs_request:)
- if Flipper.enabled?(:labels, User.session)
.mt-4
= render partial: 'webui/shared/label', collection: bs_request.labels, as: :label
Expand Down
3 changes: 3 additions & 0 deletions src/api/app/views/webui/request/_request_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
%li.nav-item.scrollable-tab-link.active
= link_to('Build Results', request_build_results_path(bs_request.number),
class: "nav-link text-nowrap #{active_tab == 'build_results' ? 'active' : ''}")
%li.nav-item.scrollable-tab-link
= link_to('Actions', request_actions_path(bs_request.number),
class: "nav-link text-nowrap #{active_tab == 'actions' ? 'active' : ''}")
%li.nav-item.scrollable-tab-link
= link_to(request_changes_path(bs_request.number, actions_count > 1 ? action : nil),
class: "nav-link text-nowrap #{active_tab == 'changes' ? 'active' : ''}") do
Expand Down
19 changes: 19 additions & 0 deletions src/api/app/views/webui/request/request_actions.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:ruby
@pagetitle = "Request #{@bs_request.number}: #{@action.name}"

.card
.card-body.p-0
= render partial: 'request_header',
locals: { bs_request: @bs_request, staging_status: @staging_status, action: @action,
prev_action: @prev_action, next_action: @next_action, actions: @actions,
diff_to_superseded_id: @diff_to_superseded_id, page_name: 'request_actions',
bs_requests: @watched_requests, packages: @watched_packages, projects: @watched_projects,
current_notification: @current_notification }
= render partial: 'request_tabs',
locals: { bs_request: @bs_request, action: @action, issues: @issues,
actions_count: @actions.count, active_tab: @active_tab }

.container.p-4
%h5
Actions
= render BsRequestActionsComponent.new(bs_request: @bs_request)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.mb-1
= render partial: 'webui/shared/label', collection: bs_request.labels, as: :label
.mb-1
= render BsRequestDescriptionComponent.new(bs_request:)
= render BsRequestSummaryDescriptionComponent.new(bs_request:)
.mb-2.request-index-description.text-truncate
= bs_request.description
.text-end
Expand Down
1 change: 1 addition & 0 deletions src/api/config/routes/webui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
# We can't apply the filename constraint, it prevents the use of `/` in file names.
get 'requests/:number/actions/:request_action_id/changes/*filename' => :changes_diff, as: 'request_changes_diff', format: false, constraints: cons.except(:filename)
get 'requests/:number/(actions/:request_action_id)/mentioned_issues' => :mentioned_issues, as: 'request_mentioned_issues', constraints: cons
get 'requests/:number/(actions/:request_action_id)/actions' => :request_actions, as: 'request_actions', constraints: cons
post 'request/sourcediff' => :sourcediff
post 'request/changerequest' => :changerequest
get 'request/diff/:number' => :diff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
end

it 'renders the "change_devel" previews' do
%i[change_devel change_devel_text_only].each do |preview_name|
%i[change_devel].each do |preview_name|
render_preview(preview_name)

expect(rendered_content).to have_text('be devel project/package of')
Expand All @@ -31,7 +31,7 @@
end

it 'renders the "delete" previews' do
%i[delete delete_text_only].each do |preview_name|
%i[delete].each do |preview_name|
render_preview(preview_name)

expect(rendered_content).to have_text('Delete')
Expand All @@ -45,7 +45,7 @@
end

it 'renders the "maintenance_incident" preview' do
render_preview('maintenance_incident_text_only')
render_preview('maintenance_incident')

expect(rendered_content).to have_text('Submit update from')
end
Expand All @@ -57,7 +57,7 @@
end

it 'renders the "maintenance_release" preview' do
render_preview('maintenance_release_text_only')
render_preview('maintenance_release')

expect(rendered_content).to have_text('Maintenance release')
end
Expand All @@ -69,7 +69,7 @@
end

it 'renders the "release" preview' do
render_preview('release_text_only')
render_preview('release')

expect(rendered_content).to have_text('Release')
end
Expand All @@ -81,7 +81,7 @@
end

it 'renders the "set_bugowner" preview' do
render_preview('set_bugowner_text_only')
render_preview('set_bugowner')

expect(rendered_content).to have_text('become bugowner')
end
Expand All @@ -93,7 +93,7 @@
end

it 'renders the "submit" previews' do
%i[submit submit_text_only].each do |preview_name|
%i[submit].each do |preview_name|
render_preview(preview_name)

expect(rendered_content).to have_text('Submit')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,33 @@ def change_devel
render(BsRequestActionDescriptionComponent.new(action: action))
end

def change_devel_text_only
action = BsRequestAction.where(type: :change_devel).last
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
end

def delete
action = BsRequestAction.where(type: :delete).last
render(BsRequestActionDescriptionComponent.new(action: action))
end

def delete_text_only
action = BsRequestAction.where(type: :delete).last
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
end

def maintenance_incident_text_only
def maintenance_incident
action = BsRequestAction.where(type: :maintenance_incident).last
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
render(BsRequestActionDescriptionComponent.new(action: action))
end

def maintenance_release_text_only
def maintenance_release
action = BsRequestAction.where(type: :maintenance_release).last
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
render(BsRequestActionDescriptionComponent.new(action: action))
end

def release_text_only
def release
action = BsRequestAction.where(type: :release).last
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
render(BsRequestActionDescriptionComponent.new(action: action))
end

def set_bugowner_text_only
def set_bugowner
action = BsRequestAction.where(type: :set_bugowner).last
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
render(BsRequestActionDescriptionComponent.new(action: action))
end

def submit
action = BsRequestAction.where(type: :submit).last
render(BsRequestActionDescriptionComponent.new(action: action))
end

def submit_text_only
action = BsRequestAction.where(type: :submit).last
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class BsRequestActionsComponentPreview < ViewComponent::Preview
# Previews at http://HOST:PORT/rails/view_components/bs_request_actions_component
def submit_preview
bs_request = BsRequestAction.where(type: :submit).last.bs_request
render(BsRequestActionsComponent.new(bs_request: bs_request))
end

def delete_preview
bs_request = BsRequestAction.where(type: :delete).last.bs_request
render(BsRequestActionsComponent.new(bs_request: bs_request))
end

def add_role_preview
bs_request = BsRequestAction.where(type: :add_role).last.bs_request
render(BsRequestActionsComponent.new(bs_request: bs_request))
end

def change_devel_preview
bs_request = BsRequestAction.where(type: :change_devel).last.bs_request
render(BsRequestActionsComponent.new(bs_request: bs_request))
end
end
Loading