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

71 lines
1.4 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.
*/
2021-11-18 22:05:49 +05:30
import { GlModalDirective, GlDropdownItem } from '@gitlab/ui';
2018-11-18 11:00:15 +05:30
import { s__ } from '~/locale';
import eventHub from '../event_hub';
export default {
components: {
2021-11-18 22:05:49 +05:30
GlDropdownItem,
2018-11-18 11:00:15 +05:30
},
directives: {
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>
2021-11-18 22:05:49 +05:30
<gl-dropdown-item v-gl-modal.confirm-rollback-modal @click="onClick">
{{ title }}
</gl-dropdown-item>
2017-08-17 22:00:37 +05:30
</template>