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

52 lines
881 B
Vue
Raw Normal View History

<script>
2018-11-16 14:29:11 -05:00
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',
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"
2018-11-16 15:07:38 -05:00
@click="doAction"
>
<slot></slot>
2018-11-16 15:07:38 -05:00
<gl-loading-icon v-if="isLoading" :inline="true" />
</button>
</template>