2017-04-28 12:06:19 -04:00
|
|
|
<script>
|
|
|
|
import eventHub from '../eventhub';
|
2017-05-10 11:52:09 -04:00
|
|
|
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
|
2017-04-28 12:06:19 -04:00
|
|
|
|
|
|
|
export default {
|
2018-01-05 09:31:01 -05:00
|
|
|
components: {
|
|
|
|
loadingIcon,
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
deployKey: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
btnCssClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'btn-default',
|
|
|
|
},
|
|
|
|
},
|
2018-01-05 09:31:01 -05:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
text() {
|
|
|
|
return `${this.type.charAt(0).toUpperCase()}${this.type.slice(1)}`;
|
|
|
|
},
|
2017-05-10 11:52:09 -04:00
|
|
|
},
|
2017-04-28 12:06:19 -04:00
|
|
|
methods: {
|
|
|
|
doAction() {
|
|
|
|
this.isLoading = true;
|
|
|
|
|
2017-12-07 03:48:17 -05:00
|
|
|
eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<button
|
|
|
|
class="btn btn-sm prepend-left-10"
|
|
|
|
:class="[{ disabled: isLoading }, btnCssClass]"
|
|
|
|
:disabled="isLoading"
|
|
|
|
@click="doAction">
|
|
|
|
{{ text }}
|
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>
|