Newer
Older
/**
* Renders Rollback or Re deploy button in environments table depending

Filipa Lacerda
committed
* of the provided property `isLastDeployment`.
*
* Makes a post request when the button is clicked.

Filipa Lacerda
committed
import eventHub from '../event_hub';
import loadingIcon from '../../vue_shared/components/loading_icon.vue';

Filipa Lacerda
committed
export default {
props: {
retryUrl: {
type: String,
default: '',
},
isLastDeployment: {
type: Boolean,
default: true,

Filipa Lacerda
committed
},
components: {
loadingIcon,
},

Filipa Lacerda
committed
data() {
return {
isLoading: false,
};
},
methods: {
onClick() {
this.isLoading = true;
eventHub.$emit('postAction', this.retryUrl);

Filipa Lacerda
committed
},
};
</script>
<template>
<button
type="button"
class="btn"
@click="onClick"
:disabled="isLoading">
<span v-if="isLastDeployment">
Re-deploy
</span>
<span v-else>
Rollback
</span>

Filipa Lacerda
committed
<loading-icon v-if="isLoading" />