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

edit_actions.vue « components « issue_show « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 20c759cfbbd4ede8b4b7f90b7d7e743ee654f9f1 (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
<script>
import { GlButton } from '@gitlab/ui';
import { __, sprintf } from '~/locale';
import eventHub from '../event_hub';
import updateMixin from '../mixins/update';

const issuableTypes = {
  issue: __('Issue'),
  epic: __('Epic'),
};

export default {
  components: {
    GlButton,
  },
  mixins: [updateMixin],
  props: {
    canDestroy: {
      type: Boolean,
      required: true,
    },
    formState: {
      type: Object,
      required: true,
    },
    showDeleteButton: {
      type: Boolean,
      required: false,
      default: true,
    },
    issuableType: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      deleteLoading: false,
    };
  },
  computed: {
    isSubmitEnabled() {
      return this.formState.title.trim() !== '';
    },
    shouldShowDeleteButton() {
      return this.canDestroy && this.showDeleteButton;
    },
    deleteIssuableButtonText() {
      return sprintf(__('Delete %{issuableType}'), {
        issuableType: issuableTypes[this.issuableType],
      });
    },
  },
  methods: {
    closeForm() {
      eventHub.$emit('close.form');
    },
    deleteIssuable() {
      const confirmMessage =
        this.issuableType === 'epic'
          ? __('Delete this epic and all descendants?')
          : sprintf(__('%{issuableType} will be removed! Are you sure?'), {
              issuableType: issuableTypes[this.issuableType],
            });
      // eslint-disable-next-line no-alert
      if (window.confirm(confirmMessage)) {
        this.deleteLoading = true;

        eventHub.$emit('delete.issuable', { destroy_confirm: true });
      }
    },
  },
};
</script>

<template>
  <div class="gl-mt-3 gl-mb-3 clearfix">
    <gl-button
      :loading="formState.updateLoading"
      :disabled="formState.updateLoading || !isSubmitEnabled"
      category="primary"
      variant="success"
      class="float-left qa-save-button"
      type="submit"
      @click.prevent="updateIssuable"
    >
      {{ __('Save changes') }}
    </gl-button>
    <gl-button class="float-right" @click="closeForm">
      {{ __('Cancel') }}
    </gl-button>
    <gl-button
      v-if="shouldShowDeleteButton"
      :loading="deleteLoading"
      :disabled="deleteLoading"
      category="primary"
      variant="danger"
      class="float-right gl-mr-3 qa-delete-button"
      @click="deleteIssuable"
    >
      {{ deleteIssuableButtonText }}
    </gl-button>
  </div>
</template>