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
|
class Shared::RecommendedIndexComponent < ApplicationComponent
|
||||||
attr_reader :recommendations, :disable_recommendations_path, :namespace
|
attr_reader :recommendations, :namespace
|
||||||
use_helpers :current_path_with_query_params
|
use_helpers :current_path_with_query_params
|
||||||
|
|
||||||
def initialize(recommendations, disable_recommendations_path:, namespace:)
|
def initialize(recommendations, namespace:)
|
||||||
@recommendations = recommendations
|
@recommendations = recommendations
|
||||||
@disable_recommendations_path = disable_recommendations_path
|
|
||||||
@namespace = namespace
|
@namespace = namespace
|
||||||
end
|
end
|
||||||
|
|
||||||
def render?
|
def render?
|
||||||
feature?("user.recommendations") && recommendations.present?
|
feature?("user.recommendations") && recommendations.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def disable_recommendations_path
|
||||||
|
if namespace == "debates"
|
||||||
|
recommendations_disable_debates_path
|
||||||
|
else
|
||||||
|
recommendations_disable_proposals_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,9 +18,7 @@
|
|||||||
<%= render "shared/section_header", i18n_namespace: "debates.index.section_header", image: "debates" %>
|
<%= render "shared/section_header", i18n_namespace: "debates.index.section_header", image: "debates" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render Shared::RecommendedIndexComponent.new(@recommended_debates,
|
<%= render Shared::RecommendedIndexComponent.new(@recommended_debates, namespace: "debates") %>
|
||||||
disable_recommendations_path: recommendations_disable_debates_path,
|
|
||||||
namespace: "debates") %>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="debates" class="debates-list small-12 medium-9 column">
|
<div id="debates" class="debates-list small-12 medium-9 column">
|
||||||
|
|||||||
@@ -25,9 +25,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if show_recommended_proposals? %>
|
<% if show_recommended_proposals? %>
|
||||||
<%= render Shared::RecommendedIndexComponent.new(@recommended_proposals,
|
<%= render Shared::RecommendedIndexComponent.new(@recommended_proposals, namespace: "proposals") %>
|
||||||
disable_recommendations_path: recommendations_disable_proposals_path,
|
|
||||||
namespace: "proposals") %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
Reference in New Issue
Block a user