diff options
Diffstat (limited to 'app/assets/javascripts/admin/users/components/actions')
3 files changed, 56 insertions, 74 deletions
diff --git a/app/assets/javascripts/admin/users/components/actions/delete.vue b/app/assets/javascripts/admin/users/components/actions/delete.vue index e6dde5898e7..ae0c6731271 100644 --- a/app/assets/javascripts/admin/users/components/actions/delete.vue +++ b/app/assets/javascripts/admin/users/components/actions/delete.vue @@ -1,9 +1,11 @@ <script> -import SharedDeleteAction from './shared/shared_delete_action.vue'; +import { GlDropdownItem } from '@gitlab/ui'; +import { s__ } from '~/locale'; +import eventHub, { EVENT_OPEN_DELETE_USER_MODAL } from '../modals/delete_user_modal_event_hub'; export default { components: { - SharedDeleteAction, + GlDropdownItem, }, props: { username: { @@ -20,17 +22,32 @@ export default { default: () => [], }, }, + methods: { + onClick() { + const { username, paths, userDeletionObstacles } = this; + eventHub.$emit(EVENT_OPEN_DELETE_USER_MODAL, { + username, + blockPath: paths.block, + deletePath: paths.delete, + userDeletionObstacles, + i18n: { + title: s__('AdminUsers|Delete User %{username}?'), + primaryButtonLabel: s__('AdminUsers|Delete user'), + messageBody: s__(`AdminUsers|You are about to permanently delete the user %{username}. Issues, merge requests, + and groups linked to them will be transferred to a system-wide "Ghost-user". 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.`), + }, + }); + }, + }, }; </script> <template> - <shared-delete-action - modal-type="delete" - :username="username" - :paths="paths" - :delete-path="paths.delete" - :user-deletion-obstacles="userDeletionObstacles" - > - <slot></slot> - </shared-delete-action> + <gl-dropdown-item @click="onClick"> + <span class="gl-text-red-500"> + <slot></slot> + </span> + </gl-dropdown-item> </template> diff --git a/app/assets/javascripts/admin/users/components/actions/delete_with_contributions.vue b/app/assets/javascripts/admin/users/components/actions/delete_with_contributions.vue index bd920a91516..a39df1cbfb6 100644 --- a/app/assets/javascripts/admin/users/components/actions/delete_with_contributions.vue +++ b/app/assets/javascripts/admin/users/components/actions/delete_with_contributions.vue @@ -1,9 +1,11 @@ <script> -import SharedDeleteAction from './shared/shared_delete_action.vue'; +import { GlDropdownItem } from '@gitlab/ui'; +import { s__ } from '~/locale'; +import eventHub, { EVENT_OPEN_DELETE_USER_MODAL } from '../modals/delete_user_modal_event_hub'; export default { components: { - SharedDeleteAction, + GlDropdownItem, }, props: { username: { @@ -20,17 +22,32 @@ export default { default: () => [], }, }, + methods: { + onClick() { + const { username, paths, userDeletionObstacles } = this; + eventHub.$emit(EVENT_OPEN_DELETE_USER_MODAL, { + username, + blockPath: paths.block, + deletePath: paths.deleteWithContributions, + userDeletionObstacles, + i18n: { + title: s__('AdminUsers|Delete User %{username} and contributions?'), + primaryButtonLabel: s__('AdminUsers|Delete user and contributions'), + messageBody: s__(`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.`), + }, + }); + }, + }, }; </script> <template> - <shared-delete-action - modal-type="delete-with-contributions" - :username="username" - :paths="paths" - :delete-path="paths.deleteWithContributions" - :user-deletion-obstacles="userDeletionObstacles" - > - <slot></slot> - </shared-delete-action> + <gl-dropdown-item @click="onClick"> + <span class="gl-text-red-500"> + <slot></slot> + </span> + </gl-dropdown-item> </template> diff --git a/app/assets/javascripts/admin/users/components/actions/shared/shared_delete_action.vue b/app/assets/javascripts/admin/users/components/actions/shared/shared_delete_action.vue deleted file mode 100644 index c9f29b55dbf..00000000000 --- a/app/assets/javascripts/admin/users/components/actions/shared/shared_delete_action.vue +++ /dev/null @@ -1,52 +0,0 @@ -<script> -import { GlDropdownItem } from '@gitlab/ui'; - -export default { - components: { - GlDropdownItem, - }, - props: { - username: { - type: String, - required: true, - }, - paths: { - type: Object, - required: true, - }, - deletePath: { - type: String, - required: true, - }, - modalType: { - type: String, - required: true, - }, - userDeletionObstacles: { - type: Array, - required: true, - }, - }, - computed: { - modalAttributes() { - return { - 'data-block-user-url': this.paths.block, - 'data-delete-user-url': this.deletePath, - 'data-gl-modal-action': this.modalType, - 'data-username': this.username, - 'data-user-deletion-obstacles': JSON.stringify(this.userDeletionObstacles), - }; - }, - }, -}; -</script> - -<template> - <div class="js-delete-user-modal-button" v-bind="{ ...modalAttributes }"> - <gl-dropdown-item> - <span class="gl-text-red-500"> - <slot></slot> - </span> - </gl-dropdown-item> - </div> -</template> |