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

delete_issue_modal.vue « components « show « issues « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f86ee11e64b21f78c684b5f10c7ad3c4ab2acb9d (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
<script>
import { GlModal } from '@gitlab/ui';
import csrf from '~/lib/utils/csrf';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
import { __, sprintf } from '~/locale';

export default {
  actionCancel: { text: __('Cancel') },
  csrf,
  components: {
    GlModal,
  },
  props: {
    issuePath: {
      type: String,
      required: false,
      default: '',
    },
    issueType: {
      type: String,
      required: true,
    },
    modalId: {
      type: String,
      required: true,
    },
    title: {
      type: String,
      required: true,
    },
  },
  computed: {
    actionPrimary() {
      return {
        attributes: {
          variant: 'danger',
          'data-qa-selector': 'confirm_delete_issue_button',
        },
        text: this.title,
      };
    },
    bodyText() {
      return this.issueType.toLowerCase() === 'epic'
        ? __('Delete this epic and all descendants?')
        : sprintf(__('%{issuableType} will be removed! Are you sure?'), {
            issuableType: capitalizeFirstCharacter(this.issueType),
          });
    },
  },
  methods: {
    submitForm() {
      this.$emit('delete');
      this.$refs.form.submit();
    },
  },
};
</script>

<template>
  <gl-modal
    :action-cancel="$options.actionCancel"
    :action-primary="actionPrimary"
    :modal-id="modalId"
    size="sm"
    :title="title"
    @primary="submitForm"
  >
    <form ref="form" :action="issuePath" method="post">
      <input type="hidden" name="_method" value="delete" />
      <input type="hidden" name="authenticity_token" :value="$options.csrf.token" />
      <input type="hidden" name="destroy_confirm" value="true" />
      {{ bodyText }}
    </form>
  </gl-modal>
</template>