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

promote_milestone_modal.vue « components « shared « milestones « pages « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f80ab8c3b0beee238e10dc69cf28a3f24778a082 (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
<script>
import axios from '~/lib/utils/axios_utils';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
import { s__, sprintf } from '~/locale';
import { visitUrl } from '~/lib/utils/url_utility';
import eventHub from '../event_hub';

export default {
  components: {
    GlModal: DeprecatedModal2,
  },
  props: {
    milestoneTitle: {
      type: String,
      required: true,
    },
    url: {
      type: String,
      required: true,
    },
    groupName: {
      type: String,
      required: true,
    },
  },
  computed: {
    title() {
      return sprintf(s__('Milestones|Promote %{milestoneTitle} to group milestone?'), {
        milestoneTitle: this.milestoneTitle,
      });
    },
    text() {
      return sprintf(
        s__(`Milestones|Promoting %{milestoneTitle} will make it available for all projects inside %{groupName}.
        Existing project milestones with the same title will be merged.`),
        { milestoneTitle: this.milestoneTitle, groupName: this.groupName },
      );
    },
  },
  methods: {
    onSubmit() {
      eventHub.$emit('promoteMilestoneModal.requestStarted', this.url);
      return axios
        .post(this.url, { params: { format: 'json' } })
        .then((response) => {
          eventHub.$emit('promoteMilestoneModal.requestFinished', {
            milestoneUrl: this.url,
            successful: true,
          });
          visitUrl(response.data.url);
        })
        .catch((error) => {
          eventHub.$emit('promoteMilestoneModal.requestFinished', {
            milestoneUrl: this.url,
            successful: false,
          });
          createFlash(error);
        });
    },
  },
};
</script>
<template>
  <gl-modal
    id="promote-milestone-modal"
    :footer-primary-button-text="s__('Milestones|Promote Milestone')"
    footer-primary-button-variant="warning"
    @submit="onSubmit"
  >
    <template #title>
      {{ title }}
    </template>
    <div>
      <p>{{ text }}</p>
      <p>{{ s__('Milestones|This action cannot be reversed.') }}</p>
    </div>
  </gl-modal>
</template>