summaryrefslogtreecommitdiff
path: root/app/helpers/users_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/users_helper.rb')
-rw-r--r--app/helpers/users_helper.rb147
1 files changed, 32 insertions, 115 deletions
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index c1d05c2d3cf..93a0166f43e 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -123,130 +123,38 @@ module UsersHelper
!user.confirmed?
end
- def user_block_data(user, message)
- {
- path: block_admin_user_path(user),
- method: 'put',
- modal_attributes: {
- title: s_('AdminUsers|Block user %{username}?') % { username: sanitize_name(user.name) },
- messageHtml: message,
- okVariant: 'warning',
- okTitle: s_('AdminUsers|Block')
- }.to_json
- }
- end
-
- def user_unblock_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:')
-
- list = tag.ul do
- concat tag.li s_('AdminUsers|User will not be able to login')
- concat tag.li s_('AdminUsers|User will not be able to access git repositories')
- concat tag.li s_('AdminUsers|Personal projects will be left')
- concat tag.li s_('AdminUsers|Owned groups will be left')
- end
-
- header + list
- end
-
- def user_ban_data(user)
- {
- path: ban_admin_user_path(user),
- method: 'put',
- modal_attributes: {
- title: s_('AdminUsers|Ban user %{username}?') % { username: sanitize_name(user.name) },
- message: s_('AdminUsers|You can unban their account in the future. Their data remains intact.'),
- okVariant: 'warning',
- okTitle: s_('AdminUsers|Ban')
- }.to_json
- }
- end
-
- def user_unban_data(user)
- {
- path: unban_admin_user_path(user),
- method: 'put',
- modal_attributes: {
- title: s_('AdminUsers|Unban %{username}?') % { username: sanitize_name(user.name) },
- message: s_('AdminUsers|You ban their account in the future if necessary.'),
- okVariant: 'info',
- okTitle: s_('AdminUsers|Unban')
- }.to_json
- }
- end
-
- def user_ban_effects
- header = tag.p s_('AdminUsers|Banning the user has the following effects:')
-
- list = tag.ul do
- concat tag.li s_('AdminUsers|User will be blocked')
- end
-
- link_start = '<a href="%{url}" target="_blank">'.html_safe % { url: help_page_path("user/admin_area/moderate_users", anchor: "ban-a-user") }
- info = tag.p s_('AdminUsers|Learn more about %{link_start}banned users.%{link_end}').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
-
- header + list + info
- end
-
def ban_feature_available?
Feature.enabled?(:ban_user_feature_flag)
end
- def user_deactivation_data(user, message)
- {
- path: deactivate_admin_user_path(user),
- method: 'put',
- modal_attributes: {
- title: s_('AdminUsers|Deactivate user %{username}?') % { username: sanitize_name(user.name) },
- messageHtml: message,
- okVariant: 'warning',
- okTitle: s_('AdminUsers|Deactivate')
- }.to_json
- }
- end
+ def confirm_user_data(user)
+ message = if user.unconfirmed_email.present?
+ _('This user has an unconfirmed email address (%{email}). You may force a confirmation.') % { email: user.unconfirmed_email }
+ else
+ _('This user has an unconfirmed email address. You may force a confirmation.')
+ end
+
+ modal_attributes = Gitlab::Json.dump({
+ title: s_('AdminUsers|Confirm user %{username}?') % { username: sanitize_name(user.name) },
+ messageHtml: message,
+ actionPrimary: {
+ text: s_('AdminUsers|Confirm user'),
+ attributes: [{ variant: 'info', 'data-qa-selector': 'confirm_user_confirm_button' }]
+ },
+ actionSecondary: {
+ text: _('Cancel'),
+ attributes: [{ variant: 'default' }]
+ }
+ })
- def user_activation_data(user)
{
- path: activate_admin_user_path(user),
+ path: confirm_admin_user_path(user),
method: 'put',
- modal_attributes: {
- title: s_('AdminUsers|Activate user %{username}?') % { username: sanitize_name(user.name) },
- message: s_('AdminUsers|You can always deactivate their account again if needed.'),
- okVariant: 'info',
- okTitle: s_('AdminUsers|Activate')
- }.to_json
+ modal_attributes: modal_attributes,
+ qa_selector: 'confirm_user_button'
}
end
- def user_deactivation_effects
- header = tag.p s_('AdminUsers|Deactivating a user has the following effects:')
-
- list = tag.ul do
- concat tag.li s_('AdminUsers|The user will be logged out')
- concat tag.li s_('AdminUsers|The user will not be able to access git repositories')
- concat tag.li s_('AdminUsers|The user will not be able to access the API')
- concat tag.li s_('AdminUsers|The user will not receive any notifications')
- concat tag.li s_('AdminUsers|The user will not be able to use slash commands')
- concat tag.li s_('AdminUsers|When the user logs back in, their account will reactivate as a fully active account')
- concat tag.li s_('AdminUsers|Personal projects, group and user history will be left intact')
- end
-
- header + list
- end
-
def user_display_name(user)
return s_('UserProfile|Blocked user') if user.blocked?
@@ -256,6 +164,13 @@ module UsersHelper
user.name
end
+ def admin_user_actions_data_attributes(user)
+ {
+ user: Admin::UserEntity.represent(user, { current_user: current_user }).to_json,
+ paths: admin_users_paths.to_json
+ }
+ end
+
private
def admin_users_paths
@@ -270,7 +185,9 @@ module UsersHelper
unlock: unlock_admin_user_path(:id),
delete: admin_user_path(:id),
delete_with_contributions: admin_user_path(:id),
- admin_user: admin_user_path(:id)
+ admin_user: admin_user_path(:id),
+ ban: ban_admin_user_path(:id),
+ unban: unban_admin_user_path(:id)
}
end