2018-08-16 07:07:59 -04:00
|
|
|
<script>
|
2018-11-16 14:29:11 -05:00
|
|
|
import { GlButton } from '@gitlab/ui';
|
2019-12-11 07:08:10 -05:00
|
|
|
import { __ } from '~/locale';
|
2018-11-09 17:42:24 -05:00
|
|
|
|
2018-12-03 14:29:05 -05:00
|
|
|
const HIDDEN_VALUE = '••••••';
|
|
|
|
|
2018-10-10 02:23:54 -04:00
|
|
|
export default {
|
2018-11-09 17:42:24 -05:00
|
|
|
components: {
|
|
|
|
GlButton,
|
|
|
|
},
|
2018-10-10 02:23:54 -04:00
|
|
|
props: {
|
|
|
|
trigger: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-08-16 07:07:59 -04:00
|
|
|
},
|
2018-10-10 02:23:54 -04:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2018-12-03 14:29:05 -05:00
|
|
|
showVariableValues: false,
|
2018-10-10 02:23:54 -04:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
hasVariables() {
|
2018-12-04 16:26:16 -05:00
|
|
|
return this.trigger.variables && this.trigger.variables.length > 0;
|
2018-12-03 14:29:05 -05:00
|
|
|
},
|
|
|
|
getToggleButtonText() {
|
2018-12-04 16:26:16 -05:00
|
|
|
return this.showVariableValues ? __('Hide values') : __('Reveal values');
|
2018-12-03 14:29:05 -05:00
|
|
|
},
|
|
|
|
hasValues() {
|
2018-12-04 16:26:16 -05:00
|
|
|
return this.trigger.variables.some(v => v.value);
|
2018-08-16 07:07:59 -04:00
|
|
|
},
|
2018-10-10 02:23:54 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2018-12-03 14:29:05 -05:00
|
|
|
toggleValues() {
|
|
|
|
this.showVariableValues = !this.showVariableValues;
|
|
|
|
},
|
|
|
|
getDisplayValue(value) {
|
|
|
|
return this.showVariableValues ? value : HIDDEN_VALUE;
|
2018-08-16 07:07:59 -04:00
|
|
|
},
|
2018-10-10 02:23:54 -04:00
|
|
|
},
|
|
|
|
};
|
2018-08-16 07:07:59 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="build-widget block">
|
2018-12-03 14:29:05 -05:00
|
|
|
<p
|
|
|
|
v-if="trigger.short_token"
|
|
|
|
class="js-short-token"
|
2018-12-19 14:16:10 -05:00
|
|
|
:class="{ 'append-bottom-5': hasVariables, 'append-bottom-0': !hasVariables }"
|
2018-12-03 14:29:05 -05:00
|
|
|
>
|
2018-12-19 14:16:10 -05:00
|
|
|
<span class="font-weight-bold">{{ __('Trigger token:') }}</span> {{ trigger.short_token }}
|
2018-08-16 07:07:59 -04:00
|
|
|
</p>
|
|
|
|
|
2018-12-03 14:29:05 -05:00
|
|
|
<template v-if="hasVariables">
|
2019-04-11 08:09:21 -04:00
|
|
|
<p class="trigger-variables-btn-container d-flex">
|
2018-12-19 14:16:10 -05:00
|
|
|
<span class="font-weight-bold">{{ __('Trigger variables:') }}</span>
|
2018-08-16 07:07:59 -04:00
|
|
|
|
2018-12-19 14:16:10 -05:00
|
|
|
<gl-button
|
|
|
|
v-if="hasValues"
|
|
|
|
class="btn-sm group js-reveal-variables trigger-variables-btn"
|
|
|
|
@click="toggleValues"
|
|
|
|
>{{ getToggleButtonText }}</gl-button
|
|
|
|
>
|
2018-12-03 14:29:05 -05:00
|
|
|
</p>
|
2018-08-16 07:07:59 -04:00
|
|
|
|
2018-12-04 16:26:16 -05:00
|
|
|
<table class="js-build-variables trigger-build-variables">
|
2018-12-06 08:06:01 -05:00
|
|
|
<tr v-for="(variable, index) in trigger.variables" :key="`${variable.key}-${index}`">
|
|
|
|
<td class="js-build-variable trigger-build-variable trigger-variables-table-cell">
|
2018-12-03 14:29:05 -05:00
|
|
|
{{ variable.key }}
|
|
|
|
</td>
|
2018-12-06 08:06:01 -05:00
|
|
|
<td class="js-build-value trigger-build-value trigger-variables-table-cell">
|
2018-12-03 14:29:05 -05:00
|
|
|
{{ getDisplayValue(variable.value) }}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</template>
|
2018-08-16 07:07:59 -04:00
|
|
|
</div>
|
|
|
|
</template>
|