2017-04-28 12:06:19 -04:00
|
|
|
<script>
|
2018-11-16 14:29:11 -05:00
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
2018-05-07 14:21:34 -04:00
|
|
|
import eventHub from '../eventhub';
|
2017-04-28 12:06:19 -04:00
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
export default {
|
2018-11-07 05:06:15 -05:00
|
|
|
components: {
|
|
|
|
GlLoadingIcon,
|
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
props: {
|
|
|
|
deployKey: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
btnCssClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'btn-default',
|
2018-01-05 09:31:01 -05:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
doAction() {
|
|
|
|
this.isLoading = true;
|
2017-04-28 12:06:19 -04:00
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
2017-04-28 12:06:19 -04:00
|
|
|
},
|
2018-05-07 14:21:34 -04:00
|
|
|
},
|
|
|
|
};
|
2017-04-28 12:06:19 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<button
|
|
|
|
:class="[{ disabled: isLoading }, btnCssClass]"
|
|
|
|
:disabled="isLoading"
|
2018-06-11 05:49:47 -04:00
|
|
|
class="btn"
|
2018-11-16 15:07:38 -05:00
|
|
|
@click="doAction"
|
|
|
|
>
|
2018-05-07 14:21:34 -04:00
|
|
|
<slot></slot>
|
2018-11-16 15:07:38 -05:00
|
|
|
<gl-loading-icon v-if="isLoading" :inline="true" />
|
2017-04-28 12:06:19 -04:00
|
|
|
</button>
|
|
|
|
</template>
|