debian-mirror-gitlab/app/assets/javascripts/environments/components/environment_delete.vue

60 lines
1.2 KiB
Vue
Raw Normal View History

2020-04-22 19:07:51 +05:30
<script>
/**
* Renders the delete button that allows deleting a stopped environment.
2021-01-29 00:20:46 +05:30
* Used in the environments table.
2020-04-22 19:07:51 +05:30
*/
2021-11-18 22:05:49 +05:30
import { GlDropdownItem, GlModalDirective } from '@gitlab/ui';
2020-04-22 19:07:51 +05:30
import { s__ } from '~/locale';
import eventHub from '../event_hub';
export default {
components: {
2021-11-18 22:05:49 +05:30
GlDropdownItem,
2020-04-22 19:07:51 +05:30
},
directives: {
2021-01-29 00:20:46 +05:30
GlModalDirective,
2020-04-22 19:07:51 +05:30
},
props: {
environment: {
type: Object,
required: true,
},
},
data() {
return {
isLoading: false,
};
},
2021-11-18 22:05:49 +05:30
i18n: {
title: s__('Environments|Delete environment'),
2020-04-22 19:07:51 +05:30
},
mounted() {
eventHub.$on('deleteEnvironment', this.onDeleteEnvironment);
},
beforeDestroy() {
eventHub.$off('deleteEnvironment', this.onDeleteEnvironment);
},
methods: {
onClick() {
eventHub.$emit('requestDeleteEnvironment', this.environment);
},
onDeleteEnvironment(environment) {
if (this.environment.id === environment.id) {
this.isLoading = true;
}
},
},
};
</script>
<template>
2021-11-18 22:05:49 +05:30
<gl-dropdown-item
v-gl-modal-directive.delete-environment-modal
2020-04-22 19:07:51 +05:30
:loading="isLoading"
2021-01-29 00:20:46 +05:30
variant="danger"
2020-04-22 19:07:51 +05:30
@click="onClick"
2021-11-18 22:05:49 +05:30
>
{{ $options.i18n.title }}
</gl-dropdown-item>
2020-04-22 19:07:51 +05:30
</template>