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
}
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
header = tag.p s_('AdminUsers|Blocking user has the following effects:')
......
......@@ -40,7 +40,8 @@
%button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_block_data(user, user_block_effects) }
= s_('AdminUsers|Block')
- 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
%button.btn.btn-default-tertiary.js-confirm-modal-button{ data: user_block_data(user, user_block_effects) }
= s_('AdminUsers|Block')
......
......@@ -186,7 +186,8 @@
%li Log in
%li Access Git repositories
%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?
= 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 ""
msgid "AdminUsers|To confirm, type %{username}"
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"
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."
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."
msgstr ""
......@@ -28958,9 +28970,6 @@ msgstr ""
msgid "Unassigned"
msgstr ""
msgid "Unblock"
msgstr ""
msgid "Undo"
msgstr ""
......
......@@ -205,8 +205,8 @@ RSpec.describe "Admin::Users" do
end
end
context 'when blocking a user' do
it 'shows confirmation and allows blocking', :js do
context 'when blocking/unblocking a user' do
it 'shows confirmation and allows blocking and unblocking', :js do
expect(page).to have_content(user.email)
find("[data-testid='user-action-button-#{user.id}']").click
......@@ -228,6 +228,30 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content('Successfully blocked')
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
......@@ -388,8 +412,8 @@ RSpec.describe "Admin::Users" do
end
end
context 'when blocking the user' do
it 'shows confirmation and allows blocking', :js do
context 'when blocking/unblocking the user' do
it 'shows confirmation and allows blocking and unblocking', :js do
visit admin_user_path(user)
find('button', text: 'Block user').click
......@@ -405,6 +429,20 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content('Successfully 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
......
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