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

73 lines
1.3 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-03-17 18:26:18 +05:30
/**
* Renders the stop "button" that allows stop an environment.
* Used in environments table.
*/
2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2018-03-17 18:26:18 +05:30
import eventHub from '../event_hub';
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
import tooltip from '../../vue_shared/directives/tooltip';
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
export default {
components: {
loadingIcon,
2017-08-17 22:00:37 +05:30
},
2018-03-17 18:26:18 +05:30
directives: {
tooltip,
},
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
props: {
stopUrl: {
type: String,
default: '',
},
},
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
data() {
return {
isLoading: false,
};
},
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
computed: {
title() {
return 'Stop';
},
2017-08-17 22:00:37 +05:30
},
2018-03-17 18:26:18 +05:30
methods: {
onClick() {
// eslint-disable-next-line no-alert
2018-11-08 19:23:39 +05:30
if (window.confirm('Are you sure you want to stop this environment?')) {
2018-03-17 18:26:18 +05:30
this.isLoading = true;
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
$(this.$el).tooltip('dispose');
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
eventHub.$emit('postAction', this.stopUrl);
}
},
2017-08-17 22:00:37 +05:30
},
2018-03-17 18:26:18 +05:30
};
2017-08-17 22:00:37 +05:30
</script>
<template>
<button
2017-09-10 17:25:29 +05:30
v-tooltip
2017-08-17 22:00:37 +05:30
:disabled="isLoading"
:title="title"
2018-03-17 18:26:18 +05:30
:aria-label="title"
2018-11-08 19:23:39 +05:30
type="button"
class="btn stop-env-link d-none d-sm-none d-md-block"
data-container="body"
@click="onClick"
2018-03-17 18:26:18 +05:30
>
2017-08-17 22:00:37 +05:30
<i
class="fa fa-stop stop-env-icon"
2018-03-17 18:26:18 +05:30
aria-hidden="true"
>
</i>
2017-09-10 17:25:29 +05:30
<loading-icon v-if="isLoading" />
2017-08-17 22:00:37 +05:30
</button>
</template>