Simplify recommended index component parameters
We can get the path if we know the namespace, so we don't need to pass both of them.
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
class Shared::RecommendedIndexComponent < ApplicationComponent
|
||||
attr_reader :recommendations, :disable_recommendations_path, :namespace
|
||||
attr_reader :recommendations, :namespace
|
||||
use_helpers :current_path_with_query_params
|
||||
|
||||
def initialize(recommendations, disable_recommendations_path:, namespace:)
|
||||
def initialize(recommendations, namespace:)
|
||||
@recommendations = recommendations
|
||||
@disable_recommendations_path = disable_recommendations_path
|
||||
@namespace = namespace
|
||||
end
|
||||
|
||||
def render?
|
||||
feature?("user.recommendations") && recommendations.present?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def disable_recommendations_path
|
||||
if namespace == "debates"
|
||||
recommendations_disable_debates_path
|
||||
else
|
||||
recommendations_disable_proposals_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
<%= render "shared/section_header", i18n_namespace: "debates.index.section_header", image: "debates" %>
|
||||
<% end %>
|
||||
|
||||
<%= render Shared::RecommendedIndexComponent.new(@recommended_debates,
|
||||
disable_recommendations_path: recommendations_disable_debates_path,
|
||||
namespace: "debates") %>
|
||||
<%= render Shared::RecommendedIndexComponent.new(@recommended_debates, namespace: "debates") %>
|
||||
|
||||
<div class="row">
|
||||
<div id="debates" class="debates-list small-12 medium-9 column">
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
<% end %>
|
||||
|
||||
<% if show_recommended_proposals? %>
|
||||
<%= render Shared::RecommendedIndexComponent.new(@recommended_proposals,
|
||||
disable_recommendations_path: recommendations_disable_proposals_path,
|
||||
namespace: "proposals") %>
|
||||
<%= render Shared::RecommendedIndexComponent.new(@recommended_proposals, namespace: "proposals") %>
|
||||
<% end %>
|
||||
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user