Ask for confirmation when hiding/blocking users
In the moderation section there's no clear indicator as to what the "Hide" and "Block" buttons do and the difference between them. Since we're using confirmation dialogs in all moderation actions except these ones, we're adding them here as well, so the difference will appear in the dialog. This isn't a very good solution, though, since the confirmation dialog comes after clicking the button and users have already been wondering whether clicking that button will be the right choice. A better solution would be making the purpose clear before the button is clicked, although that's something we don't do anywhere in the admin/moderation sections.
This commit is contained in:
@@ -68,6 +68,8 @@ class Admin::ActionComponent < ApplicationComponent
|
|||||||
else
|
else
|
||||||
t("admin.actions.confirm_action", action: text, name: record_name)
|
t("admin.actions.confirm_action", action: text, name: record_name)
|
||||||
end
|
end
|
||||||
|
elsif options[:confirm].respond_to?(:call)
|
||||||
|
options[:confirm].call(record_name)
|
||||||
else
|
else
|
||||||
options[:confirm]
|
options[:confirm]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
path: block_moderation_user_path(author),
|
path: block_moderation_user_path(author),
|
||||||
id: dom_id(author, "#{dom_id(record)}_block_author"),
|
id: dom_id(author, "#{dom_id(record)}_block_author"),
|
||||||
method: :put,
|
method: :put,
|
||||||
confirm: true
|
confirm: ->(name) { t("moderation.users.index.confirm_block", name: name) }
|
||||||
) %>
|
) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,8 +22,18 @@
|
|||||||
<%= t("moderation.users.index.hidden") %>
|
<%= t("moderation.users.index.hidden") %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render Admin::TableActionsComponent.new(user, actions: []) do |actions| %>
|
<%= render Admin::TableActionsComponent.new(user, actions: []) do |actions| %>
|
||||||
<%= actions.action(:hide, text: t("moderation.users.index.hide"), method: :put) %>
|
<%= actions.action(
|
||||||
<%= actions.action(:block, text: t("moderation.users.index.block"), method: :put) %>
|
:hide,
|
||||||
|
text: t("moderation.users.index.hide"),
|
||||||
|
confirm: ->(name) { t("moderation.users.index.confirm_hide", name: name) },
|
||||||
|
method: :put
|
||||||
|
) %>
|
||||||
|
<%= actions.action(
|
||||||
|
:block,
|
||||||
|
text: t("moderation.users.index.block"),
|
||||||
|
confirm: ->(name) { t("moderation.users.index.confirm_block", name: name) },
|
||||||
|
method: :put
|
||||||
|
) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ en:
|
|||||||
users:
|
users:
|
||||||
index:
|
index:
|
||||||
block: Block
|
block: Block
|
||||||
|
confirm_block: "Are you sure? This will hide the user \"%{name}\" and all their contents."
|
||||||
|
confirm_hide: "Are you sure? This will hide the user \"%{name}\" without hiding their contents."
|
||||||
hidden: Blocked
|
hidden: Blocked
|
||||||
hide: Hide
|
hide: Hide
|
||||||
search_placeholder: email or name of user
|
search_placeholder: email or name of user
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ es:
|
|||||||
users:
|
users:
|
||||||
index:
|
index:
|
||||||
block: Bloquear
|
block: Bloquear
|
||||||
|
confirm_block: "¿Seguro? Esto ocultará a \"%{name}\" así como todos sus contenidos."
|
||||||
|
confirm_hide: "¿Seguro? Esto ocultará a \"%{name}\" sin ocultar sus contenidos."
|
||||||
hidden: Bloqueado
|
hidden: Bloqueado
|
||||||
hide: Ocultar
|
hide: Ocultar
|
||||||
search_placeholder: email o nombre de usuario
|
search_placeholder: email o nombre de usuario
|
||||||
|
|||||||
@@ -217,7 +217,9 @@ describe "Admin activity" do
|
|||||||
visit proposal_path(proposal)
|
visit proposal_path(proposal)
|
||||||
|
|
||||||
within("#proposal_#{proposal.id}") do
|
within("#proposal_#{proposal.id}") do
|
||||||
accept_confirm("Are you sure? Block author \"#{proposal.author.name}\"") { click_button "Block author" }
|
accept_confirm("Are you sure? This will hide the user \"#{proposal.author.name}\" and all their contents.") do
|
||||||
|
click_button "Block author"
|
||||||
|
end
|
||||||
|
|
||||||
expect(page).to have_current_path(proposals_path)
|
expect(page).to have_current_path(proposals_path)
|
||||||
end
|
end
|
||||||
@@ -239,9 +241,11 @@ describe "Admin activity" do
|
|||||||
visit moderation_users_path(search: user.username)
|
visit moderation_users_path(search: user.username)
|
||||||
|
|
||||||
within("#moderation_users") do
|
within("#moderation_users") do
|
||||||
click_button "Block"
|
accept_confirm { click_button "Block" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content "The user has been blocked"
|
||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within first("tbody tr") do
|
within first("tbody tr") do
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ describe "Admin hidden comments", :admin do
|
|||||||
visit proposal_path(proposal)
|
visit proposal_path(proposal)
|
||||||
|
|
||||||
within("#proposal_#{proposal.id}") do
|
within("#proposal_#{proposal.id}") do
|
||||||
accept_confirm("Are you sure? Block author \"#{proposal.author.name}\"") { click_button "Block author" }
|
accept_confirm("Are you sure? This will hide the user \"#{proposal.author.name}\" and all their contents.") do
|
||||||
|
click_button "Block author"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to have_current_path proposals_path
|
expect(page).to have_current_path proposals_path
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ describe "Moderate budget investments" do
|
|||||||
login_as(mod.user)
|
login_as(mod.user)
|
||||||
visit budget_investment_path(budget, investment)
|
visit budget_investment_path(budget, investment)
|
||||||
|
|
||||||
accept_confirm("Are you sure? Block author \"#{investment.author.name}\"") { click_button "Block author" }
|
accept_confirm("Are you sure? This will hide the user \"#{investment.author.name}\" and all their contents.") do
|
||||||
|
click_button "Block author"
|
||||||
|
end
|
||||||
|
|
||||||
expect(page).to have_current_path(budget_investments_path(budget))
|
expect(page).to have_current_path(budget_investments_path(budget))
|
||||||
expect(page).not_to have_content(investment.title)
|
expect(page).not_to have_content(investment.title)
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ describe "Moderate users" do
|
|||||||
visit debate_path(debate1)
|
visit debate_path(debate1)
|
||||||
|
|
||||||
within("#debate_#{debate1.id}") do
|
within("#debate_#{debate1.id}") do
|
||||||
accept_confirm("Are you sure? Block author \"#{debate1.author.name}\"") { click_button "Block author" }
|
accept_confirm("Are you sure? This will hide the user \"#{debate1.author.name}\" and all their contents.") do
|
||||||
|
click_button "Block author"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to have_current_path(debates_path)
|
expect(page).to have_current_path(debates_path)
|
||||||
@@ -64,7 +66,8 @@ describe "Moderate users" do
|
|||||||
within("#moderation_users") do
|
within("#moderation_users") do
|
||||||
expect(page).to have_content citizen.name
|
expect(page).to have_content citizen.name
|
||||||
expect(page).not_to have_content "Blocked"
|
expect(page).not_to have_content "Blocked"
|
||||||
click_button "Block"
|
|
||||||
|
accept_confirm { click_button "Block" }
|
||||||
end
|
end
|
||||||
|
|
||||||
within("#moderation_users") do
|
within("#moderation_users") do
|
||||||
|
|||||||
Reference in New Issue
Block a user