Commit 7cc791ba authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '267118-add-modal-to-unblock' into 'master'

Add confirm modal to unblock user

See merge request gitlab-org/gitlab!47442
parents 5a862174 c9c63693
...@@ -123,6 +123,19 @@ module UsersHelper ...@@ -123,6 +123,19 @@ module UsersHelper
} }
end end
def unblock_user_modal_data(user)
{
path: unblock_admin_user_path(user),
method: 'put',
modal_attributes: {
title: s_('AdminUsers|Unblock user %{username}?') % { username: sanitize_name(user.name) },
message: s_('AdminUsers|You can always block their account again if needed.'),
okVariant: 'info',
okTitle: s_('AdminUsers|Unblock')
}.to_json
}
end
def user_block_effects def user_block_effects
header = tag.p s_('AdminUsers|Blocking user has the following effects:') header = tag.p s_('AdminUsers|Blocking user has the following effects:')
......
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
%button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_block_data(user, user_block_effects) } %button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_block_data(user, user_block_effects) }
= s_('AdminUsers|Block') = s_('AdminUsers|Block')
- else - else
= link_to _('Unblock'), unblock_admin_user_path(user), method: :put %button.btn.btn-default-tertiary.js-confirm-modal-button{ data: unblock_user_modal_data(user) }
= s_('AdminUsers|Unblock')
- else - else
%button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_block_data(user, user_block_effects) } %button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_block_data(user, user_block_effects) }
= s_('AdminUsers|Block') = s_('AdminUsers|Block')
......
...@@ -186,7 +186,8 @@ ...@@ -186,7 +186,8 @@
%li Log in %li Log in
%li Access Git repositories %li Access Git repositories
%br %br
= link_to 'Unblock user', unblock_admin_user_path(@user), method: :put, class: "btn gl-button btn-info", data: { confirm: s_('AdminUsers|Are you sure?') } %button.btn.gl-button.btn-info.js-confirm-modal-button{ data: unblock_user_modal_data(@user) }
= s_('AdminUsers|Unblock user')
- elsif !@user.internal? - elsif !@user.internal?
= render 'admin/users/block_user', user: @user = render 'admin/users/block_user', user: @user
......
---
title: Add confirm modal to unblock user
merge_request: 47442
author:
type: added
...@@ -2239,6 +2239,15 @@ msgstr "" ...@@ -2239,6 +2239,15 @@ msgstr ""
msgid "AdminUsers|To confirm, type %{username}" msgid "AdminUsers|To confirm, type %{username}"
msgstr "" msgstr ""
msgid "AdminUsers|Unblock"
msgstr ""
msgid "AdminUsers|Unblock user"
msgstr ""
msgid "AdminUsers|Unblock user %{username}?"
msgstr ""
msgid "AdminUsers|User will not be able to access git repositories" msgid "AdminUsers|User will not be able to access git repositories"
msgstr "" msgstr ""
...@@ -2257,6 +2266,9 @@ msgstr "" ...@@ -2257,6 +2266,9 @@ msgstr ""
msgid "AdminUsers|You are about to permanently delete the user %{username}. This will delete all of the issues, merge requests, and groups linked to them. To avoid data loss, consider using the %{strongStart}block user%{strongEnd} feature instead. Once you %{strongStart}Delete user%{strongEnd}, it cannot be undone or recovered." msgid "AdminUsers|You are about to permanently delete the user %{username}. This will delete all of the issues, merge requests, and groups linked to them. To avoid data loss, consider using the %{strongStart}block user%{strongEnd} feature instead. Once you %{strongStart}Delete user%{strongEnd}, it cannot be undone or recovered."
msgstr "" msgstr ""
msgid "AdminUsers|You can always block their account again if needed."
msgstr ""
msgid "AdminUsers|You can always unblock their account, their data will remain intact." msgid "AdminUsers|You can always unblock their account, their data will remain intact."
msgstr "" msgstr ""
...@@ -28958,9 +28970,6 @@ msgstr "" ...@@ -28958,9 +28970,6 @@ msgstr ""
msgid "Unassigned" msgid "Unassigned"
msgstr "" msgstr ""
msgid "Unblock"
msgstr ""
msgid "Undo" msgid "Undo"
msgstr "" msgstr ""
......
...@@ -205,8 +205,8 @@ RSpec.describe "Admin::Users" do ...@@ -205,8 +205,8 @@ RSpec.describe "Admin::Users" do
end end
end end
context 'when blocking a user' do context 'when blocking/unblocking a user' do
it 'shows confirmation and allows blocking', :js do it 'shows confirmation and allows blocking and unblocking', :js do
expect(page).to have_content(user.email) expect(page).to have_content(user.email)
find("[data-testid='user-action-button-#{user.id}']").click find("[data-testid='user-action-button-#{user.id}']").click
...@@ -228,6 +228,30 @@ RSpec.describe "Admin::Users" do ...@@ -228,6 +228,30 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content('Successfully blocked') expect(page).to have_content('Successfully blocked')
expect(page).not_to have_content(user.email) expect(page).not_to have_content(user.email)
click_link 'Blocked'
wait_for_requests
expect(page).to have_content(user.email)
find("[data-testid='user-action-button-#{user.id}']").click
within find("[data-testid='user-action-dropdown-#{user.id}']") do
find('li button', text: 'Unblock').click
end
wait_for_requests
expect(page).to have_content('Unblock user')
expect(page).to have_content('You can always block their account again if needed.')
find('.modal-footer button', text: 'Unblock').click
wait_for_requests
expect(page).to have_content('Successfully unblocked')
expect(page).not_to have_content(user.email)
end end
end end
end end
...@@ -388,8 +412,8 @@ RSpec.describe "Admin::Users" do ...@@ -388,8 +412,8 @@ RSpec.describe "Admin::Users" do
end end
end end
context 'when blocking the user' do context 'when blocking/unblocking the user' do
it 'shows confirmation and allows blocking', :js do it 'shows confirmation and allows blocking and unblocking', :js do
visit admin_user_path(user) visit admin_user_path(user)
find('button', text: 'Block user').click find('button', text: 'Block user').click
...@@ -405,6 +429,20 @@ RSpec.describe "Admin::Users" do ...@@ -405,6 +429,20 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content('Successfully blocked') expect(page).to have_content('Successfully blocked')
expect(page).to have_content('This user is blocked') expect(page).to have_content('This user is blocked')
find('button', text: 'Unblock user').click
wait_for_requests
expect(page).to have_content('Unblock user')
expect(page).to have_content('You can always block their account again if needed.')
find('.modal-footer button', text: 'Unblock').click
wait_for_requests
expect(page).to have_content('Successfully unblocked')
expect(page).to have_content('Block this user')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment