Skip to content

Commit

Permalink
Deduplicate action and bs_request_action
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Mar 22, 2024
1 parent 6a46199 commit 45ad4ec
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 22 deletions.
20 changes: 7 additions & 13 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ class Webui::RequestController < Webui::WebuiController
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_action_id, only: %i[inline_comment show build_results rpm_lint changes mentioned_issues],
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_bs_request_action, only: %i[show build_results rpm_lint changes mentioned_issues],
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_influxdb_data_request_actions, only: %i[show build_results rpm_lint changes mentioned_issues],
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_action, only: %i[inline_comment show build_results rpm_lint changes mentioned_issues],
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_influxdb_data_request_actions, only: %i[show build_results rpm_lint changes mentioned_issues],
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_superseded_request, only: %i[show request_action request_action_changes build_results rpm_lint changes mentioned_issues]
before_action :check_ajax, only: :sourcediff
before_action :prepare_request_data, only: %i[show build_results rpm_lint changes mentioned_issues],
Expand Down Expand Up @@ -281,15 +279,15 @@ def inline_comment
end

def build_results
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.build
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @action.tab_visibility.build

Check warning on line 282 in src/api/app/controllers/webui/request_controller.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/controllers/webui/request_controller.rb#L282

Added line #L282 was not covered by tests

@active_tab = 'build_results'
@project = @staging_project || @action.source_project
@buildable = @action.source_package || @project
end

def rpm_lint
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.rpm_lint
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @action.tab_visibility.rpm_lint

Check warning on line 290 in src/api/app/controllers/webui/request_controller.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/controllers/webui/request_controller.rb#L290

Added line #L290 was not covered by tests

@active_tab = 'rpm_lint'
@ajax_data = {}
Expand All @@ -299,13 +297,13 @@ def rpm_lint
end

def changes
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.changes
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @action.tab_visibility.changes

Check warning on line 300 in src/api/app/controllers/webui/request_controller.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/controllers/webui/request_controller.rb#L300

Added line #L300 was not covered by tests

@active_tab = 'changes'
end

def mentioned_issues
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.issues
redirect_to request_show_path(params[:number], params[:request_action_id]) unless @action.tab_visibility.issues

Check warning on line 306 in src/api/app/controllers/webui/request_controller.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/controllers/webui/request_controller.rb#L306

Added line #L306 was not covered by tests

@active_tab = 'mentioned_issues'
end
Expand Down Expand Up @@ -485,10 +483,6 @@ def set_action_id
@action_id = params[:request_action_id] || @supported_actions.first&.id || @actions.first.id
end

def set_bs_request_action
@bs_request_action = @bs_request.bs_request_actions.find(@action_id)
end

def set_action
@action = @actions.find(@action_id)

Check warning on line 487 in src/api/app/controllers/webui/request_controller.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/controllers/webui/request_controller.rb#L487

Added line #L487 was not covered by tests
end
Expand Down Expand Up @@ -562,7 +556,7 @@ def prepare_request_data

def set_influxdb_data_request_actions
InfluxDB::Rails.current.tags = {
bs_request_action_type: @bs_request_action.class.name
bs_request_action_type: @action.class.name
}
end
end
8 changes: 4 additions & 4 deletions src/api/app/views/webui/request/_request_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
%li.nav-item.scrollable-tab-link
= link_to('Conversation', request_show_path(bs_request.number, actions_count > 1 ? action : nil),
class: "nav-link text-nowrap #{active_tab == 'conversation' ? 'active' : ''}")
- if bs_request_action.tab_visibility.build
- if action.tab_visibility.build
%li.nav-item.scrollable-tab-link.active
= link_to('Build Results', request_build_results_path(bs_request.number, actions_count > 1 ? action : nil),
class: "nav-link text-nowrap #{active_tab == 'build_results' ? 'active' : ''}")
- if bs_request_action.tab_visibility.rpm_lint
- if action.tab_visibility.rpm_lint
%li.nav-item.scrollable-tab-link
= link_to('RPM Lint', request_rpm_lint_path(bs_request.number, actions_count > 1 ? action : nil),
class: "nav-link text-nowrap #{active_tab == 'rpm_lint' ? 'active' : ''}")
- if bs_request_action.tab_visibility.changes
- if action.tab_visibility.changes
%li.nav-item.scrollable-tab-link
= link_to('Changes', request_changes_path(bs_request.number, actions_count > 1 ? action : nil),
class: "nav-link text-nowrap #{active_tab == 'changes' ? 'active' : ''}")
- if bs_request_action.tab_visibility.issues
- if action.tab_visibility.issues
%li.nav-item.scrollable-tab-link
= link_to(request_mentioned_issues_path(bs_request.number, actions_count > 1 ? action : nil),
class: "nav-link text-nowrap #{active_tab == 'mentioned_issues' ? 'active' : ''}") do
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/beta_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
diff_to_superseded_id: @diff_to_superseded_id, page_name: '',
bs_requests: @watched_requests, packages: @watched_packages, projects: @watched_projects }
= render partial: 'request_tabs',
locals: { bs_request: @bs_request, bs_request_action: @bs_request_action, issues: @issues, action: @action,
locals: { bs_request: @bs_request, action: @action, issues: @issues,
actions_count: @supported_actions.count, active_tab: @active_tab }
.container.p-4
.row
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/build_results.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
diff_to_superseded_id: @diff_to_superseded_id, page_name: 'request_build_results',
bs_requests: @watched_requests, packages: @watched_packages, projects: @watched_projects }
= render partial: 'request_tabs',
locals: { bs_request: @bs_request, bs_request_action: @bs_request_action, issues: @issues, action: @action,
locals: { bs_request: @bs_request, action: @action, issues: @issues,
actions_count: @supported_actions.count, active_tab: @active_tab }
.container.p-4
- if @buildable
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/changes.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
diff_to_superseded_id: @diff_to_superseded_id, page_name: 'request_changes',
bs_requests: @watched_requests, packages: @watched_packages, projects: @watched_projects }
= render partial: 'request_tabs',
locals: { bs_request: @bs_request, bs_request_action: @bs_request_action, issues: @issues, action: @action,
locals: { bs_request: @bs_request, action: @action, issues: @issues,
actions_count: @supported_actions.count, active_tab: @active_tab }
.container.p-4
.tab-content.sourcediff
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/mentioned_issues.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
diff_to_superseded_id: @diff_to_superseded_id, page_name: 'request_mentioned_issues',
bs_requests: @watched_requests, packages: @watched_packages, projects: @watched_projects }
= render partial: 'request_tabs',
locals: { bs_request: @bs_request, bs_request_action: @bs_request_action, issues: @issues, action: @action,
locals: { bs_request: @bs_request, action: @action, issues: @issues,
actions_count: @supported_actions.count, active_tab: @active_tab }
.container.p-4
- if @issues.empty?
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/rpm_lint.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
diff_to_superseded_id: @diff_to_superseded_id, page_name: 'request_rpm_lint',
bs_requests: @watched_requests, packages: @watched_packages, projects: @watched_projects }
= render partial: 'request_tabs',
locals: { bs_request: @bs_request, bs_request_action: @bs_request_action, issues: @issues, action: @action,
locals: { bs_request: @bs_request, action: @action, issues: @issues,
actions_count: @supported_actions.count, active_tab: @active_tab }
.container.p-4
- if @action.source_package
Expand Down

0 comments on commit 45ad4ec

Please sign in to comment.