diff --git a/src/api/app/controllers/webui/request_controller.rb b/src/api/app/controllers/webui/request_controller.rb index 8e51cfe0091a..667fbeb9f8ae 100644 --- a/src/api/app/controllers/webui/request_controller.rb +++ b/src/api/app/controllers/webui/request_controller.rb @@ -286,7 +286,7 @@ def inline_comment end def build_results - redirect_to request_show_path(params[:number], params[:request_action_id]) unless @action[:sprj] || @action[:spkg] + redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.build @active_tab = 'build_results' @project = @staging_project || @action[:sprj] @@ -298,7 +298,7 @@ def build_results end def rpm_lint - redirect_to request_show_path(params[:number], params[:request_action_id]) unless @action[:sprj] || @action[:spkg] + redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.rpm_lint @active_tab = 'rpm_lint' @ajax_data = {} @@ -308,13 +308,13 @@ def rpm_lint end def changes - redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.visible_tab(:changes) + redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.changes @active_tab = 'changes' end def mentioned_issues - redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.visible_tab(:mentioned_issues) + redirect_to request_show_path(params[:number], params[:request_action_id]) unless @bs_request_action.tab_visibility.issues @active_tab = 'mentioned_issues' end diff --git a/src/api/app/models/bs_request_action.rb b/src/api/app/models/bs_request_action.rb index cdd0384d0ae8..7b2b6efe7d53 100644 --- a/src/api/app/models/bs_request_action.rb +++ b/src/api/app/models/bs_request_action.rb @@ -864,9 +864,8 @@ def event_parameters params end - def visible_tab(tab_name) - action_tab_visibility = BsRequestActionTabVisibility.new(self) - action_tab_visibility.visible(tab_name) + def tab_visibility + BsRequestActionTabVisibility.new(self) end private diff --git a/src/api/app/models/bs_request_action_tab_visibility.rb b/src/api/app/models/bs_request_action_tab_visibility.rb index 8e80ac2c0ddf..d33a04b71012 100644 --- a/src/api/app/models/bs_request_action_tab_visibility.rb +++ b/src/api/app/models/bs_request_action_tab_visibility.rb @@ -5,18 +5,20 @@ def initialize(bs_request_action) @action = bs_request_action end - # Handle tabs visibility - def visible(tab_name) - case tab_name - when :build_results, :rpm_lint - source_package && !patchinfo_package - when :changes - (@action.type == :delete && @action.source_package) || @action.type.in?(CHANGES_TABS) - when :mentioned_issues - @action.type.in?(CHANGES_TABS) - else - true - end + def build + source_package && !patchinfo_package + end + + def rpm_lint + build + end + + def changes + (@action.type == :delete && @action.source_package) || @action.type.in?(CHANGES_TABS) + end + + def issues + @action.type.in?(CHANGES_TABS) end private 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 218501ed1432..a0570946345e 100644 --- a/src/api/app/views/webui/request/_request_tabs.html.haml +++ b/src/api/app/views/webui/request/_request_tabs.html.haml @@ -3,19 +3,19 @@ %li.nav-item.scrollable-tab-link = link_to('Conversation', request_show_path(bs_request.number, actions_count > 1 ? active_action : nil), class: "nav-link text-nowrap #{active_tab == 'conversation' ? 'active' : ''}") - - if bs_request_action.visible_tab(:build_results) + - if bs_request_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 ? active_action : nil), class: "nav-link text-nowrap #{active_tab == 'build_results' ? 'active' : ''}") - - if bs_request_action.visible_tab(:rpm_lint) + - if bs_request_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 ? active_action : nil), class: "nav-link text-nowrap #{active_tab == 'rpm_lint' ? 'active' : ''}") - - if bs_request_action.visible_tab(:changes) + - if bs_request_action.tab_visibility.changes %li.nav-item.scrollable-tab-link = link_to('Changes', request_changes_path(bs_request.number, actions_count > 1 ? active_action : nil), class: "nav-link text-nowrap #{active_tab == 'changes' ? 'active' : ''}") - - if bs_request_action.visible_tab(:mentioned_issues) + - if bs_request_action.tab_visibility.issues %li.nav-item.scrollable-tab-link = link_to(request_mentioned_issues_path(bs_request.number, actions_count > 1 ? active_action : nil), class: "nav-link text-nowrap #{active_tab == 'mentioned_issues' ? 'active' : ''}") do