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

70 lines
1.6 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-01-29 00:20:46 +05:30
import { GlTooltipDirective, GlButton, GlModalDirective } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
2020-04-22 19:07:51 +05:30
import { s__ } from '~/locale';
import eventHub from '../event_hub';
export default {
components: {
2021-01-29 00:20:46 +05:30
GlButton,
2020-04-22 19:07:51 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
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,
};
},
computed: {
title() {
return s__('Environments|Delete environment');
},
},
mounted() {
eventHub.$on('deleteEnvironment', this.onDeleteEnvironment);
},
beforeDestroy() {
eventHub.$off('deleteEnvironment', this.onDeleteEnvironment);
},
methods: {
onClick() {
2021-03-11 19:13:27 +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>
2021-01-29 00:20:46 +05:30
<gl-button
2021-01-03 14:25:43 +05:30
v-gl-tooltip="{ id: $options.deleteEnvironmentTooltipId }"
2021-01-29 00:20:46 +05:30
v-gl-modal-directive="'delete-environment-modal'"
2020-04-22 19:07:51 +05:30
:loading="isLoading"
:title="title"
:aria-label="title"
2021-03-11 19:13:27 +05:30
class="gl-display-none gl-md-display-block"
2021-01-29 00:20:46 +05:30
variant="danger"
category="primary"
icon="remove"
2020-04-22 19:07:51 +05:30
@click="onClick"
2021-01-29 00:20:46 +05:30
/>
2020-04-22 19:07:51 +05:30
</template>