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';
|
2019-01-03 12:48:30 +05:30
|
|
|
import tooltip from '~/vue_shared/directives/tooltip';
|
2018-11-18 11:00:15 +05:30
|
|
|
import eventHub from '../event_hub';
|
2019-01-03 12:48:30 +05:30
|
|
|
import { GlLoadingIcon } from '@gitlab-org/gitlab-ui';
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Icon,
|
2018-12-13 13:39:08 +05:30
|
|
|
GlLoadingIcon,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
2019-01-03 12:48:30 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
directives: {
|
2019-01-03 12:48:30 +05:30
|
|
|
tooltip,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
2019-01-03 12:48:30 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
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() {
|
2018-12-13 13:39:08 +05:30
|
|
|
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
|
2019-01-03 12:48:30 +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
|
|
|
>
|
2019-01-03 12:48:30 +05:30
|
|
|
|
|
|
|
<icon
|
|
|
|
v-if="isLastDeployment"
|
|
|
|
name="repeat" />
|
|
|
|
<icon
|
|
|
|
v-else
|
|
|
|
name="redo"/>
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
<gl-loading-icon v-if="isLoading" />
|
2017-08-17 22:00:37 +05:30
|
|
|
</button>
|
|
|
|
</template>
|