gitlab-org--gitlab-foss/app/assets/javascripts/environments/components/environment_rollback.vue

60 lines
1,002 B
Vue
Raw Normal View History

2017-04-20 07:48:54 -04:00
<script>
2017-02-09 06:52:22 -05:00
/**
* Renders Rollback or Re deploy button in environments table depending
* of the provided property `isLastDeployment`.
*
* Makes a post request when the button is clicked.
2017-02-09 06:52:22 -05:00
*/
import eventHub from '../event_hub';
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
2016-11-09 13:52:26 -05:00
export default {
2017-02-09 06:52:22 -05:00
props: {
retryUrl: {
type: String,
default: '',
},
2016-12-08 06:54:08 -05:00
2017-02-09 06:52:22 -05:00
isLastDeployment: {
type: Boolean,
default: true,
2016-11-09 13:52:26 -05:00
},
},
components: {
loadingIcon,
},
data() {
return {
isLoading: false,
};
},
methods: {
onClick() {
this.isLoading = true;
eventHub.$emit('postAction', this.retryUrl);
},
2017-02-09 06:52:22 -05:00
},
2017-04-20 07:48:54 -04:00
};
</script>
<template>
<button
type="button"
2017-06-06 08:58:29 -04:00
class="btn hidden-xs hidden-sm"
2017-04-20 07:48:54 -04:00
@click="onClick"
:disabled="isLoading">
2016-11-09 13:52:26 -05:00
2017-04-20 07:48:54 -04:00
<span v-if="isLastDeployment">
Re-deploy
</span>
<span v-else>
Rollback
</span>
<loading-icon v-if="isLoading" />
2017-04-20 07:48:54 -04:00
</button>
</template>