gitlab-org--gitlab-foss/app/assets/javascripts/deploy_keys/components/action_btn.vue

50 lines
810 B
Vue
Raw Normal View History

<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',
2018-01-05 09:31:01 -05:00
},
},
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"
2018-06-11 05:49:47 -04:00
class="btn"
@click="doAction">
<slot></slot>
2018-09-11 18:19:21 -04:00
<gl-loading-icon
v-if="isLoading"
:inline="true"
/>
</button>
</template>