Files
nairobi/app/components/widgets/feeds/feed_component.rb
Javi Martín fae52274a4 Reuse code between feed components
They were all following the same format.

Note we need to group the `see_all` translation keys together (the same
way it's done with the `most_active` keys) so we don't have an unused
translation warning.

We're also moving the "see all" link in processes outside the feed
content; the same way it's done in debates and proposals and removing
unnecessary classes in the processes feed: the column class is causing
the processes not to be aligned with the debates above them, and the
margin bottom is not needed because the margin of the footer is already
enough.
2020-12-27 21:42:40 +01:00

26 lines
488 B
Ruby

class Widgets::Feeds::FeedComponent < ApplicationComponent
attr_reader :feed
delegate :kind, to: :feed
def initialize(feed)
@feed = feed
end
def see_all_path
polymorphic_path(feed.items.model)
end
private
def item_component_class
case kind
when "proposals"
Widgets::Feeds::ProposalComponent
when "debates"
Widgets::Feeds::DebateComponent
when "processes"
Widgets::Feeds::ProcessComponent
end
end
end