From 56f247596b1000a597d79a704bace5392f87339b Mon Sep 17 00:00:00 2001 From: Lukas Krause Date: Thu, 28 Nov 2024 16:28:33 +0100 Subject: [PATCH] Redirect to the proper route if beta request_index enabled In order to refactor the request listing controller, and to move the logic to the appropriate bs_request_controller we first have to change the paths and redirect to the old one inside the controller. This enables us to do the changes in smaller chunks. Co-authored-by: Daniel Donisa Co-authored-by: Dario Leidi Co-authored-by: Lukas Krause Co-authored-by: Rubhan Azeem --- .../app/controllers/webui/project_controller.rb | 3 +-- .../webui/projects/bs_requests_controller.rb | 14 +++++++++----- .../webui/project/_breadcrumb_items.html.haml | 3 +++ src/api/app/views/webui/project/_tabs.html.haml | 5 ++++- .../project/side_links/_incident_project.html.haml | 2 ++ .../webui/project/side_links/_requests.html.haml | 2 ++ .../pulse/_pulse_list_requests_box.html.haml | 8 ++++++-- .../views/webui/staging/workflows/_infos.html.haml | 8 ++++++-- 8 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/api/app/controllers/webui/project_controller.rb b/src/api/app/controllers/webui/project_controller.rb index d40038a6991..d18dd6e45ab 100644 --- a/src/api/app/controllers/webui/project_controller.rb +++ b/src/api/app/controllers/webui/project_controller.rb @@ -222,9 +222,8 @@ def buildresult collapsed_repositories: params.fetch(:collapsedRepositories, {}) } end + # TODO: Remove this once request_index beta is rolled out def requests - redirect_to project_requests_beta_path(@project, involvement: 'incoming', state: %w[new review]) if Flipper.enabled?(:request_index, User.session) - @default_request_type = params[:type] if params[:type] @default_request_state = params[:state] if params[:state] end 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 674c3c38985..7599df722b0 100644 --- a/src/api/app/controllers/webui/projects/bs_requests_controller.rb +++ b/src/api/app/controllers/webui/projects/bs_requests_controller.rb @@ -4,12 +4,16 @@ class BsRequestsController < WebuiController before_action :set_project def index - parsed_params = BsRequest::DataTable::ParamsParserWithStateAndType.new(params).parsed_params - requests_query = BsRequest::DataTable::FindForProjectQuery.new(@project, parsed_params) - @requests_data_table = BsRequest::DataTable::Table.new(requests_query, params[:draw]) + if Flipper.enabled?(:request_index, User.session) + redirect_to project_requests_beta_path(@project, action_type: params[:action_type], state: params[:state]) + else + parsed_params = BsRequest::DataTable::ParamsParserWithStateAndType.new(params).parsed_params + requests_query = BsRequest::DataTable::FindForProjectQuery.new(@project, parsed_params) + @requests_data_table = BsRequest::DataTable::Table.new(requests_query, params[:draw]) - respond_to do |format| - format.json { render 'webui/shared/bs_requests/index' } + respond_to do |format| + format.json { render 'webui/shared/bs_requests/index' } + end end end end diff --git a/src/api/app/views/webui/project/_breadcrumb_items.html.haml b/src/api/app/views/webui/project/_breadcrumb_items.html.haml index e8558914e9a..a0043b4e0b8 100644 --- a/src/api/app/views/webui/project/_breadcrumb_items.html.haml +++ b/src/api/app/views/webui/project/_breadcrumb_items.html.haml @@ -17,6 +17,9 @@ - elsif current_page?(project_monitor_path(@project)) %li.breadcrumb-item.active{ 'aria-current' => 'page' } Monitor + - elsif current_page?(project_requests_beta_path(@project)) + %li.breadcrumb-item.active{ 'aria-current' => 'page' } + Requests - elsif current_page?(project_requests_path(@project)) %li.breadcrumb-item.active{ 'aria-current' => 'page' } Requests diff --git a/src/api/app/views/webui/project/_tabs.html.haml b/src/api/app/views/webui/project/_tabs.html.haml index 0eb7ebefb66..5b0e2c7ee4a 100644 --- a/src/api/app/views/webui/project/_tabs.html.haml +++ b/src/api/app/views/webui/project/_tabs.html.haml @@ -10,7 +10,10 @@ - unless project.defines_remote_instance? || project.is_maintenance? = tab_link('Repositories', repositories_path(project), 'scrollable-tab-link') = tab_link('Monitor', project_monitor_path(project), 'scrollable-tab-link') - = tab_link('Requests', project_requests_path(project), 'scrollable-tab-link', active: controller_name == 'requests_listing') + - if Flipper.enabled?(:request_index, User.session) + = tab_link('Requests', projects_requests_path(project), 'scrollable-tab-link', active: controller_name == 'requests_listing') + - else + = tab_link('Requests', project_requests_path(project), 'scrollable-tab-link', active: controller_name == 'requests_listing') - unless project.defines_remote_instance? = tab_link('Users', project_users_path(project), 'scrollable-tab-link') - unless project.defines_remote_instance? || project.is_maintenance? diff --git a/src/api/app/views/webui/project/side_links/_incident_project.html.haml b/src/api/app/views/webui/project/side_links/_incident_project.html.haml index d92760d3c66..b42e7ca27dd 100644 --- a/src/api/app/views/webui/project/side_links/_incident_project.html.haml +++ b/src/api/app/views/webui/project/side_links/_incident_project.html.haml @@ -8,6 +8,8 @@ :ruby path = if open_release_requests.length == 1 request_show_path(open_release_requests.first) + elsif Flipper.enabled?(:request_index, User.session) + projects_requests_path(project, action_type: ['maintenance_release']) else project_requests_path(project, type: 'maintenance_release') end diff --git a/src/api/app/views/webui/project/side_links/_requests.html.haml b/src/api/app/views/webui/project/side_links/_requests.html.haml index 53b8417a86c..1a4d86f24b6 100644 --- a/src/api/app/views/webui/project/side_links/_requests.html.haml +++ b/src/api/app/views/webui/project/side_links/_requests.html.haml @@ -4,6 +4,8 @@ request_show_path(requests.first) elsif package package_requests_path(project, package) + elsif Flipper.enabled?(:request_index, User.session) + projects_requests_path(project) else project_requests_path(project) end diff --git a/src/api/app/views/webui/projects/pulse/_pulse_list_requests_box.html.haml b/src/api/app/views/webui/projects/pulse/_pulse_list_requests_box.html.haml index 9171c556ae4..7ecdf6b7694 100644 --- a/src/api/app/views/webui/projects/pulse/_pulse_list_requests_box.html.haml +++ b/src/api/app/views/webui/projects/pulse/_pulse_list_requests_box.html.haml @@ -27,5 +27,9 @@ %br in #{state} - else - = link_to(project_requests_path(project)) do - No requests have been sent to this project. + - if Flipper.enabled?(:request_index, User.session) + = link_to(projects_requests_path(project)) do + No requests have been sent to this project. + - else + = link_to(project_requests_path(project)) do + No requests have been sent to this project. diff --git a/src/api/app/views/webui/staging/workflows/_infos.html.haml b/src/api/app/views/webui/staging/workflows/_infos.html.haml index ca0f9f3b421..40f4b9f08e6 100644 --- a/src/api/app/views/webui/staging/workflows/_infos.html.haml +++ b/src/api/app/views/webui/staging/workflows/_infos.html.haml @@ -13,8 +13,12 @@ %dt= link_to('Backlog:', group_path(staging_workflow.managers_group, anchor: 'reviews-in')) %dd= render 'requests_list', requests: unassigned_requests, more_requests: more_unassigned_requests - %dt= link_to('Ready:', project_requests_path(staging_workflow.project, state: :new)) - %dd= render 'requests_list', requests: ready_requests, more_requests: more_ready_requests + - if Flipper.enabled?(:request_index, User.session) + %dt= link_to('Ready:', projects_requests_path(staging_workflow.project, state: ['new'])) + %dd= render 'requests_list', requests: ready_requests, more_requests: more_ready_requests + - else + %dt= link_to('Ready:', project_requests_path(staging_workflow.project, state: :new)) + %dd= render 'requests_list', requests: ready_requests, more_requests: more_ready_requests %dt= link_to('Excluded:', excluded_requests_path(staging_workflow.project)) %dd= render 'requests_list', requests: excluded_requests, more_requests: more_excluded_requests, excluded: true