gitlab-org--gitlab-foss/app/assets/javascripts/environments/components/environment_stop.vue

71 lines
1.5 KiB
Vue
Raw Normal View History

2017-04-20 05:04:06 -04:00
<script>
/**
* Renders the stop "button" that allows stop an environment.
* Used in environments table.
*/
import $ from 'jquery';
2018-11-16 14:29:11 -05:00
import { GlTooltipDirective } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import { s__ } from '~/locale';
import eventHub from '../event_hub';
import LoadingButton from '../../vue_shared/components/loading_button.vue';
2016-11-09 13:52:26 -05:00
export default {
components: {
Icon,
LoadingButton,
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
environment: {
type: Object,
required: true,
2018-01-06 13:59:49 -05:00
},
},
data() {
return {
isLoading: false,
};
},
computed: {
title() {
return s__('Environments|Stop environment');
},
},
mounted() {
eventHub.$on('stopEnvironment', this.onStopEnvironment);
},
beforeDestroy() {
eventHub.$off('stopEnvironment', this.onStopEnvironment);
},
methods: {
onClick() {
$(this.$el).tooltip('dispose');
eventHub.$emit('requestStopEnvironment', this.environment);
},
onStopEnvironment(environment) {
if (this.environment.id === environment.id) {
this.isLoading = true;
}
},
},
};
2017-04-20 05:04:06 -04:00
</script>
<template>
<loading-button
v-gl-tooltip
:loading="isLoading"
2018-06-11 05:49:47 -04:00
:title="title"
:aria-label="title"
container-class="btn btn-danger d-none d-sm-none d-md-block"
data-toggle="modal"
data-target="#stop-environment-modal"
2017-04-20 05:04:06 -04:00
@click="onClick"
2018-01-06 13:59:49 -05:00
>
2018-11-16 15:07:38 -05:00
<icon name="stop" />
</loading-button>
2017-04-20 05:04:06 -04:00
</template>