debian-mirror-gitlab/app/assets/javascripts/jobs/components/trigger_block.vue

78 lines
2 KiB
Vue
Raw Normal View History

2018-11-20 20:47:30 +05:30
<script>
2018-12-23 12:14:25 +05:30
import { __ } from '~/locale';
import { GlButton } from '@gitlab/ui';
const HIDDEN_VALUE = '••••••';
2018-12-13 13:39:08 +05:30
export default {
2018-12-23 12:14:25 +05:30
components: {
GlButton,
},
2018-12-13 13:39:08 +05:30
props: {
trigger: {
type: Object,
required: true,
2018-11-20 20:47:30 +05:30
},
2018-12-13 13:39:08 +05:30
},
data() {
return {
2018-12-23 12:14:25 +05:30
showVariableValues: false,
2018-12-13 13:39:08 +05:30
};
},
computed: {
hasVariables() {
return this.trigger.variables && this.trigger.variables.length > 0;
2018-11-20 20:47:30 +05:30
},
2018-12-23 12:14:25 +05:30
getToggleButtonText() {
return this.showVariableValues ? __('Hide values') : __('Reveal values');
},
hasValues() {
return this.trigger.variables.some(v => v.value);
},
2018-12-13 13:39:08 +05:30
},
methods: {
2018-12-23 12:14:25 +05:30
toggleValues() {
this.showVariableValues = !this.showVariableValues;
},
getDisplayValue(value) {
return this.showVariableValues ? value : HIDDEN_VALUE;
2018-11-20 20:47:30 +05:30
},
2018-12-13 13:39:08 +05:30
},
};
2018-11-20 20:47:30 +05:30
</script>
<template>
<div class="build-widget block">
2018-12-23 12:14:25 +05:30
<h4 class="title">{{ __('Trigger') }}</h4>
2018-11-20 20:47:30 +05:30
<p
2018-12-05 23:21:45 +05:30
v-if="trigger.short_token"
2018-11-20 20:47:30 +05:30
class="js-short-token"
2018-12-23 12:14:25 +05:30
:class="{ 'append-bottom-0': !hasVariables }"
2018-11-20 20:47:30 +05:30
>
2018-12-23 12:14:25 +05:30
<span class="build-light-text"> {{ __('Token') }} </span> {{ trigger.short_token }}
2018-11-20 20:47:30 +05:30
</p>
2018-12-23 12:14:25 +05:30
<template v-if="hasVariables">
<p class="trigger-variables-btn-container">
<span class="build-light-text"> {{ __('Variables:') }} </span>
2018-11-20 20:47:30 +05:30
2018-12-23 12:14:25 +05:30
<gl-button v-if="hasValues" class="group js-reveal-variables" @click="toggleValues">
{{ getToggleButtonText }}
</gl-button>
</p>
2018-11-20 20:47:30 +05:30
2018-12-23 12:14:25 +05:30
<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>
2018-11-20 20:47:30 +05:30
</div>
</template>