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

user_actions_app.vue « components « actions « profile « users « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5dfa9c6785285ad1f11d026d2bc2dbd019b5812b (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
84
85
86
87
88
89
90
91
92
93
94
95
<script>
import { GlDisclosureDropdown } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale';
import AbuseCategorySelector from '~/abuse_reports/components/abuse_category_selector.vue';

export default {
  components: {
    GlDisclosureDropdown,
    AbuseCategorySelector,
  },
  props: {
    userId: {
      type: String,
      required: true,
    },
    rssSubscriptionPath: {
      type: String,
      required: false,
      default: '',
    },
    reportedUserId: {
      type: Number,
      required: false,
      default: null,
    },
    reportedFromUrl: {
      type: String,
      required: false,
      default: '',
    },
  },
  data() {
    return {
      defaultDropdownItems: [
        {
          action: this.onUserIdCopy,
          text: sprintf(this.$options.i18n.userId, { id: this.userId }),
          extraAttrs: {
            'data-clipboard-text': this.userId,
          },
        },
      ],
      open: false,
    };
  },
  computed: {
    dropdownItems() {
      const dropdownItems = this.defaultDropdownItems.slice();
      if (this.rssSubscriptionPath) {
        dropdownItems.push({
          href: this.rssSubscriptionPath,
          text: this.$options.i18n.rssSubscribe,
          extraAttrs: {
            'data-testid': 'user-profile-rss-subscription-link',
          },
        });
      }
      if (this.reportedUserId) {
        dropdownItems.push({
          action: () => this.toggleDrawer(true),
          text: this.$options.i18n.reportToAdmin,
        });
      }
      return dropdownItems;
    },
  },
  methods: {
    onUserIdCopy() {
      this.$toast.show(this.$options.i18n.userIdCopied);
    },
    toggleDrawer(open) {
      this.open = open;
    },
  },
  i18n: {
    userId: s__('UserProfile|Copy user ID: %{id}'),
    userIdCopied: s__('UserProfile|User ID copied to clipboard'),
    rssSubscribe: s__('UserProfile|Subscribe'),
    reportToAdmin: s__('ReportAbuse|Report abuse to administrator'),
  },
};
</script>

<template>
  <span>
    <gl-disclosure-dropdown icon="ellipsis_v" category="tertiary" no-caret :items="dropdownItems" />
    <abuse-category-selector
      v-if="reportedUserId"
      :reported-user-id="reportedUserId"
      :reported-from-url="reportedFromUrl"
      :show-drawer="open"
      @close-drawer="toggleDrawer(false)"
    />
  </span>
</template>