Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make confirm alerts show the triggering action #4543

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/components/moderation/shared/index_component.html.erb
Expand Up @@ -21,18 +21,18 @@
<%= submit_tag t("moderation.#{i18n_namespace}.index.block_authors"),
name: "block_authors",
class: "button hollow alert",
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm") } %>
data: { confirm: t("moderation.actions.confirm_action", action: t("moderation.#{i18n_namespace}.index.block_authors")) } %>

<div class="float-right">
<%= submit_tag t("moderation.#{i18n_namespace}.index.hide"),
name: "hide_#{table_name}",
class: "button hollow alert",
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm") } %>
data: { confirm: t("moderation.actions.confirm_action", action: t("moderation.#{i18n_namespace}.index.hide")) } %>

<%= submit_tag t("moderation.#{i18n_namespace}.index.ignore_flags"),
name: "ignore_flags",
class: "button hollow",
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm") } %>
data: { confirm: t("moderation.actions.confirm_action", action: t("moderation.#{i18n_namespace}.index.ignore_flags")) } %>
</div>

<%= paginate records %>
Expand Down
Expand Up @@ -18,6 +18,6 @@
class: "delete float-right",
method: :delete,
remote: true,
data: { confirm: t("admin.actions.confirm") } %>
data: { confirm: t("admin.actions.confirm_action", action: t("images.remove_image"), name: image.title) } %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/budgets/investments/_actions.html.erb
@@ -1,10 +1,10 @@
<% if can? :hide, investment %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_budget_investment_path(investment),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: investment.title) } %>
<% end %>

<% if can? :hide, investment.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(investment.author_id),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: investment.author.name) } %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/comments/_actions.html.erb
Expand Up @@ -12,13 +12,13 @@
data: { confirm: t("comments.actions.confirm_delete") } %>
<% else %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_comment_path(comment),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: comment.body.truncate(32)) } %>
<% end %>
<% end %>

<% if can? :hide, comment.user %>
<span class="divider">&nbsp;&bull;&nbsp;</span>
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(comment.user_id),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: comment.author.name) } %>
<% end %>
</span>
8 changes: 4 additions & 4 deletions app/views/debates/_actions.html.erb
@@ -1,21 +1,21 @@
<% 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") } %>
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") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: debate.author.name) } %>
<% end %>

<% if can? :mark_featured, debate %>
&nbsp;|&nbsp;
<% if debate.featured? %>
<%= link_to t("admin.actions.unmark_featured").capitalize, unmark_featured_debate_path(debate),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.unmark_featured"), name: debate.title) } %>
<% else %>
<%= link_to t("admin.actions.mark_featured").capitalize, mark_featured_debate_path(debate),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.mark_featured"), name: debate.title) } %>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/legislation/proposals/_actions.html.erb
@@ -1,10 +1,10 @@
<% if can? :hide, proposal %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_legislation_proposal_path(proposal),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: proposal.title) } %>
<% end %>

<% if can? :hide, proposal.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(proposal.author_id),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: proposal.author.name) } %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/proposal_notifications/_actions.html.erb
Expand Up @@ -3,13 +3,13 @@
<span class="js-moderation-actions">
<% if can? :hide, notification %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_proposal_notification_path(notification),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: notification.title) } %>
<% end %>

<% if can? :hide, notification.author %>
<span class="divider">&nbsp;&bull;&nbsp;</span>
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(notification.author_id),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: notification.author.name) } %>
<% end %>
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/proposals/_actions.html.erb
@@ -1,10 +1,10 @@
<% if can? :hide, proposal %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_proposal_path(proposal),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm") } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: proposal.title) } %>
<% end %>

<% if can? :hide, proposal.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(proposal.author_id),
method: :put, data: { confirm: t("admin.actions.confirm") } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: proposal.author.name) } %>
<% end %>
1 change: 0 additions & 1 deletion config/locales/en/admin.yml
Expand Up @@ -4,7 +4,6 @@ en:
title: Administration
actions:
actions: Actions
confirm: Are you sure?
confirm_action: "Are you sure? %{action} \"%{name}\""
confirm_delete: "Are you sure? This action will delete \"%{name}\" and can't be undone."
confirm_hide: Confirm moderation
Expand Down
7 changes: 2 additions & 5 deletions config/locales/en/moderation.yml
@@ -1,9 +1,10 @@
en:
moderation:
actions:
confirm_action: "Are you sure? %{action}"
comments:
index:
block_authors: Block authors
rhian-cs marked this conversation as resolved.
Show resolved Hide resolved
confirm: Are you sure?
filter: Filter
filters:
all: All
Expand All @@ -24,7 +25,6 @@ en:
debates:
index:
block_authors: Block authors
confirm: Are you sure?
filter: Filter
filters:
all: All
Expand All @@ -51,7 +51,6 @@ en:
proposals:
index:
block_authors: Block authors
confirm: Are you sure?
filter: Filter
filters:
all: All
Expand All @@ -69,7 +68,6 @@ en:
budget_investments:
index:
block_authors: Block authors
confirm: Are you sure?
filter: Filter
filters:
all: All
Expand All @@ -87,7 +85,6 @@ en:
proposal_notifications:
index:
block_authors: Block authors
confirm: Are you sure?
filter: Filter
filters:
all: All
Expand Down
1 change: 0 additions & 1 deletion config/locales/es/admin.yml
Expand Up @@ -4,7 +4,6 @@ es:
title: Administración
actions:
actions: Acciones
confirm: '¿Estás seguro?'
confirm_action: "¿Estás seguro? %{action} \"%{name}\""
confirm_delete: "¿Estás seguro? Esta acción borrará \"%{name}\" y no se puede deshacer."
confirm_hide: Confirmar moderación
Expand Down
7 changes: 2 additions & 5 deletions config/locales/es/moderation.yml
@@ -1,9 +1,10 @@
es:
moderation:
actions:
confirm_action: "¿Estás seguro? %{action}"
comments:
index:
block_authors: Bloquear autores
confirm: '¿Estás seguro?'
filter: Filtro
filters:
all: Todos
Expand All @@ -24,7 +25,6 @@ es:
debates:
index:
block_authors: Bloquear autores
confirm: '¿Estás seguro?'
filter: Filtrar
filters:
all: Todos
Expand All @@ -51,7 +51,6 @@ es:
proposals:
index:
block_authors: Bloquear autores
confirm: '¿Estás seguro?'
filter: Filtro
filters:
all: Todas
Expand All @@ -69,7 +68,6 @@ es:
budget_investments:
index:
block_authors: Bloquear autores
confirm: '¿Estás seguro?'
filter: Filtro
filters:
all: Todos
Expand All @@ -87,7 +85,6 @@ es:
proposal_notifications:
index:
block_authors: Bloquear autores
confirm: '¿Estás seguro?'
filter: Filtro
filters:
all: Todas
Expand Down
28 changes: 14 additions & 14 deletions spec/system/admin/activity_spec.rb
Expand Up @@ -14,7 +14,7 @@
visit proposal_path(proposal)

within("#proposal_#{proposal.id}") do
accept_confirm { click_link "Hide" }
accept_confirm("Are you sure? Hide \"#{proposal.title}\"") { click_link "Hide" }
end
expect(page).to have_css("#proposal_#{proposal.id}.faded")

Expand Down Expand Up @@ -43,7 +43,7 @@
check "proposal_#{proposal3.id}_check"
end

accept_confirm { click_button "Hide proposals" }
accept_confirm("Are you sure? Hide proposals") { click_button "Hide proposals" }

expect(page).not_to have_content(proposal1.title)

Expand All @@ -60,7 +60,7 @@
visit admin_hidden_proposals_path

within("#proposal_#{proposal.id}") do
accept_confirm { click_button "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden proposals"
Expand All @@ -82,7 +82,7 @@
visit debate_path(debate)

within("#debate_#{debate.id}") do
accept_confirm { click_link "Hide" }
accept_confirm("Are you sure? Hide \"#{debate.title}\"") { click_link "Hide" }
end
expect(page).to have_css("#debate_#{debate.id}.faded")

Expand Down Expand Up @@ -110,7 +110,7 @@
check "debate_#{debate3.id}_check"
end

accept_confirm { click_button "Hide debates" }
accept_confirm("Are you sure? Hide debates") { click_button "Hide debates" }

expect(page).not_to have_content(debate1.title)

Expand All @@ -127,7 +127,7 @@
visit admin_hidden_debates_path

within("#debate_#{debate.id}") do
accept_confirm { click_button "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden debates"
Expand All @@ -150,7 +150,7 @@
visit debate_path(debate)

within("#comment_#{comment.id}") do
accept_confirm { click_link "Hide" }
accept_confirm("Are you sure? Hide \"#{comment.body}\"") { click_link "Hide" }
expect(page).to have_css(".faded")
end

Expand Down Expand Up @@ -178,7 +178,7 @@
check "comment_#{comment3.id}_check"
end

accept_confirm { click_button "Hide comments" }
accept_confirm("Are you sure? Hide comments") { click_button "Hide comments" }

expect(page).not_to have_content(comment1.body)

Expand All @@ -195,7 +195,7 @@
visit admin_hidden_comments_path

within("#comment_#{comment.id}") do
accept_confirm { click_button "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden comments"
Expand All @@ -217,7 +217,7 @@
visit proposal_path(proposal)

within("#proposal_#{proposal.id}") do
accept_confirm { click_link "Hide author" }
accept_confirm("Are you sure? Hide author \"#{proposal.author.name}\"") { click_link "Hide author" }

expect(page).to have_current_path(debates_path)
end
Expand Down Expand Up @@ -266,7 +266,7 @@
check "proposal_#{proposal3.id}_check"
end

accept_confirm { click_button "Block authors" }
accept_confirm("Are you sure? Block authors") { click_button "Block authors" }

expect(page).not_to have_content(proposal1.author.username)

Expand Down Expand Up @@ -294,7 +294,7 @@
check "debate_#{debate3.id}_check"
end

accept_confirm { click_button "Block authors" }
accept_confirm("Are you sure? Block authors") { click_button "Block authors" }

expect(page).not_to have_content(debate1.author.username)

Expand Down Expand Up @@ -322,7 +322,7 @@
check "comment_#{comment3.id}_check"
end

accept_confirm { click_button "Block authors" }
accept_confirm("Are you sure? Block authors") { click_button "Block authors" }

expect(page).not_to have_content comment1.author.username

Expand All @@ -341,7 +341,7 @@
visit admin_hidden_users_path

within("#user_#{user.id}") do
accept_confirm { click_button "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden users"
Expand Down
4 changes: 3 additions & 1 deletion spec/system/admin/admin_notifications_spec.rb
Expand Up @@ -117,8 +117,10 @@
notification = create(:admin_notification)

visit admin_admin_notifications_path

confirmation = "Are you sure? This action will delete \"#{notification.title}\" and can't be undone."
within("#admin_notification_#{notification.id}") do
accept_confirm { click_button "Delete" }
accept_confirm(confirmation) { click_button "Delete" }
end

expect(page).to have_content "Notification deleted successfully"
Expand Down