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

edit_actions.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: 120034b8d67cb249c7d67f9fd265cc2be86d5c41 (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
<script>
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
import Tracking from '~/tracking';
import eventHub from '../event_hub';
import updateMixin from '../mixins/update';
import getIssueStateQuery from '../queries/get_issue_state.query.graphql';

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

const trackingMixin = Tracking.mixin({ label: 'delete_issue' });

export default {
  components: {
    GlButton,
  },
  mixins: [trackingMixin, updateMixin],
  props: {
    endpoint: {
      required: true,
      type: String,
    },
    formState: {
      type: Object,
      required: true,
    },
    issuableType: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      deleteLoading: false,
      skipApollo: false,
      issueState: {},
    };
  },
  apollo: {
    issueState: {
      query: getIssueStateQuery,
      skip() {
        return this.skipApollo;
      },
      result() {
        this.skipApollo = true;
      },
    },
  },
  computed: {
    isSubmitEnabled() {
      return this.formState.title.trim() !== '';
    },
    typeToShow() {
      const { issueState, issuableType } = this;
      const type = issueState.issueType ?? issuableType;
      return issuableTypes[type];
    },
  },
  methods: {
    closeForm() {
      eventHub.$emit('close.form');
    },
  },
};
</script>

<template>
  <div class="gl-mt-3 gl-mb-3 gl-display-flex">
    <gl-button
      :loading="formState.updateLoading"
      :disabled="formState.updateLoading || !isSubmitEnabled"
      category="primary"
      variant="confirm"
      class="gl-mr-3"
      data-testid="issuable-save-button"
      type="submit"
      @click.prevent="updateIssuable"
    >
      {{ __('Save changes') }}
    </gl-button>
    <gl-button data-testid="issuable-cancel-button" @click="closeForm">
      {{ __('Cancel') }}
    </gl-button>
  </div>
</template>