summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/admin/topics/components/remove_avatar.vue
blob: a54c30a833636db53a8fbb9e788d78f4f497f2c8 (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
<script>
import { uniqueId } from 'lodash';
import { GlButton, GlModal, GlModalDirective, GlSprintf } from '@gitlab/ui';
import { __ } from '~/locale';
import csrf from '~/lib/utils/csrf';

export default {
  components: {
    GlButton,
    GlModal,
    GlSprintf,
  },
  directives: {
    GlModal: GlModalDirective,
  },
  inject: ['path', 'name'],
  data() {
    return {
      modalId: uniqueId('remove-topic-avatar-'),
    };
  },
  methods: {
    deleteApplication() {
      this.$refs.deleteForm.submit();
    },
  },
  i18n: {
    remove: __('Remove avatar'),
    title: __('Remove topic avatar'),
    body: __('Topic avatar for %{name} will be removed. This cannot be undone.'),
  },
  modal: {
    actionPrimary: {
      text: __('Remove'),
      attributes: {
        variant: 'danger',
      },
    },
    actionSecondary: {
      text: __('Cancel'),
      attributes: {
        variant: 'default',
      },
    },
  },
  csrf,
};
</script>
<template>
  <div>
    <gl-button v-gl-modal="modalId" variant="danger" category="secondary" class="gl-mt-2">{{
      $options.i18n.remove
    }}</gl-button>
    <gl-modal
      :title="$options.i18n.title"
      :action-primary="$options.modal.actionPrimary"
      :action-secondary="$options.modal.actionSecondary"
      :modal-id="modalId"
      size="sm"
      @primary="deleteApplication"
      ><gl-sprintf :message="$options.i18n.body"
        ><template #name>{{ name }}</template></gl-sprintf
      >
      <form ref="deleteForm" method="post" :action="path">
        <input type="hidden" name="_method" value="delete" />
        <input type="hidden" name="authenticity_token" :value="$options.csrf.token" />
      </form>
    </gl-modal>
  </div>
</template>