2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
2019-02-15 15:39:39 +05:30
|
|
|
import { GlLoadingIcon } from '@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"
|
2019-02-15 15:39:39 +05:30
|
|
|
@click="doAction"
|
|
|
|
>
|
2018-10-15 14:42:47 +05:30
|
|
|
<slot></slot>
|
2019-02-15 15:39:39 +05:30
|
|
|
<gl-loading-icon v-if="isLoading" :inline="true" />
|
2017-08-17 22:00:37 +05:30
|
|
|
</button>
|
|
|
|
</template>
|