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

54 lines
905 B
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-12-13 13:39:08 +05:30
import { GlLoadingIcon } from '@gitlab-org/gitlab-ui';
2018-10-15 14:42:47 +05:30
import eventHub from '../eventhub';
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
export default {
2018-12-13 13:39:08 +05:30
components: {
GlLoadingIcon,
},
2018-10-15 14:42:47 +05:30
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
:class="[{ disabled: isLoading }, btnCssClass]"
:disabled="isLoading"
2018-11-08 19:23:39 +05:30
class="btn"
2017-08-17 22:00:37 +05:30
@click="doAction">
2018-10-15 14:42:47 +05:30
<slot></slot>
2018-12-05 23:21:45 +05:30
<gl-loading-icon
2018-03-17 18:26:18 +05:30
v-if="isLoading"
:inline="true"
/>
2017-08-17 22:00:37 +05:30
</button>
</template>