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

68 lines
1.3 KiB
Vue
Raw Normal View History

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-02-15 15:39:39 +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: {
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-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"
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-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" />
2017-08-17 22:00:37 +05:30
</button>
</template>