Files
nairobi/app/components/shared/moderation_actions_component.rb
Javi Martín a5c66c7281 Use buttons instead of links to hide content
We're continuing to replace links with buttons, for the reasons
explained in commit 5311daadf.

Since we're using the admin action component, we can also simplify the
logic handling the confirmation message.

In order to avoid duplicate IDs when generating buttons to block the
same author more than once in a page, we're including the record dom_id
in the ID of the button to block an author.
2021-12-30 15:50:03 +01:00

31 lines
517 B
Ruby

class Shared::ModerationActionsComponent < ApplicationComponent
attr_reader :record
delegate :can?, to: :helpers
def initialize(record)
@record = record
end
def render?
can?(:hide, record) || can?(:hide, author)
end
private
def author
record.author
end
def hide_path
polymorphic_path([:moderation, record], action: :hide)
end
def separator
if record.is_a?(Comment)
"&nbsp;&bull;&nbsp;"
else
"&nbsp;|&nbsp;"
end
end
end