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

97 lines
2.1 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlButton } from '@gitlab/ui';
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 {
2020-11-24 15:15:51 +05:30
components: {
GlButton,
},
2018-12-13 13:39:08 +05:30
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>
2020-07-28 23:09:34 +05:30
<div class="gl-mt-3 gl-mb-3 clearfix">
2020-11-24 15:15:51 +05:30
<gl-button
:loading="formState.updateLoading"
2017-09-10 17:25:29 +05:30
:disabled="formState.updateLoading || !isSubmitEnabled"
2020-11-24 15:15:51 +05:30
category="primary"
variant="success"
class="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"
>
2020-11-24 15:15:51 +05:30
{{ __('Save changes') }}
</gl-button>
<gl-button class="float-right" @click="closeForm">
2019-09-30 21:07:59 +05:30
{{ __('Cancel') }}
2020-11-24 15:15:51 +05:30
</gl-button>
<gl-button
2018-03-17 18:26:18 +05:30
v-if="shouldShowDeleteButton"
2020-11-24 15:15:51 +05:30
:loading="deleteLoading"
2017-09-10 17:25:29 +05:30
:disabled="deleteLoading"
2020-11-24 15:15:51 +05:30
category="primary"
variant="danger"
class="float-right gl-mr-3 qa-delete-button"
2019-02-15 15:39:39 +05:30
@click="deleteIssuable"
>
2020-11-24 15:15:51 +05:30
{{ __('Delete') }}
</gl-button>
2017-09-10 17:25:29 +05:30
</div>
</template>