From 8f7fb2846487e155ad1ebdd5e795a179aa9b83b7 Mon Sep 17 00:00:00 2001 From: ncounter Date: Thu, 30 Oct 2025 16:15:40 +0100 Subject: [PATCH 1/5] Request show page and summary index to use different components --- ...st_summary_description_component.html.haml | 39 +++++++ ...s_request_summary_description_component.rb | 107 ++++++++++++++++++ .../bs_requests/_request_item.html.haml | 2 +- ...t_summary_description_component_preview.rb | 22 ++++ 4 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 src/api/app/components/bs_request_summary_description_component.html.haml create mode 100644 src/api/app/components/bs_request_summary_description_component.rb create mode 100644 src/api/spec/components/previews/bs_request_summary_description_component_preview.rb diff --git a/src/api/app/components/bs_request_summary_description_component.html.haml b/src/api/app/components/bs_request_summary_description_component.html.haml new file mode 100644 index 00000000000..285e0974c29 --- /dev/null +++ b/src/api/app/components/bs_request_summary_description_component.html.haml @@ -0,0 +1,39 @@ +- action_descriptions = types.map do |type, actions| + - capture do + - case type + - when 'submit' + Submit + = source_container(actions) + %i.fas.fa-long-arrow-alt-right.text-info.mx-2 + = target_container(actions) + - when 'delete' + Delete + = sanitize(delete_target(actions)) + - when 'add_role', 'set_bugowner' + Assign + = sanitize(role_target(actions)) + for + = target_container(actions) + - when 'change_devel' + Set + = source_container(actions) + to be + %b devel + project/package of + = target_container(actions) + - when 'maintenance_incident' + Submit update from + = source_container(actions) + %i.fas.fa-long-arrow-alt-right.text-info.mx-2 + = target_container(actions) + - when 'maintenance_release' + Maintenance release + = source_container(actions) + %i.fas.fa-long-arrow-alt-right.text-info.mx-2 + = target_container(actions) + - when 'release' + Release + = source_container(actions) + %i.fas.fa-long-arrow-alt-right.text-info.mx-2 + = target_container(actions) += to_sentence(action_descriptions) diff --git a/src/api/app/components/bs_request_summary_description_component.rb b/src/api/app/components/bs_request_summary_description_component.rb new file mode 100644 index 00000000000..596ef3e4481 --- /dev/null +++ b/src/api/app/components/bs_request_summary_description_component.rb @@ -0,0 +1,107 @@ +# This component renders the request description based on the type of the actions + +class BsRequestSummaryDescriptionComponent < ApplicationComponent + attr_reader :bs_request, :types + + 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(bs_request:) + super() + @bs_request = bs_request + @types = bs_request.bs_request_actions.group_by(&:type) + end + + private + + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + def source_container(actions) + source_packages = actions.map { |a| [a.source_project, a.source_package] }.uniq.map { |pr, pk| highlight_package(pr, pk) } + packages_count = source_packages.count + source_packages = shorten_list(source_packages) + source_projects = actions.map(&:source_project).uniq.map { |a| highlight_project(a) } + source_projects = shorten_list(source_projects) + container = if actions.length == 1 && source_packages.length == 1 + "package #{source_projects.first} / #{source_packages.first}" + elsif source_packages + "#{'package'.pluralize(source_packages.count)} #{to_sentence(source_packages)} from #{'project'.pluralize(source_projects.count)} #{to_sentence(source_projects)}" + else + "#{'project'.pluralize(source_projects.count)} #{to_sentence(source_projects)}" + end + return tag.span(sanitize(container)) if packages_count <= 3 + + tag.span(sanitize(container), data: { bs_toggle: 'popover', bs_content: to_sentence(actions.map { |a| "#{a.source_project} / #{a.source_package}" }.uniq) }) + end + + def target_container(actions) + target_projects = actions.map(&:target_project).uniq.map { |a| highlight_project(a) } + target_projects = shorten_list(target_projects) + container = if actions.length == 1 && actions.first.target_package + "package #{highlight_project(actions.first.target_project)} / #{highlight_package(actions.first.target_project, actions.first.target_package)}" + elsif actions.any?(&:target_package) + "#{'package'.pluralize(actions.filter_map(&:target_package).uniq.count)} in #{'project'.pluralize(target_projects.count)} #{to_sentence(target_projects)}" + else + "#{'project'.pluralize(target_projects.count)} #{to_sentence(target_projects)}" + end + return tag.span(sanitize(container)) if actions.filter_map { |a| [a.target_project, a.target_package] }.uniq.count <= 1 + + tag.span(sanitize(container), data: { bs_toggle: 'popover', bs_content: to_sentence(actions.map { |a| "#{a.target_project} / #{a.target_package}" }.uniq) }) + end + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity + + def delete_target(actions) + target = actions.map do |a| + string = '' + string += "repository #{tag.b(a.target_repository)} for " if a.target_repository + string += a.target_package ? 'package ' : 'project ' + string += "#{highlight_project(a.target_project)} " + string += "/ #{highlight_package(a.target_project, a.target_package)}" if a.target_package + string + end + target.to_sentence + end + + def role_target(actions) + target = actions.map do |a| + "#{a.person_name ? 'user' : 'group'} #{highlight_user(a.person_name)} #{highlight_group(a.group_name)} as #{a.type == 'set_bugowner' ? "the #{tag.b('bugowner')}" : "a #{tag.b(a.role)}"}" + end + shorten_list(target).to_sentence + end + + def highlight_project(project) + return unless project + + link_to(project, project_show_path(project)) + end + + def highlight_package(project, package) + return unless project && package + + link_to(package, package_show_path(project, package)) + end + + def highlight_user(user) + return unless user + + link_to(user, user_path(user)) + end + + def highlight_group(group) + return unless group + + link_to(group, group_path(group)) + end + + def shorten_list(array, limit = 3) + if array.count > limit + total = array.count - (limit - 1) + array = array.take(limit - 1) + array << "#{total} #{'other'.pluralize(total)}" + end + array + end +end diff --git a/src/api/app/views/webui/shared/bs_requests/_request_item.html.haml b/src/api/app/views/webui/shared/bs_requests/_request_item.html.haml index 5c27f0b63a2..16d019073e4 100644 --- a/src/api/app/views/webui/shared/bs_requests/_request_item.html.haml +++ b/src/api/app/views/webui/shared/bs_requests/_request_item.html.haml @@ -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 diff --git a/src/api/spec/components/previews/bs_request_summary_description_component_preview.rb b/src/api/spec/components/previews/bs_request_summary_description_component_preview.rb new file mode 100644 index 00000000000..382ef3bd928 --- /dev/null +++ b/src/api/spec/components/previews/bs_request_summary_description_component_preview.rb @@ -0,0 +1,22 @@ +class BsRequestSummaryDescriptionComponentPreview < ViewComponent::Preview + # Previews at http://HOST:PORT/rails/view_components/bs_request_description_component + def submit_preview + bs_request = BsRequestAction.where(type: :submit).last.bs_request + render(BsRequestSummaryDescriptionComponent.new(bs_request: bs_request)) + end + + def delete_preview + bs_request = BsRequestAction.where(type: :delete).last.bs_request + render(BsRequestSummaryDescriptionComponent.new(bs_request: bs_request)) + end + + def add_role_preview + bs_request = BsRequestAction.where(type: :add_role).last.bs_request + render(BsRequestSummaryDescriptionComponent.new(bs_request: bs_request)) + end + + def change_devel_preview + bs_request = BsRequestAction.where(type: :change_devel).last.bs_request + render(BsRequestSummaryDescriptionComponent.new(bs_request: bs_request)) + end +end From e92cdb38d84b744515ae7527a686c1e1d545e49f Mon Sep 17 00:00:00 2001 From: ncounter Date: Fri, 31 Oct 2025 10:47:00 +0100 Subject: [PATCH 2/5] Drop stale optional parameter condition --- ...bs_request_action_description_component.rb | 19 ++++-------- ...quest_action_description_component_spec.rb | 14 ++++----- ...st_action_description_component_preview.rb | 31 +++++-------------- 3 files changed, 21 insertions(+), 43 deletions(-) diff --git a/src/api/app/components/bs_request_action_description_component.rb b/src/api/app/components/bs_request_action_description_component.rb index 8b5e3758864..af5151ef938 100644 --- a/src/api/app/components/bs_request_action_description_component.rb +++ b/src/api/app/components/bs_request_action_description_component.rb @@ -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 @@ -24,14 +23,8 @@ 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) @@ -39,14 +32,14 @@ def description 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 diff --git a/src/api/spec/components/bs_request_action_description_component_spec.rb b/src/api/spec/components/bs_request_action_description_component_spec.rb index 15a610af93b..d00c22cd8e4 100644 --- a/src/api/spec/components/bs_request_action_description_component_spec.rb +++ b/src/api/spec/components/bs_request_action_description_component_spec.rb @@ -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') @@ -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') @@ -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 @@ -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 @@ -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 @@ -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 @@ -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') diff --git a/src/api/spec/components/previews/bs_request_action_description_component_preview.rb b/src/api/spec/components/previews/bs_request_action_description_component_preview.rb index f8969785789..da89a4248a6 100644 --- a/src/api/spec/components/previews/bs_request_action_description_component_preview.rb +++ b/src/api/spec/components/previews/bs_request_action_description_component_preview.rb @@ -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 From ea989ff1ab8dd45f163643328dc9c30f777469e1 Mon Sep 17 00:00:00 2001 From: ncounter Date: Fri, 31 Oct 2025 10:48:41 +0100 Subject: [PATCH 3/5] Request show page to list a summary of all action In case of multiple actions, show each action description provided by the proper existing BsRequestActionDescriptionComponent in an accordion behavior grouped by action type In case of a single action, just present the action description --- .../assets/stylesheets/webui/requests.scss | 11 +++ ...bs_request_description_component.html.haml | 61 +++++------- .../bs_request_description_component.rb | 96 +------------------ 3 files changed, 37 insertions(+), 131 deletions(-) diff --git a/src/api/app/assets/stylesheets/webui/requests.scss b/src/api/app/assets/stylesheets/webui/requests.scss index 04a228a56eb..75ad58100ce 100644 --- a/src/api/app/assets/stylesheets/webui/requests.scss +++ b/src/api/app/assets/stylesheets/webui/requests.scss @@ -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; diff --git a/src/api/app/components/bs_request_description_component.html.haml b/src/api/app/components/bs_request_description_component.html.haml index 285e0974c29..bda9d17ea87 100644 --- a/src/api/app/components/bs_request_description_component.html.haml +++ b/src/api/app/components/bs_request_description_component.html.haml @@ -1,39 +1,22 @@ -- action_descriptions = types.map do |type, actions| - - capture do - - case type - - when 'submit' - Submit - = source_container(actions) - %i.fas.fa-long-arrow-alt-right.text-info.mx-2 - = target_container(actions) - - when 'delete' - Delete - = sanitize(delete_target(actions)) - - when 'add_role', 'set_bugowner' - Assign - = sanitize(role_target(actions)) - for - = target_container(actions) - - when 'change_devel' - Set - = source_container(actions) - to be - %b devel - project/package of - = target_container(actions) - - when 'maintenance_incident' - Submit update from - = source_container(actions) - %i.fas.fa-long-arrow-alt-right.text-info.mx-2 - = target_container(actions) - - when 'maintenance_release' - Maintenance release - = source_container(actions) - %i.fas.fa-long-arrow-alt-right.text-info.mx-2 - = target_container(actions) - - when 'release' - Release - = source_container(actions) - %i.fas.fa-long-arrow-alt-right.text-info.mx-2 - = target_container(actions) -= to_sentence(action_descriptions) +- 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) diff --git a/src/api/app/components/bs_request_description_component.rb b/src/api/app/components/bs_request_description_component.rb index b9162a7e53f..e8b55bb1ee5 100644 --- a/src/api/app/components/bs_request_description_component.rb +++ b/src/api/app/components/bs_request_description_component.rb @@ -3,105 +3,17 @@ class BsRequestDescriptionComponent < ApplicationComponent attr_reader :bs_request, :types - 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(bs_request:) super() @bs_request = bs_request @types = bs_request.bs_request_actions.group_by(&:type) end - private - - # rubocop:disable Metrics/CyclomaticComplexity - # rubocop:disable Metrics/PerceivedComplexity - def source_container(actions) - source_packages = actions.map { |a| [a.source_project, a.source_package] }.uniq.map { |pr, pk| highlight_package(pr, pk) } - packages_count = source_packages.count - source_packages = shorten_list(source_packages) - source_projects = actions.map(&:source_project).uniq.map { |a| highlight_project(a) } - source_projects = shorten_list(source_projects) - container = if actions.length == 1 && source_packages.length == 1 - "package #{source_projects.first} / #{source_packages.first}" - elsif source_packages - "#{'package'.pluralize(source_packages.count)} #{to_sentence(source_packages)} from #{'project'.pluralize(source_projects.count)} #{to_sentence(source_projects)}" - else - "#{'project'.pluralize(source_projects.count)} #{to_sentence(source_projects)}" - end - return tag.span(sanitize(container)) if packages_count <= 3 - - tag.span(sanitize(container), data: { bs_toggle: 'popover', bs_content: to_sentence(actions.map { |a| "#{a.source_project} / #{a.source_package}" }.uniq) }) - end - - def target_container(actions) - target_projects = actions.map(&:target_project).uniq.map { |a| highlight_project(a) } - target_projects = shorten_list(target_projects) - container = if actions.length == 1 && actions.first.target_package - "package #{highlight_project(actions.first.target_project)} / #{highlight_package(actions.first.target_project, actions.first.target_package)}" - elsif actions.any?(&:target_package) - "#{'package'.pluralize(actions.filter_map(&:target_package).uniq.count)} in #{'project'.pluralize(target_projects.count)} #{to_sentence(target_projects)}" - else - "#{'project'.pluralize(target_projects.count)} #{to_sentence(target_projects)}" - end - return tag.span(sanitize(container)) if actions.filter_map { |a| [a.target_project, a.target_package] }.uniq.count <= 1 - - tag.span(sanitize(container), data: { bs_toggle: 'popover', bs_content: to_sentence(actions.map { |a| "#{a.target_project} / #{a.target_package}" }.uniq) }) - end - # rubocop:enable Metrics/CyclomaticComplexity - # rubocop:enable Metrics/PerceivedComplexity - - def delete_target(actions) - target = actions.map do |a| - string = '' - string += "repository #{tag.b(a.target_repository)} for " if a.target_repository - string += a.target_package ? 'package ' : 'project ' - string += "#{highlight_project(a.target_project)} " - string += "/ #{highlight_package(a.target_project, a.target_package)}" if a.target_package - string - end - target.to_sentence - end - - def role_target(actions) - target = actions.map do |a| - "#{a.person_name ? 'user' : 'group'} #{highlight_user(a.person_name)} #{highlight_group(a.group_name)} as #{a.type == 'set_bugowner' ? "the #{tag.b('bugowner')}" : "a #{tag.b(a.role)}"}" - end - shorten_list(target).to_sentence - end - - def highlight_project(project) - return unless project - - link_to(project, project_show_path(project)) - end - - def highlight_package(project, package) - return unless project && package - - link_to(package, package_show_path(project, package)) - end - - def highlight_user(user) - return unless user - - link_to(user, user_path(user)) - end - - def highlight_group(group) - return unless group - - link_to(group, group_path(group)) + def multiple_types? + types.many? end - def shorten_list(array, limit = 3) - if array.count > limit - total = array.count - (limit - 1) - array = array.take(limit - 1) - array << "#{total} #{'other'.pluralize(total)}" - end - array + def any_types_has_many_multiple_actions? + types.any? { |_type, actions| actions.count > 10 } end end From 75a4cdd897e1775d9a3d3708b0cf545f03868268 Mon Sep 17 00:00:00 2001 From: ncounter Date: Fri, 31 Oct 2025 14:34:22 +0100 Subject: [PATCH 4/5] Adapt specs --- src/api/spec/features/beta/webui/requests_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/spec/features/beta/webui/requests_spec.rb b/src/api/spec/features/beta/webui/requests_spec.rb index 1935272661a..c5fd21c6d1f 100644 --- a/src/api/spec/features/beta/webui/requests_spec.rb +++ b/src/api/spec/features/beta/webui/requests_spec.rb @@ -26,7 +26,7 @@ it 'can be submitted' do click_button('Request') - expect(page).to have_text("Assign user #{submitter.login} as a bugowner for project #{target_project}") + expect(page).to have_text("#{submitter.realname} (#{submitter.login}) wants to get the role bugowner for project #{target_project}") expect(page).to have_css('#description-text', text: 'I can fix bugs too.') expect(page).to have_css('.badge', text: 'new') expect(BsRequest.where(creator: submitter.login, description: 'I can fix bugs too.')).to exist From c7b408a05af09a3279f0146ede4c70c50807482f Mon Sep 17 00:00:00 2001 From: ncounter Date: Mon, 3 Nov 2025 10:12:40 +0100 Subject: [PATCH 5/5] List all request actions into a separated tab page --- ...=> bs_request_actions_component.html.haml} | 0 ...ent.rb => bs_request_actions_component.rb} | 2 +- .../controllers/webui/request_controller.rb | 21 ++++++++++++------- .../webui/request/_request_header.html.haml | 6 +----- .../webui/request/_request_tabs.html.haml | 3 +++ .../webui/request/request_actions.html.haml | 19 +++++++++++++++++ src/api/config/routes/webui.rb | 1 + ...> bs_request_actions_component_preview.rb} | 12 +++++------ 8 files changed, 44 insertions(+), 20 deletions(-) rename src/api/app/components/{bs_request_description_component.html.haml => bs_request_actions_component.html.haml} (100%) rename src/api/app/components/{bs_request_description_component.rb => bs_request_actions_component.rb} (87%) create mode 100644 src/api/app/views/webui/request/request_actions.html.haml rename src/api/spec/components/previews/{bs_request_description_component_preview.rb => bs_request_actions_component_preview.rb} (56%) diff --git a/src/api/app/components/bs_request_description_component.html.haml b/src/api/app/components/bs_request_actions_component.html.haml similarity index 100% rename from src/api/app/components/bs_request_description_component.html.haml rename to src/api/app/components/bs_request_actions_component.html.haml diff --git a/src/api/app/components/bs_request_description_component.rb b/src/api/app/components/bs_request_actions_component.rb similarity index 87% rename from src/api/app/components/bs_request_description_component.rb rename to src/api/app/components/bs_request_actions_component.rb index e8b55bb1ee5..bb97fb638c7 100644 --- a/src/api/app/components/bs_request_description_component.rb +++ b/src/api/app/components/bs_request_actions_component.rb @@ -1,6 +1,6 @@ # This component renders the request description based on the type of the actions -class BsRequestDescriptionComponent < ApplicationComponent +class BsRequestActionsComponent < ApplicationComponent attr_reader :bs_request, :types def initialize(bs_request:) diff --git a/src/api/app/controllers/webui/request_controller.rb b/src/api/app/controllers/webui/request_controller.rb index adc1b6394d7..c3f55bdc63e 100644 --- a/src/api/app/controllers/webui/request_controller.rb +++ b/src/api/app/controllers/webui/request_controller.rb @@ -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] @@ -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 diff --git a/src/api/app/views/webui/request/_request_header.html.haml b/src/api/app/views/webui/request/_request_header.html.haml index 965a2dbc05c..7bbfc8f5334 100644 --- a/src/api/app/views/webui/request/_request_header.html.haml +++ b/src/api/app/views/webui/request/_request_header.html.haml @@ -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) @@ -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 diff --git a/src/api/app/views/webui/request/_request_tabs.html.haml b/src/api/app/views/webui/request/_request_tabs.html.haml index c6f9b44d093..dd6a31deecd 100644 --- a/src/api/app/views/webui/request/_request_tabs.html.haml +++ b/src/api/app/views/webui/request/_request_tabs.html.haml @@ -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 diff --git a/src/api/app/views/webui/request/request_actions.html.haml b/src/api/app/views/webui/request/request_actions.html.haml new file mode 100644 index 00000000000..36dc2b07a55 --- /dev/null +++ b/src/api/app/views/webui/request/request_actions.html.haml @@ -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) diff --git a/src/api/config/routes/webui.rb b/src/api/config/routes/webui.rb index 31d0bc4582e..165bfbe1505 100644 --- a/src/api/config/routes/webui.rb +++ b/src/api/config/routes/webui.rb @@ -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 diff --git a/src/api/spec/components/previews/bs_request_description_component_preview.rb b/src/api/spec/components/previews/bs_request_actions_component_preview.rb similarity index 56% rename from src/api/spec/components/previews/bs_request_description_component_preview.rb rename to src/api/spec/components/previews/bs_request_actions_component_preview.rb index 32da5847ddd..9864501f3f8 100644 --- a/src/api/spec/components/previews/bs_request_description_component_preview.rb +++ b/src/api/spec/components/previews/bs_request_actions_component_preview.rb @@ -1,22 +1,22 @@ -class BsRequestDescriptionComponentPreview < ViewComponent::Preview - # Previews at http://HOST:PORT/rails/view_components/bs_request_description_component +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(BsRequestDescriptionComponent.new(bs_request: bs_request)) + render(BsRequestActionsComponent.new(bs_request: bs_request)) end def delete_preview bs_request = BsRequestAction.where(type: :delete).last.bs_request - render(BsRequestDescriptionComponent.new(bs_request: 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(BsRequestDescriptionComponent.new(bs_request: 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(BsRequestDescriptionComponent.new(bs_request: bs_request)) + render(BsRequestActionsComponent.new(bs_request: bs_request)) end end