Welcome to mirror list, hosted at ThFree Co, Russian Federation.

environment_rollback.vue « components « environments « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 291d8558a7499d963cfa77de02438000a68748ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<script>
/**
 * 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 { GlDisclosureDropdownItem, GlModalDirective } from '@gitlab/ui';
import { s__ } from '~/locale';
import eventHub from '../event_hub';
import setEnvironmentToRollback from '../graphql/mutations/set_environment_to_rollback.mutation.graphql';

export default {
  components: {
    GlDisclosureDropdownItem,
  },
  directives: {
    GlModal: GlModalDirective,
  },
  props: {
    isLastDeployment: {
      type: Boolean,
      default: true,
      required: false,
    },

    environment: {
      type: Object,
      required: true,
    },

    retryUrl: {
      type: String,
      required: true,
    },

    graphql: {
      type: Boolean,
      required: false,
      default: false,
    },
  },

  data() {
    return {
      item: {
        text: this.isLastDeployment
          ? s__('Environments|Re-deploy to environment')
          : s__('Environments|Rollback environment'),
      },
    };
  },

  methods: {
    onClick() {
      const rollbackEnvironmentData = {
        ...this.environment,
        retryUrl: this.retryUrl,
        isLastDeployment: this.isLastDeployment,
      };
      if (this.graphql) {
        this.$apollo.mutate({
          mutation: setEnvironmentToRollback,
          variables: {
            environment: rollbackEnvironmentData,
          },
        });
      } else {
        eventHub.$emit('requestRollbackEnvironment', rollbackEnvironmentData);
      }
    },
  },
};
</script>
<template>
  <gl-disclosure-dropdown-item v-gl-modal.confirm-rollback-modal :item="item" @action="onClick" />
</template>