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

abuse_category_selector.vue « components « abuse_reports « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4a7c12e5e51ff830525191b3807eb2976d3958fc (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<script>
import { GlButton, GlDrawer, GlForm, GlFormGroup, GlFormRadioGroup } from '@gitlab/ui';
import { getContentWrapperHeight } from '~/lib/utils/dom_utils';
import { s__, __ } from '~/locale';
import csrf from '~/lib/utils/csrf';

export default {
  name: 'AbuseCategorySelector',
  csrf,
  components: {
    GlButton,
    GlDrawer,
    GlForm,
    GlFormGroup,
    GlFormRadioGroup,
  },
  inject: {
    reportAbusePath: {
      default: '',
    },
  },
  props: {
    reportedUserId: {
      type: Number,
      required: true,
    },
    reportedFromUrl: {
      type: String,
      required: false,
      default: '',
    },
    showDrawer: {
      type: Boolean,
      required: true,
    },
  },
  i18n: {
    title: __('Report abuse to administrator'),
    close: __('Close'),
    label: s__('ReportAbuse|Why are you reporting this user?'),
    next: __('Next'),
  },
  categoryOptions: [
    { value: 'spam', text: s__("ReportAbuse|They're posting spam.") },
    { value: 'offensive', text: s__("ReportAbuse|They're being offensive or abusive.") },
    { value: 'phishing', text: s__("ReportAbuse|They're phishing.") },
    { value: 'crypto', text: s__("ReportAbuse|They're crypto mining.") },
    {
      value: 'credentials',
      text: s__("ReportAbuse|They're posting personal information or credentials."),
    },
    { value: 'copyright', text: s__("ReportAbuse|They're violating a copyright or trademark.") },
    { value: 'malware', text: s__("ReportAbuse|They're posting malware.") },
    { value: 'other', text: s__('ReportAbuse|Something else.') },
  ],
  data() {
    return {
      selected: '',
      mounted: false,
    };
  },
  computed: {
    drawerOffsetTop() {
      // avoid calculating this in advance because it causes layout thrashing
      // https://gitlab.com/gitlab-org/gitlab/-/issues/331172#note_1269378396
      if (!this.showDrawer) return '0';
      return getContentWrapperHeight('.content-wrapper');
    },
  },
  mounted() {
    // this is required for the component to properly animate
    // when it is shown with v-if
    this.mounted = true;
  },
  methods: {
    closeDrawer() {
      this.$emit('close-drawer');
    },
  },
};
</script>
<template>
  <gl-drawer
    :header-height="drawerOffsetTop"
    :z-index="300"
    :open="showDrawer && mounted"
    @close="closeDrawer"
  >
    <template #title>
      <h2
        class="gl-font-size-h2 gl-mt-0 gl-mb-0 gl-line-height-24"
        data-testid="category-drawer-title"
      >
        {{ $options.i18n.title }}
      </h2>
    </template>
    <template #default>
      <gl-form :action="reportAbusePath" method="post" class="gl-text-left">
        <input :value="$options.csrf.token" type="hidden" name="authenticity_token" />

        <input type="hidden" name="user_id" :value="reportedUserId" data-testid="input-user-id" />
        <input
          type="hidden"
          name="abuse_report[reported_from_url]"
          :value="reportedFromUrl"
          data-testid="input-referer"
        />

        <gl-form-group :label="$options.i18n.label" label-class="gl-text-black-normal">
          <gl-form-radio-group
            v-model="selected"
            :options="$options.categoryOptions"
            name="abuse_report[category]"
            required
          />
        </gl-form-group>

        <gl-button type="submit" variant="confirm" data-testid="submit-form-button">
          {{ $options.i18n.next }}
        </gl-button>
      </gl-form>
    </template>
  </gl-drawer>
</template>