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

79 lines
1.5 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-11-18 11:00:15 +05:30
/**
* Renders the stop "button" that allows stop an environment.
* Used in environments table.
*/
2018-05-09 12:01:36 +05:30
2018-11-18 11:00:15 +05:30
import $ from 'jquery';
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';
import tooltip from '../../vue_shared/directives/tooltip';
2017-08-17 22:00:37 +05:30
2018-11-18 11:00:15 +05:30
export default {
components: {
Icon,
LoadingButton,
},
2017-08-17 22:00:37 +05:30
2018-11-18 11:00:15 +05:30
directives: {
tooltip,
},
2017-09-10 17:25:29 +05:30
2018-11-18 11:00:15 +05:30
props: {
environment: {
type: Object,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-11-18 11:00:15 +05:30
},
2017-08-17 22:00:37 +05:30
2018-11-18 11:00:15 +05:30
data() {
return {
isLoading: false,
};
},
2017-09-10 17:25:29 +05:30
2018-11-18 11:00:15 +05:30
computed: {
title() {
return s__('Environments|Stop environment');
2017-08-17 22:00:37 +05:30
},
2018-11-18 11:00:15 +05:30
},
2017-08-17 22:00:37 +05:30
2018-11-18 11:00:15 +05:30
mounted() {
eventHub.$on('stopEnvironment', this.onStopEnvironment);
},
2017-08-17 22:00:37 +05:30
2018-11-18 11:00:15 +05:30
beforeDestroy() {
eventHub.$off('stopEnvironment', this.onStopEnvironment);
},
2017-08-17 22:00:37 +05:30
2018-11-18 11:00:15 +05:30
methods: {
onClick() {
$(this.$el).tooltip('dispose');
eventHub.$emit('requestStopEnvironment', this.environment);
},
onStopEnvironment(environment) {
if (this.environment.id === environment.id) {
this.isLoading = true;
}
2017-08-17 22:00:37 +05:30
},
2018-11-18 11:00:15 +05:30
},
};
2017-08-17 22:00:37 +05:30
</script>
<template>
2018-11-18 11:00:15 +05:30
<loading-button
2017-09-10 17:25:29 +05:30
v-tooltip
2018-11-18 11:00:15 +05:30
:loading="isLoading"
2017-08-17 22:00:37 +05:30
:title="title"
2018-03-17 18:26:18 +05:30
:aria-label="title"
2018-11-18 11:00:15 +05:30
container-class="btn btn-danger d-none d-sm-none d-md-block"
2018-11-08 19:23:39 +05:30
data-container="body"
2018-11-18 11:00:15 +05:30
data-toggle="modal"
data-target="#stop-environment-modal"
2018-11-08 19:23:39 +05:30
@click="onClick"
2018-03-17 18:26:18 +05:30
>
2018-11-18 11:00:15 +05:30
<icon name="stop"/>
</loading-button>
2017-08-17 22:00:37 +05:30
</template>