debian-mirror-gitlab/app/assets/javascripts/deploy_keys/components/action_btn.vue

54 lines
913 B
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-10-15 14:42:47 +05:30
import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import eventHub from '../eventhub';
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
export default {
components: {
loadingIcon,
},
props: {
deployKey: {
type: Object,
required: true,
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
type: {
type: String,
required: true,
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
btnCssClass: {
type: String,
required: false,
default: 'btn-default',
2018-03-17 18:26:18 +05:30
},
2018-10-15 14:42:47 +05:30
},
data() {
return {
isLoading: false,
};
},
methods: {
doAction() {
this.isLoading = true;
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
this.isLoading = false;
});
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
},
};
2017-08-17 22:00:37 +05:30
</script>
<template>
<button
2018-10-15 14:42:47 +05:30
class="btn"
2017-08-17 22:00:37 +05:30
:class="[{ disabled: isLoading }, btnCssClass]"
:disabled="isLoading"
@click="doAction">
2018-10-15 14:42:47 +05:30
<slot></slot>
2018-03-17 18:26:18 +05:30
<loading-icon
v-if="isLoading"
:inline="true"
/>
2017-08-17 22:00:37 +05:30
</button>
</template>