All files / app/assets/javascripts/admin/users/components/actions delete.vue

75% Statements 3/4
100% Branches 3/3
66.66% Functions 2/3
75% Lines 3/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 614x       8x                                                     1x                                                          
<!-- eslint-disable vue/multi-word-component-names -->
<script>
import { GlDisclosureDropdownItem } from '@gitlab/ui';
import { s__ } from '~/locale';
import eventHub, { EVENT_OPEN_DELETE_USER_MODAL } from '../modals/delete_user_modal_event_hub';
 
export default {
  components: {
    GlDisclosureDropdownItem,
  },
  props: {
    username: {
      type: String,
      required: true,
    },
    userId: {
      type: Number,
      required: true,
    },
    paths: {
      type: Object,
      required: true,
    },
    userDeletionObstacles: {
      type: Array,
      required: false,
      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>
  <gl-disclosure-dropdown-item @action="onClick">
    <template #list-item>
      <span class="gl-text-red-500">
        <slot></slot>
      </span>
    </template>
  </gl-disclosure-dropdown-item>
</template>