gitlab-org--gitlab-foss/app/assets/javascripts/deploy_keys/components/action_btn.vue
2018-09-11 22:19:21 +00:00

49 lines
810 B
Vue

<script>
import eventHub from '../eventhub';
export default {
props: {
deployKey: {
type: Object,
required: true,
},
type: {
type: String,
required: true,
},
btnCssClass: {
type: String,
required: false,
default: 'btn-default',
},
},
data() {
return {
isLoading: false,
};
},
methods: {
doAction() {
this.isLoading = true;
eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
this.isLoading = false;
});
},
},
};
</script>
<template>
<button
:class="[{ disabled: isLoading }, btnCssClass]"
:disabled="isLoading"
class="btn"
@click="doAction">
<slot></slot>
<gl-loading-icon
v-if="isLoading"
:inline="true"
/>
</button>
</template>