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