2017-04-28 12:06:19 -04:00
|
|
|
<script>
|
2018-05-07 14:21:34 -04:00
|
|
|
import loadingIcon from '~/vue_shared/components/loading_icon.vue';
|
|
|
|
import eventHub from '../eventhub';
|
2017-04-28 12:06:19 -04:00
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
loadingIcon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
deployKey: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
btnCssClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'btn-default',
|
2018-01-05 09:31:01 -05:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
doAction() {
|
|
|
|
this.isLoading = true;
|
2017-04-28 12:06:19 -04:00
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
},
|
|
|
|
};
|
2017-04-28 12:06:19 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<button
|
2018-05-07 14:21:34 -04:00
|
|
|
class="btn"
|
2017-04-28 12:06:19 -04:00
|
|
|
:class="[{ disabled: isLoading }, btnCssClass]"
|
|
|
|
:disabled="isLoading"
|
|
|
|
@click="doAction">
|
2018-05-07 14:21:34 -04:00
|
|
|
<slot></slot>
|
2017-12-07 03:48:17 -05:00
|
|
|
<loading-icon
|
|
|
|
v-if="isLoading"
|
|
|
|
:inline="true"
|
|
|
|
/>
|
2017-04-28 12:06:19 -04:00
|
|
|
</button>
|
|
|
|
</template>
|