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

78 lines
1.6 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.
*/
2020-11-24 15:15:51 +05:30
import { GlTooltipDirective, GlModalDirective, GlButton } from '@gitlab/ui';
2018-11-18 11:00:15 +05:30
import { s__ } from '~/locale';
import eventHub from '../event_hub';
export default {
components: {
2020-11-24 15:15:51 +05:30
GlButton,
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,
});
2021-03-08 18:12:59 +05:30
eventHub.$on('rollbackEnvironment', (environment) => {
2019-07-07 11:18:12 +05:30
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-11-24 15:15:51 +05:30
<gl-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
2021-03-11 19:13:27 +05:30
class="gl-display-none gl-md-display-block text-secondary"
2020-11-24 15:15:51 +05:30
:loading="isLoading"
2018-11-18 11:00:15 +05:30
:title="title"
2020-11-24 15:15:51 +05:30
:icon="isLastDeployment ? 'repeat' : 'redo'"
2017-08-17 22:00:37 +05:30
@click="onClick"
2020-11-24 15:15:51 +05:30
/>
2017-08-17 22:00:37 +05:30
</template>