summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/custom_metrics/components/delete_custom_metric_modal.vue
blob: 7c4117d7e8b6eb018e074849dff850d65f2f9af3 (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
<script>
import { GlModal, GlModalDirective, GlButton } from '@gitlab/ui';
import { s__ } from '~/locale';

export default {
  components: {
    GlModal,
    GlButton,
  },
  directives: {
    'gl-modal': GlModalDirective,
  },
  props: {
    deleteMetricUrl: {
      type: String,
      required: true,
    },
    csrfToken: {
      type: String,
      required: true,
    },
  },
  methods: {
    onSubmit() {
      this.$refs.form.submit();
    },
  },
  descriptionText: s__(
    `Metrics|You're about to permanently delete this metric. This cannot be undone.`,
  ),
  modalId: 'delete-custom-metric-modal',
};
</script>
<template>
  <div class="d-inline-block float-right mr-3">
    <gl-button v-gl-modal="$options.modalId" variant="danger" category="primary">
      {{ __('Delete') }}
    </gl-button>
    <gl-modal
      :title="s__('Metrics|Delete metric?')"
      :ok-title="s__('Metrics|Delete metric')"
      :modal-id="$options.modalId"
      ok-variant="danger"
      @ok="onSubmit"
    >
      {{ $options.descriptionText }}

      <form ref="form" :action="deleteMetricUrl" method="post">
        <input type="hidden" name="_method" value="delete" />
        <input :value="csrfToken" type="hidden" name="authenticity_token" />
      </form>
    </gl-modal>
  </div>
</template>