debian-mirror-gitlab/app/assets/javascripts/pages/milestones/shared/components/promote_milestone_modal.vue

69 lines
2 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash';
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { s__, sprintf } from '~/locale';
import { visitUrl } from '~/lib/utils/url_utility';
import eventHub from '../event_hub';
export default {
components: {
GlModal,
},
props: {
milestoneTitle: {
type: String,
required: true,
},
url: {
type: String,
required: true,
},
2018-05-01 15:08:00 +05:30
groupName: {
type: String,
required: true,
},
2018-03-27 19:54:05 +05:30
},
computed: {
title() {
return sprintf(s__('Milestones|Promote %{milestoneTitle} to group milestone?'), { milestoneTitle: this.milestoneTitle });
},
text() {
2018-05-01 15:08:00 +05:30
return sprintf(s__(`Milestones|Promoting %{milestoneTitle} will make it available for all projects inside %{groupName}.
2018-03-27 19:54:05 +05:30
Existing project milestones with the same title will be merged.
2018-05-01 15:08:00 +05:30
This action cannot be reversed.`), { milestoneTitle: this.milestoneTitle, groupName: this.groupName });
2018-03-27 19:54:05 +05:30
},
},
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')"
2018-11-08 19:23:39 +05:30
footer-primary-button-variant="warning"
2018-03-27 19:54:05 +05:30
@submit="onSubmit"
>
<template
slot="title"
>
{{ title }}
</template>
{{ text }}
</gl-modal>
</template>