debian-mirror-gitlab/app/assets/javascripts/deploy_keys/components/action_btn.vue
2019-02-15 15:39:39 +05:30

52 lines
881 B
Vue

<script>
import { GlLoadingIcon } from '@gitlab/ui';
import eventHub from '../eventhub';
export default {
components: {
GlLoadingIcon,
},
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>