From 584e6a16847ae1d44984c35826c3f5a9924641db Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 6 Dec 2024 17:00:24 +0100 Subject: [PATCH] Rename involvement filter to direction Requests come in or go out. --- .../controllers/concerns/webui/requests_filter.rb | 12 ++++++------ .../webui/packages/bs_requests_controller.rb | 4 ++-- .../webui/projects/bs_requests_controller.rb | 4 ++-- .../webui/users/bs_requests_controller.rb | 4 ++-- src/api/app/views/layouts/webui/_places.html.haml | 2 +- .../shared/bs_requests/_requests_filter.html.haml | 12 ++++++------ 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/api/app/controllers/concerns/webui/requests_filter.rb b/src/api/app/controllers/concerns/webui/requests_filter.rb index b48fe6ef2a6..f1418602d82 100644 --- a/src/api/app/controllers/concerns/webui/requests_filter.rb +++ b/src/api/app/controllers/concerns/webui/requests_filter.rb @@ -1,7 +1,7 @@ module Webui::RequestsFilter extend ActiveSupport::Concern - ALLOWED_INVOLVEMENTS = %w[all incoming outgoing].freeze + ALLOWED_DIRECTIONS = %w[all incoming outgoing].freeze TEXT_SEARCH_MAX_RESULTS = 10_000 def filter_requests @@ -9,9 +9,9 @@ def filter_requests if params[:requests_search_text].present? initial_bs_requests = filter_by_text(params[:requests_search_text]) - params[:ids] = filter_by_involvement(@filter_involvement).ids + params[:ids] = filter_by_direction(@filter_direction).ids else - initial_bs_requests = filter_by_involvement(@filter_involvement) + initial_bs_requests = filter_by_direction(@filter_direction) end params[:creator] = @filter_creators if @filter_creators.present? @@ -23,8 +23,8 @@ def filter_requests end def set_filters - @filter_involvement = params[:involvement].presence || 'all' - @filter_involvement = 'all' if ALLOWED_INVOLVEMENTS.exclude?(@filter_involvement) + @filter_direction = params[:direction].presence || 'all' + @filter_direction = 'all' if ALLOWED_DIRECTIONS.exclude?(@filter_direction) @filter_state = params[:state].presence || [] @filter_state = @filter_state.intersection(BsRequest::VALID_REQUEST_STATES.map(&:to_s)) @@ -36,7 +36,7 @@ def set_filters end def set_selected_filter - @selected_filter = { involvement: @filter_involvement, action_type: @filter_action_type, search_text: params[:requests_search_text], + @selected_filter = { direction: @filter_direction, action_type: @filter_action_type, search_text: params[:requests_search_text], state: @filter_state, creators: @filter_creators } end diff --git a/src/api/app/controllers/webui/packages/bs_requests_controller.rb b/src/api/app/controllers/webui/packages/bs_requests_controller.rb index bba7508fb84..2411f743b0c 100644 --- a/src/api/app/controllers/webui/packages/bs_requests_controller.rb +++ b/src/api/app/controllers/webui/packages/bs_requests_controller.rb @@ -26,10 +26,10 @@ def index private - def filter_by_involvement(filter_by_involvement) + def filter_by_direction(direction) target = BsRequest.with_actions.where(bs_request_actions: { target_project: @project.name, target_package: @package.name }) source = BsRequest.with_actions.where(bs_request_actions: { source_project: @project.name, source_package: @package.name }) - case filter_by_involvement + case direction when 'all' target.or(source) when 'incoming' diff --git a/src/api/app/controllers/webui/projects/bs_requests_controller.rb b/src/api/app/controllers/webui/projects/bs_requests_controller.rb index 47f59b01bc6..529140bc926 100644 --- a/src/api/app/controllers/webui/projects/bs_requests_controller.rb +++ b/src/api/app/controllers/webui/projects/bs_requests_controller.rb @@ -25,10 +25,10 @@ def index private - def filter_by_involvement(filter_by_involvement) + def filter_by_direction(direction) target = BsRequest.with_actions.where(bs_request_actions: { target_project: @project.name }) source = BsRequest.with_actions.where(bs_request_actions: { source_project: @project.name }) - case filter_by_involvement + case direction when 'all' target.or(source) when 'incoming' diff --git a/src/api/app/controllers/webui/users/bs_requests_controller.rb b/src/api/app/controllers/webui/users/bs_requests_controller.rb index 0feeaab4d8d..724e6532c1c 100644 --- a/src/api/app/controllers/webui/users/bs_requests_controller.rb +++ b/src/api/app/controllers/webui/users/bs_requests_controller.rb @@ -30,8 +30,8 @@ def index private - def filter_by_involvement(filter_involvement) - case filter_involvement + def filter_by_direction(direction) + case direction when 'all' User.session.requests when 'incoming' diff --git a/src/api/app/views/layouts/webui/_places.html.haml b/src/api/app/views/layouts/webui/_places.html.haml index eb54e07becf..dff2514f588 100644 --- a/src/api/app/views/layouts/webui/_places.html.haml +++ b/src/api/app/views/layouts/webui/_places.html.haml @@ -10,7 +10,7 @@ Profile - if Flipper.enabled?(:request_index, User.session) %li.nav-item - = link_to(my_requests_path(involvement: 'incoming', state: %w[new review]), class: 'nav-link', title: 'Requests') do + = link_to(my_requests_path(direction: 'incoming', state: %w[new review]), class: 'nav-link', title: 'Requests') do %i.fas.fa-code-pull-request.fa-lg.me-2 %span.nav-item-name Requests - else diff --git a/src/api/app/views/webui/shared/bs_requests/_requests_filter.html.haml b/src/api/app/views/webui/shared/bs_requests/_requests_filter.html.haml index 9c5e5b24954..c6f0e5b3964 100644 --- a/src/api/app/views/webui/shared/bs_requests/_requests_filter.html.haml +++ b/src/api/app/views/webui/shared/bs_requests/_requests_filter.html.haml @@ -1,14 +1,14 @@ .mt-3.mb-2 .px-4 = render partial: 'webui/shared/radio_button', locals: { label: 'All', - key: 'involvement[all]', name: 'involvement', value: 'all', - checked: selected_filter[:involvement] == 'all' } + key: 'direction[all]', name: 'direction', value: 'all', + checked: selected_filter[:direction] == 'all' } = render partial: 'webui/shared/radio_button', locals: { label: 'Incoming', - key: 'involvement[incoming]', name: 'involvement', value: 'incoming', - checked: selected_filter[:involvement] == 'incoming' } + key: 'direction[incoming]', name: 'direction', value: 'incoming', + checked: selected_filter[:direction] == 'incoming' } = render partial: 'webui/shared/radio_button', locals: { label: 'Outgoing', - key: 'involvement[outgoing]', name: 'involvement', value: 'outgoing', - checked: selected_filter[:involvement] == 'outgoing' } + key: 'direction[outgoing]', name: 'direction', value: 'outgoing', + checked: selected_filter[:direction] == 'outgoing' } .mt-4.mb-4 %h6.px-3.py-2 %b State