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

trigger_block.vue « components « jobs « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7c9b2824a4328bae855425695683535553e083c9 (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>
import { GlDeprecatedButton } from '@gitlab/ui';
import { __ } from '~/locale';

const HIDDEN_VALUE = '••••••';

export default {
  components: {
    GlDeprecatedButton,
  },
  props: {
    trigger: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      showVariableValues: false,
    };
  },
  computed: {
    hasVariables() {
      return this.trigger.variables && this.trigger.variables.length > 0;
    },
    getToggleButtonText() {
      return this.showVariableValues ? __('Hide values') : __('Reveal values');
    },
    hasValues() {
      return this.trigger.variables.some(v => v.value);
    },
  },
  methods: {
    toggleValues() {
      this.showVariableValues = !this.showVariableValues;
    },
    getDisplayValue(value) {
      return this.showVariableValues ? value : HIDDEN_VALUE;
    },
  },
};
</script>

<template>
  <div class="build-widget block">
    <p
      v-if="trigger.short_token"
      class="js-short-token"
      :class="{ 'append-bottom-5': hasVariables, 'append-bottom-0': !hasVariables }"
    >
      <span class="font-weight-bold">{{ __('Trigger token:') }}</span> {{ trigger.short_token }}
    </p>

    <template v-if="hasVariables">
      <p class="trigger-variables-btn-container d-flex">
        <span class="font-weight-bold">{{ __('Trigger variables:') }}</span>

        <gl-deprecated-button
          v-if="hasValues"
          class="btn-sm group js-reveal-variables trigger-variables-btn"
          @click="toggleValues"
          >{{ getToggleButtonText }}</gl-deprecated-button
        >
      </p>

      <table class="js-build-variables trigger-build-variables">
        <tr v-for="(variable, index) in trigger.variables" :key="`${variable.key}-${index}`">
          <td class="js-build-variable trigger-build-variable trigger-variables-table-cell">
            {{ variable.key }}
          </td>
          <td class="js-build-value trigger-build-value trigger-variables-table-cell">
            {{ getDisplayValue(variable.value) }}
          </td>
        </tr>
      </table>
    </template>
  </div>
</template>