2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
2018-11-18 11:00:15 +05:30
|
|
|
/**
|
|
|
|
* 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 { s__ } from '~/locale';
|
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import tooltip from '~/vue_shared/directives/tooltip';
|
|
|
|
import eventHub from '../event_hub';
|
|
|
|
import LoadingIcon from '../../vue_shared/components/loading_icon.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
LoadingIcon,
|
|
|
|
},
|
|
|
|
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
retryUrl: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
isLastDeployment: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
title() {
|
|
|
|
return this.isLastDeployment ? s__('Environments|Re-deploy to environment') : s__('Environments|Rollback environment');
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onClick() {
|
|
|
|
this.isLoading = true;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
eventHub.$emit('postAction', { endpoint: this.retryUrl });
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<button
|
2018-11-18 11:00:15 +05:30
|
|
|
v-tooltip
|
2018-11-08 19:23:39 +05:30
|
|
|
:disabled="isLoading"
|
2018-11-18 11:00:15 +05:30
|
|
|
:title="title"
|
2017-08-17 22:00:37 +05:30
|
|
|
type="button"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="btn d-none d-sm-none d-md-block"
|
2017-08-17 22:00:37 +05:30
|
|
|
@click="onClick"
|
2018-03-17 18:26:18 +05:30
|
|
|
>
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
<icon
|
|
|
|
v-if="isLastDeployment"
|
|
|
|
name="repeat" />
|
|
|
|
<icon
|
|
|
|
v-else
|
|
|
|
name="redo"/>
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
<loading-icon v-if="isLoading" />
|
2017-08-17 22:00:37 +05:30
|
|
|
</button>
|
|
|
|
</template>
|