debian-mirror-gitlab/app/assets/javascripts/issue_show/components/edit_actions.vue

92 lines
2.3 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2020-04-22 19:07:51 +05:30
/* eslint-disable @gitlab/vue-require-i18n-strings */
2018-12-13 13:39:08 +05:30
import { __, sprintf } from '~/locale';
import updateMixin from '../mixins/update';
import eventHub from '../event_hub';
2017-09-10 17:25:29 +05:30
2018-12-13 13:39:08 +05:30
const issuableTypes = {
issue: __('Issue'),
epic: __('Epic'),
};
2018-12-05 23:21:45 +05:30
2018-12-13 13:39:08 +05:30
export default {
mixins: [updateMixin],
props: {
canDestroy: {
type: Boolean,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-12-13 13:39:08 +05:30
formState: {
type: Object,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-12-13 13:39:08 +05:30
showDeleteButton: {
type: Boolean,
required: false,
default: true,
2017-09-10 17:25:29 +05:30
},
2018-12-13 13:39:08 +05:30
issuableType: {
type: String,
required: true,
},
},
data() {
return {
deleteLoading: false,
};
},
computed: {
isSubmitEnabled() {
return this.formState.title.trim() !== '';
},
shouldShowDeleteButton() {
return this.canDestroy && this.showDeleteButton;
},
},
methods: {
closeForm() {
eventHub.$emit('close.form');
},
deleteIssuable() {
const confirmMessage = 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;
2017-09-10 17:25:29 +05:30
2019-12-04 20:38:33 +05:30
eventHub.$emit('delete.issuable', { destroy_confirm: true });
2018-12-13 13:39:08 +05:30
}
2017-09-10 17:25:29 +05:30
},
2018-12-13 13:39:08 +05:30
},
};
2017-09-10 17:25:29 +05:30
</script>
<template>
<div class="prepend-top-default append-bottom-default clearfix">
<button
:class="{ disabled: formState.updateLoading || !isSubmitEnabled }"
:disabled="formState.updateLoading || !isSubmitEnabled"
2018-12-05 23:21:45 +05:30
class="btn btn-success float-left qa-save-button"
2018-11-08 19:23:39 +05:30
type="submit"
2019-02-15 15:39:39 +05:30
@click.prevent="updateIssuable"
>
2017-09-10 17:25:29 +05:30
Save changes
2019-02-15 15:39:39 +05:30
<i v-if="formState.updateLoading" class="fa fa-spinner fa-spin" aria-hidden="true"> </i>
2017-09-10 17:25:29 +05:30
</button>
2019-09-30 21:07:59 +05:30
<button class="btn btn-default float-right" type="button" @click="closeForm">
{{ __('Cancel') }}
</button>
2017-09-10 17:25:29 +05:30
<button
2018-03-17 18:26:18 +05:30
v-if="shouldShowDeleteButton"
2017-09-10 17:25:29 +05:30
:class="{ disabled: deleteLoading }"
:disabled="deleteLoading"
2018-12-05 23:21:45 +05:30
class="btn btn-danger float-right append-right-default qa-delete-button"
2018-11-08 19:23:39 +05:30
type="button"
2019-02-15 15:39:39 +05:30
@click="deleteIssuable"
>
Delete <i v-if="deleteLoading" class="fa fa-spinner fa-spin" aria-hidden="true"> </i>
2017-09-10 17:25:29 +05:30
</button>
</div>
</template>