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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
1.9 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2022-10-11 01:57:18 +05:30
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
2022-01-26 12:08:38 +05:30
import Tracking from '~/tracking';
2018-12-13 13:39:08 +05:30
import eventHub from '../event_hub';
2021-03-11 19:13:27 +05:30
import updateMixin from '../mixins/update';
2021-09-04 01:27:46 +05:30
import getIssueStateQuery from '../queries/get_issue_state.query.graphql';
2017-09-10 17:25:29 +05:30
2018-12-13 13:39:08 +05:30
const issuableTypes = {
issue: __('Issue'),
epic: __('Epic'),
2021-09-04 01:27:46 +05:30
incident: __('Incident'),
2018-12-13 13:39:08 +05:30
};
2018-12-05 23:21:45 +05:30
2022-01-26 12:08:38 +05:30
const trackingMixin = Tracking.mixin({ label: 'delete_issue' });
2018-12-13 13:39:08 +05:30
export default {
2020-11-24 15:15:51 +05:30
components: {
GlButton,
2021-09-04 01:27:46 +05:30
},
2022-01-26 12:08:38 +05:30
mixins: [trackingMixin, updateMixin],
2018-12-13 13:39:08 +05:30
props: {
2022-01-26 12:08:38 +05:30
endpoint: {
required: true,
type: String,
},
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
issuableType: {
type: String,
required: true,
},
},
data() {
return {
deleteLoading: false,
2021-09-04 01:27:46 +05:30
skipApollo: false,
issueState: {},
2018-12-13 13:39:08 +05:30
};
},
2021-09-04 01:27:46 +05:30
apollo: {
issueState: {
query: getIssueStateQuery,
skip() {
return this.skipApollo;
},
result() {
this.skipApollo = true;
},
},
},
2018-12-13 13:39:08 +05:30
computed: {
isSubmitEnabled() {
return this.formState.title.trim() !== '';
},
2021-09-04 01:27:46 +05:30
typeToShow() {
const { issueState, issuableType } = this;
const type = issueState.issueType ?? issuableType;
return issuableTypes[type];
2021-04-17 20:07:23 +05:30
},
2018-12-13 13:39:08 +05:30
},
methods: {
closeForm() {
eventHub.$emit('close.form');
},
},
};
2017-09-10 17:25:29 +05:30
</script>
<template>
2022-10-11 01:57:18 +05:30
<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>
2017-09-10 17:25:29 +05:30
</div>
</template>