summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/components/environment_rollback.vue
blob: 605a88e997e0644f04f2e0919701e49bdea285d4 (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
<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 {
    components: {
      loadingIcon,
    },

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

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

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

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

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

    <span v-if="isLastDeployment">
      {{ s__("Environments|Re-deploy") }}
    </span>
    <span v-else>
      {{ s__("Environments|Rollback") }}
    </span>

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