2020-04-22 19:07:51 +05:30
|
|
|
<script>
|
|
|
|
/**
|
|
|
|
* Renders the delete button that allows deleting a stopped environment.
|
|
|
|
* Used in the environments table and the environment detail view.
|
|
|
|
*/
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
import { GlTooltipDirective, GlIcon } from '@gitlab/ui';
|
2020-04-22 19:07:51 +05:30
|
|
|
import { s__ } from '~/locale';
|
|
|
|
import eventHub from '../event_hub';
|
|
|
|
import LoadingButton from '../../vue_shared/components/loading_button.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-11-24 15:15:51 +05:30
|
|
|
GlIcon,
|
2020-04-22 19:07:51 +05:30
|
|
|
LoadingButton,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
environment: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
title() {
|
|
|
|
return s__('Environments|Delete environment');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
eventHub.$on('deleteEnvironment', this.onDeleteEnvironment);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
eventHub.$off('deleteEnvironment', this.onDeleteEnvironment);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick() {
|
2021-01-03 14:25:43 +05:30
|
|
|
this.$root.$emit('bv::hide::tooltip', this.$options.deleteEnvironmentTooltipId);
|
2020-04-22 19:07:51 +05:30
|
|
|
eventHub.$emit('requestDeleteEnvironment', this.environment);
|
|
|
|
},
|
|
|
|
onDeleteEnvironment(environment) {
|
|
|
|
if (this.environment.id === environment.id) {
|
|
|
|
this.isLoading = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2021-01-03 14:25:43 +05:30
|
|
|
deleteEnvironmentTooltipId: 'delete-environment-button-tooltip',
|
2020-04-22 19:07:51 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<loading-button
|
2021-01-03 14:25:43 +05:30
|
|
|
v-gl-tooltip="{ id: $options.deleteEnvironmentTooltipId }"
|
2020-04-22 19:07:51 +05:30
|
|
|
:loading="isLoading"
|
|
|
|
:title="title"
|
|
|
|
:aria-label="title"
|
2021-01-03 14:25:43 +05:30
|
|
|
container-class="btn btn-danger d-none d-md-block"
|
2020-04-22 19:07:51 +05:30
|
|
|
data-toggle="modal"
|
|
|
|
data-target="#delete-environment-modal"
|
|
|
|
@click="onClick"
|
|
|
|
>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-icon name="remove" />
|
2020-04-22 19:07:51 +05:30
|
|
|
</loading-button>
|
|
|
|
</template>
|