All files / app/assets/javascripts/custom_metrics/components delete_custom_metric_modal.vue

75% Statements 3/4
100% Branches 0/0
0% Functions 0/2
75% Lines 3/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  1x 1x                                                             3x                                          
<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>