debian-mirror-gitlab/app/assets/javascripts/issues/show/components/edit_actions.vue
2022-10-11 01:57:18 +05:30

90 lines
1.9 KiB
Vue

<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>