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';
|
2019-05-30 16:15:17 +05:30
|
|
|
import { GlTooltipDirective, GlLoadingIcon } from '@gitlab/ui';
|
2018-11-18 11:00:15 +05:30
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import eventHub from '../event_hub';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Icon,
|
2018-12-13 13:39:08 +05:30
|
|
|
GlLoadingIcon,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
directives: {
|
2019-02-15 15:39:39 +05:30
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
props: {
|
2019-05-30 16:15:17 +05:30
|
|
|
retryUrl: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
|
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() {
|
2019-05-30 16:15:17 +05:30
|
|
|
this.isLoading = true;
|
|
|
|
|
|
|
|
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>
|
2019-05-30 16:15:17 +05:30
|
|
|
<button
|
2019-02-15 15:39:39 +05:30
|
|
|
v-gl-tooltip
|
2018-11-08 19:23:39 +05:30
|
|
|
:disabled="isLoading"
|
2018-11-18 11:00:15 +05:30
|
|
|
:title="title"
|
2019-05-30 16:15:17 +05:30
|
|
|
type="button"
|
|
|
|
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-02-15 15:39:39 +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" />
|
2019-05-30 16:15:17 +05:30
|
|
|
</button>
|
2017-08-17 22:00:37 +05:30
|
|
|
</template>
|