Welcome to mirror list, hosted at ThFree Co, Russian Federation.

delete_with_contributions.vue « actions « components « users « admin « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 413804c9a3bd5ad00079d8c770bb8ef192e94b69 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<script>
import { GlDropdownItem, GlLoadingIcon } from '@gitlab/ui';
import { s__, __ } from '~/locale';
import { associationsCount } from '~/api/user_api';
import eventHub, { EVENT_OPEN_DELETE_USER_MODAL } from '../modals/delete_user_modal_event_hub';

export default {
  i18n: {
    loading: __('Loading'),
  },
  components: {
    GlDropdownItem,
    GlLoadingIcon,
  },
  props: {
    username: {
      type: String,
      required: true,
    },
    userId: {
      type: Number,
      required: true,
    },
    paths: {
      type: Object,
      required: true,
    },
    userDeletionObstacles: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
  data() {
    return {
      loading: false,
    };
  },
  methods: {
    async onClick() {
      this.loading = true;
      try {
        const { data: associationsCountData } = await associationsCount(this.userId);
        this.openModal(associationsCountData);
      } catch (error) {
        this.openModal(new Error());
      } finally {
        this.loading = false;
      }
    },
    openModal(associationsCountData) {
      const { username, paths, userDeletionObstacles } = this;
      eventHub.$emit(EVENT_OPEN_DELETE_USER_MODAL, {
        username,
        blockPath: paths.block,
        deletePath: paths.deleteWithContributions,
        userDeletionObstacles,
        associationsCount: associationsCountData,
        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 issues,
                            merge requests, groups, and projects linked to them. To avoid data loss,
                            consider using the %{strongStart}Block user%{strongEnd} feature instead. After you %{strongStart}Delete user%{strongEnd},
                            you cannot undo this action or recover the data.`),
        },
      });
    },
  },
};
</script>

<template>
  <gl-dropdown-item :disabled="loading" :aria-busy="loading" @click.capture.native.stop="onClick">
    <div v-if="loading" class="gl-display-flex gl-align-items-center">
      <gl-loading-icon class="gl-mr-3" />
      {{ $options.i18n.loading }}
    </div>
    <span v-else class="gl-text-red-500">
      <slot></slot>
    </span>
  </gl-dropdown-item>
</template>