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

80 lines
2 KiB
Vue
Raw Normal View History

2018-11-20 20:47:30 +05:30
<script>
2021-01-03 14:25:43 +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: {
2021-01-03 14:25:43 +05:30
GlButton,
2019-02-15 15:39:39 +05:30
},
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() {
2021-03-08 18:12:59 +05:30
return this.trigger.variables.some((v) => v.value);
2019-02-15 15:39:39 +05:30
},
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"
2020-07-28 23:09:34 +05:30
:class="{ 'gl-mb-2': hasVariables, 'gl-mb-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
2021-01-03 14:25:43 +05:30
<gl-button
2019-02-15 15:39:39 +05:30
v-if="hasValues"
2021-01-03 14:25:43 +05:30
class="group js-reveal-variables trigger-variables-btn"
size="small"
2019-02-15 15:39:39 +05:30
@click="toggleValues"
2021-01-03 14:25:43 +05:30
>{{ 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>