From: Anton Khorev Date: Wed, 21 Aug 2024 14:07:40 +0000 (+0300) Subject: Change submit button on block edit page when can only revoke X-Git-Tag: live~206^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/76736bab4f4b5f24074bb0a147ea3dafb5cffa0e Change submit button on block edit page when can only revoke --- diff --git a/app/views/user_blocks/edit.html.erb b/app/views/user_blocks/edit.html.erb index aaa2fcaa4..14480eac8 100644 --- a/app/views/user_blocks/edit.html.erb +++ b/app/views/user_blocks/edit.html.erb @@ -21,6 +21,8 @@ <%= f.form_group :needs_view do %> <%= f.check_box :needs_view %> <% end %> + + <%= f.primary %> <% else %>
<% if @user_block.active? %> @@ -32,7 +34,11 @@ <%= hidden_field_tag "user_block_period", 0 %> <%= hidden_field_tag "user_block[needs_view]", false %> - <% end %> - <%= f.primary %> + <% if @user_block.active? %> + <%= f.submit t(".revoke"), :class => "btn btn-danger" %> + <% else %> + <%= f.primary %> + <% end %> + <% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a1cf2cecf..80811cd1f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2943,6 +2943,7 @@ en: title: "Editing block on %{name}" heading_html: "Editing block on %{name}" period: "How long, starting now, the user will be blocked from the API for." + revoke: "Revoke block" filter: block_period: "The blocking period must be one of the values selectable in the drop-down list." create: diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index 2cbfb37b4..61440ae56 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -278,9 +278,10 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest assert_select "textarea#user_block_reason", :count => 1 assert_select "select#user_block_period", :count => 0 assert_select "input#user_block_needs_view[type='checkbox']", :count => 0 + assert_select "input[type='submit'][value='Update block']", :count => 0 assert_select "input#user_block_period[type='hidden']", :count => 1 assert_select "input#user_block_needs_view[type='hidden']", :count => 1 - assert_select "input[type='submit'][value='Update block']", :count => 1 + assert_select "input[type='submit'][value='Revoke block']", :count => 1 end # Login as the block creator @@ -294,9 +295,10 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest assert_select "textarea#user_block_reason", :count => 1 assert_select "select#user_block_period", :count => 1 assert_select "input#user_block_needs_view[type='checkbox']", :count => 1 + assert_select "input[type='submit'][value='Update block']", :count => 1 assert_select "input#user_block_period[type='hidden']", :count => 0 assert_select "input#user_block_needs_view[type='hidden']", :count => 0 - assert_select "input[type='submit'][value='Update block']", :count => 1 + assert_select "input[type='submit'][value='Revoke block']", :count => 0 end # We should get an error if the user doesn't exist diff --git a/test/system/user_blocks_test.rb b/test/system/user_blocks_test.rb index b4b7ada7a..e9fa4e7ec 100644 --- a/test/system/user_blocks_test.rb +++ b/test/system/user_blocks_test.rb @@ -111,7 +111,7 @@ class UserBlocksSystemTest < ApplicationSystemTestCase assert_no_field "Needs view" fill_in "Reason", :with => "Revoking 0-hour blocks works" - click_on "Update block" + click_on "Revoke block" assert_text(/Revoker:\s+#{Regexp.escape other_moderator_user.display_name}/) assert_text(/Status:\s+Ended/) assert_text(/Reason for block:\s+Revoking 0-hour blocks works/)