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

59 lines
1.1 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
import eventHub from '../eventhub';
2017-09-10 17:25:29 +05:30
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
2017-08-17 22:00:37 +05:30
export default {
2018-03-17 18:26:18 +05:30
components: {
loadingIcon,
2017-08-17 22:00:37 +05:30
},
props: {
deployKey: {
type: Object,
required: true,
},
type: {
type: String,
required: true,
},
btnCssClass: {
type: String,
required: false,
default: 'btn-default',
},
},
2018-03-17 18:26:18 +05:30
data() {
return {
isLoading: false,
};
},
computed: {
text() {
return `${this.type.charAt(0).toUpperCase()}${this.type.slice(1)}`;
},
2017-09-10 17:25:29 +05:30
},
2017-08-17 22:00:37 +05:30
methods: {
doAction() {
this.isLoading = true;
2018-03-17 18:26:18 +05:30
eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
this.isLoading = false;
});
2017-08-17 22:00:37 +05:30
},
},
};
</script>
<template>
<button
class="btn btn-sm prepend-left-10"
:class="[{ disabled: isLoading }, btnCssClass]"
:disabled="isLoading"
@click="doAction">
{{ text }}
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>