summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/abuse_reports/components/links_to_spam_input.vue
blob: 02fe131553ce42a30fbffa5e0fc9669bb8a60538 (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
<script>
import { GlButton, GlFormGroup, GlFormInput } from '@gitlab/ui';
import { s__ } from '~/locale';

export default {
  name: 'LinksToSpamInput',
  components: {
    GlButton,
    GlFormGroup,
    GlFormInput,
  },
  i18n: {
    label: s__('ReportAbuse|Link to spam'),
    description: s__('ReportAbuse|URL of this user posting spam'),
    addAnotherText: s__('ReportAbuse|Add another link'),
  },
  props: {
    previousLinks: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
  data() {
    return {
      links: this.previousLinks.length > 0 ? this.previousLinks : [''],
    };
  },
  methods: {
    addAnotherInput() {
      this.links.push('');
    },
  },
};
</script>
<template>
  <div>
    <template v-for="(link, index) in links">
      <div :key="index" class="row">
        <div class="col-lg-8">
          <gl-form-group class="gl-mt-5">
            <template #label>
              <div class="gl-pb-2">
                {{ $options.i18n.label }}
              </div>
              <div class="gl-font-weight-normal">
                {{ $options.i18n.description }}
              </div>
            </template>
            <gl-form-input
              v-model.trim="links[index]"
              type="url"
              name="abuse_report[links_to_spam][]"
              autocomplete="off"
            />
          </gl-form-group>
        </div>
      </div>
    </template>
    <div class="row">
      <div class="col-lg-8">
        <gl-button variant="link" icon="plus" class="gl-float-right" @click="addAnotherInput">
          {{ $options.i18n.addAnotherText }}
        </gl-button>
      </div>
    </div>
  </div>
</template>