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

79 lines
2 KiB
Vue
Raw Normal View History

2018-11-20 20:47:30 +05:30
<script>
2019-02-15 15:39:39 +05:30
import { GlButton } from '@gitlab/ui';
2020-01-01 13:55:28 +05:30
import { __ } from '~/locale';
2019-02-15 15:39:39 +05:30
const HIDDEN_VALUE = '••••••';
2018-12-13 13:39:08 +05:30
export default {
2019-02-15 15:39:39 +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 {
2019-02-15 15:39:39 +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
},
2019-02-15 15:39:39 +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: {
2019-02-15 15:39:39 +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">
<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"
2019-02-15 15:39:39 +05:30
:class="{ 'append-bottom-5': hasVariables, 'append-bottom-0': !hasVariables }"
2018-11-20 20:47:30 +05:30
>
2019-02-15 15:39:39 +05:30
<span class="font-weight-bold">{{ __('Trigger token:') }}</span> {{ trigger.short_token }}
2018-11-20 20:47:30 +05:30
</p>
2019-02-15 15:39:39 +05:30
<template v-if="hasVariables">
2019-07-31 22:56:46 +05:30
<p class="trigger-variables-btn-container d-flex">
2019-02-15 15:39:39 +05:30
<span class="font-weight-bold">{{ __('Trigger variables:') }}</span>
2018-11-20 20:47:30 +05:30
2019-02-15 15:39:39 +05:30
<gl-button
v-if="hasValues"
class="btn-sm group js-reveal-variables trigger-variables-btn"
@click="toggleValues"
>{{ getToggleButtonText }}</gl-button
2019-01-03 12:48:30 +05:30
>
2019-02-15 15:39:39 +05:30
</p>
2018-11-20 20:47:30 +05:30
2019-02-15 15:39:39 +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>