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

delete_button.vue « shared « components « projects « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c749034d2a87c1daa38c071680ec53e9f4c6821c (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<script>
import { GlButton, GlForm } from '@gitlab/ui';
import csrf from '~/lib/utils/csrf';
import { __ } from '~/locale';
import DeleteModal from './delete_modal.vue';

export default {
  components: {
    GlButton,
    GlForm,
    DeleteModal,
  },
  props: {
    confirmPhrase: {
      type: String,
      required: true,
    },
    formPath: {
      type: String,
      required: true,
    },
    isFork: {
      type: Boolean,
      required: true,
    },
    issuesCount: {
      type: Number,
      required: true,
    },
    mergeRequestsCount: {
      type: Number,
      required: true,
    },
    forksCount: {
      type: Number,
      required: true,
    },
    starsCount: {
      type: Number,
      required: true,
    },
  },
  data() {
    return {
      isModalVisible: false,
    };
  },
  computed: {
    csrfToken() {
      return csrf.token;
    },
  },
  methods: {
    submitForm() {
      this.$refs.form.$el.submit();
    },
    onButtonClick() {
      this.isModalVisible = true;
    },
  },
  i18n: {
    deleteProject: __('Delete project'),
  },
};
</script>

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

    <delete-modal
      v-model="isModalVisible"
      :confirm-phrase="confirmPhrase"
      :is-fork="isFork"
      :issues-count="issuesCount"
      :merge-requests-count="mergeRequestsCount"
      :forks-count="forksCount"
      :stars-count="starsCount"
      @primary="submitForm"
    >
      <template #modal-footer>
        <slot name="modal-footer"></slot>
      </template>
    </delete-modal>

    <gl-button
      category="primary"
      variant="danger"
      data-qa-selector="delete_button"
      @click="onButtonClick"
      >{{ $options.i18n.deleteProject }}</gl-button
    >
  </gl-form>
</template>