gitlab-org--gitlab-foss/app/assets/javascripts/deploy_keys/components/action_btn.vue
2018-11-20 09:30:01 -06:00

51 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>