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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
1.7 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';
2022-01-26 12:08:38 +05:30
import setEnvironmentToRollback from '../graphql/mutations/set_environment_to_rollback.mutation.graphql';
2018-11-18 11:00:15 +05:30
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,
},
2022-01-26 12:08:38 +05:30
graphql: {
type: Boolean,
required: false,
default: false,
},
2018-11-18 11:00:15 +05:30
},
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() {
2023-01-13 00:05:48 +05:30
const rollbackEnvironmentData = {
...this.environment,
retryUrl: this.retryUrl,
isLastDeployment: this.isLastDeployment,
};
2022-01-26 12:08:38 +05:30
if (this.graphql) {
this.$apollo.mutate({
mutation: setEnvironmentToRollback,
2023-01-13 00:05:48 +05:30
variables: {
environment: rollbackEnvironmentData,
},
2022-01-26 12:08:38 +05:30
});
} else {
2023-01-13 00:05:48 +05:30
eventHub.$emit('requestRollbackEnvironment', rollbackEnvironmentData);
2022-01-26 12:08:38 +05:30
}
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>