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.
|
|
|
|
*/
|
2020-04-22 19:07:51 +05:30
|
|
|
import {
|
|
|
|
GlTooltipDirective,
|
|
|
|
GlLoadingIcon,
|
|
|
|
GlModalDirective,
|
|
|
|
GlDeprecatedButton,
|
|
|
|
} from '@gitlab/ui';
|
2018-11-18 11:00:15 +05:30
|
|
|
import { s__ } from '~/locale';
|
|
|
|
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,
|
2020-04-22 19:07:51 +05:30
|
|
|
GlDeprecatedButton,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
directives: {
|
2019-02-15 15:39:39 +05:30
|
|
|
GlTooltip: GlTooltipDirective,
|
2019-07-07 11:18:12 +05:30
|
|
|
GlModal: GlModalDirective,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
isLastDeployment: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
2020-04-22 19:07:51 +05:30
|
|
|
required: false,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
environment: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
retryUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
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-07-07 11:18:12 +05:30
|
|
|
eventHub.$emit('requestRollbackEnvironment', {
|
|
|
|
...this.environment,
|
|
|
|
retryUrl: this.retryUrl,
|
|
|
|
isLastDeployment: this.isLastDeployment,
|
|
|
|
});
|
|
|
|
eventHub.$on('rollbackEnvironment', environment => {
|
|
|
|
if (environment.id === this.environment.id) {
|
|
|
|
this.isLoading = true;
|
|
|
|
}
|
|
|
|
});
|
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>
|
2020-04-22 19:07:51 +05:30
|
|
|
<gl-deprecated-button
|
2019-02-15 15:39:39 +05:30
|
|
|
v-gl-tooltip
|
2019-07-07 11:18:12 +05:30
|
|
|
v-gl-modal.confirm-rollback-modal
|
2018-11-08 19:23:39 +05:30
|
|
|
:disabled="isLoading"
|
2018-11-18 11:00:15 +05:30
|
|
|
:title="title"
|
2019-07-31 22:56:46 +05:30
|
|
|
class="d-none d-md-block text-secondary"
|
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" />
|
2020-04-22 19:07:51 +05:30
|
|
|
</gl-deprecated-button>
|
2017-08-17 22:00:37 +05:30
|
|
|
</template>
|