summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/integrations/edit/components/trigger_field.vue
blob: dc5ae2f3a3de43c1702362442da577d74db12251 (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
<script>
import { GlFormCheckbox } from '@gitlab/ui';
import { mapGetters } from 'vuex';

import { integrationTriggerEventTitles } from '~/integrations/constants';

export default {
  name: 'TriggerField',
  components: {
    GlFormCheckbox,
  },
  props: {
    event: {
      type: Object,
      required: false,
      default: () => ({}),
    },
  },
  data() {
    return {
      value: false,
    };
  },
  computed: {
    ...mapGetters(['isInheriting']),
    name() {
      return `service[${this.event.name}]`;
    },
    title() {
      return integrationTriggerEventTitles[this.event.name];
    },
  },
  mounted() {
    this.value = this.event.value || false;
  },
};
</script>

<template>
  <div>
    <input :name="name" type="hidden" :value="value" />
    <gl-form-checkbox v-model="value" :disabled="isInheriting">
      {{ title }}
    </gl-form-checkbox>
  </div>
</template>