Skip to content

Commit

Permalink
Merge pull request #17184 from hennevogel/refactoring/request-control…
Browse files Browse the repository at this point in the history
…lers

Rename involvement filter to direction
  • Loading branch information
krauselukas authored Dec 9, 2024
2 parents 372b3c9 + 584e6a1 commit 33fdfb0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/api/app/controllers/concerns/webui/requests_filter.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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
set_filters

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?
Expand All @@ -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))
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/users/bs_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,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'
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/layouts/webui/_places.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 33fdfb0

Please sign in to comment.