debian-mirror-gitlab/app/assets/javascripts/environments/components/environment_rollback.vue

60 lines
1,002 B
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
/**
* Renders Rollback or Re deploy button in environments table depending
* of the provided property `isLastDeployment`.
*
* Makes a post request when the button is clicked.
*/
import eventHub from '../event_hub';
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 {
props: {
retryUrl: {
type: String,
default: '',
},
isLastDeployment: {
type: Boolean,
default: true,
},
},
2017-09-10 17:25:29 +05:30
components: {
loadingIcon,
},
2017-08-17 22:00:37 +05:30
data() {
return {
isLoading: false,
};
},
methods: {
onClick() {
this.isLoading = true;
eventHub.$emit('postAction', this.retryUrl);
},
},
};
</script>
<template>
<button
type="button"
2017-09-10 17:25:29 +05:30
class="btn hidden-xs hidden-sm"
2017-08-17 22:00:37 +05:30
@click="onClick"
:disabled="isLoading">
<span v-if="isLastDeployment">
Re-deploy
</span>
<span v-else>
Rollback
</span>
2017-09-10 17:25:29 +05:30
<loading-icon v-if="isLoading" />
2017-08-17 22:00:37 +05:30
</button>
</template>