summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/trigger_block.vue
blob: d7b3c4fcb5b720595afb1af4b07bf0075d3b3f8a (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<script>
  export default {
    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">
      <button
        v-if="!areVariablesVisible"
        type="button"
        class="btn btn-default group js-reveal-variables"
        @click="revealVariables"
      >
        {{ __('Reveal Variables') }}
      </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>