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

stage_button.vue « commit_sidebar « components « ide « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f5a2af006123d92ee6109387c688be89aa415d30 (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
<script>
import $ from 'jquery';
import { mapActions } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
import GlModal from '~/vue_shared/components/gl_modal.vue';

export default {
  components: {
    Icon,
    GlModal,
  },
  directives: {
    tooltip,
  },
  props: {
    path: {
      type: String,
      required: true,
    },
  },
  computed: {
    modalId() {
      return `discard-file-${this.path}`;
    },
    modalTitle() {
      return `Discard changes to ${this.path}?`;
    },
  },
  methods: {
    ...mapActions(['stageChange', 'discardFileChanges']),
    showDiscardModal() {
      $(document.getElementById(this.modalId)).modal('show');
    },
  },
};
</script>

<template>
  <div
    v-once
    class="multi-file-discard-btn d-flex"
  >
    <button
      v-tooltip
      :aria-label="__('Stage changes')"
      :title="__('Stage changes')"
      type="button"
      class="btn btn-blank align-items-center"
      data-container="body"
      data-boundary="viewport"
      data-placement="bottom"
      @click.stop.prevent="stageChange(path)"
    >
      <icon
        :size="16"
        name="mobile-issue-close"
        class="ml-auto mr-auto"
      />
    </button>
    <button
      v-tooltip
      :aria-label="__('Discard changes')"
      :title="__('Discard changes')"
      type="button"
      class="btn btn-blank align-items-center"
      data-container="body"
      data-boundary="viewport"
      data-placement="bottom"
      @click.stop.prevent="showDiscardModal"
    >
      <icon
        :size="16"
        name="remove"
        class="ml-auto mr-auto"
      />
    </button>
    <gl-modal
      :id="modalId"
      :header-title-text="modalTitle"
      :footer-primary-button-text="__('Discard changes')"
      footer-primary-button-variant="danger"
      @submit="discardFileChanges(path)"
    >
      {{ __("You will loose all changes you've made to this file. This action cannot be undone.") }}
    </gl-modal>
  </div>
</template>