summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/trigger_block.vue
blob: 1e62c05b4d16cddf52dcf358502326ff7f8b93a3 (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
79
80
81
82
<script>
import { GlButton } from '@gitlab-org/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>