debian-mirror-gitlab/app/assets/javascripts/deploy_keys/components/action_btn.vue
2021-06-08 01:23:25 +05:30

62 lines
999 B
Vue

<script>
import { GlButton } from '@gitlab/ui';
import eventHub from '../eventhub';
export default {
components: {
GlButton,
},
props: {
deployKey: {
type: Object,
required: true,
},
type: {
type: String,
required: true,
},
category: {
type: String,
required: false,
default: 'tertiary',
},
variant: {
type: String,
required: false,
default: 'default',
},
icon: {
type: String,
required: false,
default: '',
},
},
data() {
return {
isLoading: false,
};
},
methods: {
doAction() {
this.isLoading = true;
eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
this.isLoading = false;
});
},
},
};
</script>
<template>
<gl-button
:category="category"
:variant="variant"
:icon="icon"
:loading="isLoading"
class="btn"
@click="doAction"
>
<slot></slot>
</gl-button>
</template>