Extract component to show moderation actions

Note that in proposal notifications we're writing the call to
render the component in the same line as the <div class="reply">
definition in order to be able to use the `:empty` selector when the
component renders nothing. No browser matches whitespace with the
`:empty` selector, so we can't add newline characters inside the tag. A
more elegant solution would be extracting the proposal notification
actions to a component and only rendering it if the moderation actions
component is rendered.
This commit is contained in:
Javi Martín
2021-12-02 02:18:46 +01:00
parent 49edd6a9b1
commit cac24b0159
12 changed files with 126 additions and 76 deletions

View File

@@ -1,13 +1,4 @@
<% if can? :hide, debate %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_debate_path(debate),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: debate.title) } %>
<% end %>
<% if can? :hide, debate.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(debate.author_id),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: debate.author.name) } %>
<% end %>
<%= render Shared::ModerationActionsComponent.new(debate) %>
<% if can? :mark_featured, debate %>
&nbsp;|&nbsp;