summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/components/environment_rollback.vue
blob: 2ba985bfe3e6d0802cbfe3647d9f530cd930bbd5 (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
<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 eventHub from '../event_hub';
import loadingIcon from '../../vue_shared/components/loading_icon.vue';

export default {
  props: {
    retryUrl: {
      type: String,
      default: '',
    },

    isLastDeployment: {
      type: Boolean,
      default: true,
    },
  },

  components: {
    loadingIcon,
  },

  data() {
    return {
      isLoading: false,
    };
  },

  methods: {
    onClick() {
      this.isLoading = true;

      eventHub.$emit('postAction', this.retryUrl);
    },
  },
};
</script>
<template>
  <button
    type="button"
    class="btn"
    @click="onClick"
    :disabled="isLoading">

    <span v-if="isLastDeployment">
      Re-deploy
    </span>
    <span v-else>
      Rollback
    </span>

    <loading-icon v-if="isLoading" />
  </button>
</template>