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

environment_pin.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: 1a63bfa2c1ca64e875f99b0f90b5c0b4e72b8580 (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
<script>
/**
 * Renders a prevent auto-stop button.
 * Used in environments table.
 */
import { GlDisclosureDropdownItem } from '@gitlab/ui';
import { __ } from '~/locale';
import eventHub from '../event_hub';
import cancelAutoStopMutation from '../graphql/mutations/cancel_auto_stop.mutation.graphql';

export default {
  components: {
    GlDisclosureDropdownItem,
  },
  props: {
    autoStopUrl: {
      type: String,
      required: true,
    },
    graphql: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  data() {
    return {
      item: { text: __('Prevent auto-stopping') },
    };
  },
  methods: {
    onPinClick() {
      if (this.graphql) {
        this.$apollo.mutate({
          mutation: cancelAutoStopMutation,
          variables: { autoStopUrl: this.autoStopUrl },
        });
      } else {
        eventHub.$emit('cancelAutoStop', this.autoStopUrl);
      }
    },
  },
};
</script>
<template>
  <gl-disclosure-dropdown-item :item="item" @action="onPinClick" />
</template>