summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/trigger_block.vue
blob: 4a9b2903eecff81b5e09f19f6c07d50bc652d4dd (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
<script>
import { GlButton } from '@gitlab/ui';

export default {
  components: {
    GlButton,
  },
  props: {
    trigger: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      areVariablesVisible: false,
    };
  },
  computed: {
    hasVariables() {
      return this.trigger.variables && this.trigger.variables.length > 0;
    },
  },
  methods: {
    revealVariables() {
      this.areVariablesVisible = true;
    },
  },
};
</script>

<template>
  <div class="build-widget block">
    <h4 class="title">{{ __('Trigger') }}</h4>

    <p v-if="trigger.short_token" class="js-short-token">
      <span class="build-light-text"> {{ __('Token') }} </span> {{ trigger.short_token }}
    </p>

    <p v-if="hasVariables">
      <gl-button
        v-if="!areVariablesVisible"
        type="button"
        class="btn btn-default group js-reveal-variables"
        @click="revealVariables"
      >
        {{ __('Reveal Variables') }}
      </gl-button>
    </p>

    <dl v-if="areVariablesVisible" class="js-build-variables trigger-build-variables">
      <template v-for="variable in trigger.variables">
        <dt :key="`${variable.key}-variable`" class="js-build-variable trigger-build-variable">
          {{ variable.key }}
        </dt>

        <dd :key="`${variable.key}-value`" class="js-build-value trigger-build-value">
          {{ variable.value }}
        </dd>
      </template>
    </dl>
  </div>
</template>