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

remove_modal.vue « components « projects « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37f58efcb307aa35875fac1222d166b31faf2d45 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
<script>
import { GlModal, GlModalDirective, GlSprintf, GlFormInput, GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
import { rstrip } from '~/lib/utils/common_utils';
import csrf from '~/lib/utils/csrf';

export default {
  components: {
    GlModal,
    GlSprintf,
    GlFormInput,
    GlButton,
  },
  directives: {
    GlModal: GlModalDirective,
  },
  props: {
    confirmPhrase: {
      type: String,
      required: true,
    },
    warningMessage: {
      type: String,
      required: true,
    },
    formPath: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      userInput: null,
    };
  },
  computed: {
    buttonDisabled() {
      return rstrip(this.userInput) !== this.confirmPhrase;
    },
    csrfToken() {
      return csrf.token;
    },
  },
  methods: {
    submitForm() {
      this.$refs.form.submit();
    },
  },
  strings: {
    removeProject: __('Remove project'),
    title: __('Confirmation required'),
    confirm: __('Confirm'),
    dataLoss: __(
      'This action can lead to data loss. To prevent accidental actions we ask you to confirm your intention.',
    ),
    confirmText: __('Please type %{phrase_code} to proceed or close this modal to cancel.'),
  },
  modalId: 'remove-project-modal',
};
</script>

<template>
  <form ref="form" :action="formPath" method="post">
    <input type="hidden" name="_method" value="delete" />
    <input :value="csrfToken" type="hidden" name="authenticity_token" />
    <gl-button v-gl-modal="$options.modalId" category="primary" variant="danger">{{
      $options.strings.removeProject
    }}</gl-button>
    <gl-modal
      ref="removeModal"
      :modal-id="$options.modalId"
      size="sm"
      ok-variant="danger"
      footer-class="bg-gray-light gl-p-5"
    >
      <template #modal-title>{{ $options.strings.title }}</template>
      <template #modal-footer>
        <div class="gl-w-full gl-display-flex gl-just-content-start gl-m-0">
          <gl-button
            :disabled="buttonDisabled"
            category="primary"
            variant="danger"
            @click="submitForm"
          >
            {{ $options.strings.confirm }}
          </gl-button>
        </div>
      </template>
      <div>
        <p class="gl-text-red-500 gl-font-weight-bold">{{ warningMessage }}</p>
        <p class="gl-mb-0">{{ $options.strings.dataLoss }}</p>
        <p>
          <gl-sprintf :message="$options.strings.confirmText">
            <template #phrase_code>
              <code>{{ confirmPhrase }}</code>
            </template>
          </gl-sprintf>
        </p>
        <gl-form-input
          id="confirm_name_input"
          v-model="userInput"
          name="confirm_name_input"
          type="text"
        />
      </div>
    </gl-modal>
  </form>
</template>