Commit 16211230 authored by jhampton's avatar jhampton

Updates per MR feedback

- Adjusts il8n implementation
- Removes unnecessary type check
- Adjusts to use Vue shorthand directives
- Adjusts class names
parent aaf22b66
<script> <script>
import { __ } from '~/locale';
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
const HIDDEN_VALUE = '••••••'; const HIDDEN_VALUE = '••••••';
const TOGGLE_BUTTON_TEXT = {
HIDE: 'Hide',
REVEAL: 'Reveal',
};
export default { export default {
components: { components: {
...@@ -24,14 +21,13 @@ export default { ...@@ -24,14 +21,13 @@ export default {
}, },
computed: { computed: {
hasVariables() { hasVariables() {
return Array.isArray(this.trigger.variables) && this.trigger.variables.length > 0; return this.trigger.variables && this.trigger.variables.length > 0;
}, },
getToggleButtonText() { getToggleButtonText() {
const { HIDE, REVEAL } = TOGGLE_BUTTON_TEXT; return this.showVariableValues ? __('Hide values') : __('Reveal values');
return `${this.showVariableValues ? HIDE : REVEAL} Values`;
}, },
hasValues() { hasValues() {
return (this.trigger.variables || []).some(v => v.value); return this.trigger.variables.some(v => v.value);
}, },
}, },
methods: { methods: {
...@@ -61,25 +57,23 @@ export default { ...@@ -61,25 +57,23 @@ export default {
<p class="trigger-variables-btn-container"> <p class="trigger-variables-btn-container">
<span class="build-light-text"> {{ __('Variables:') }} </span> <span class="build-light-text"> {{ __('Variables:') }} </span>
<gl-button <gl-button v-if="hasValues" class="group js-reveal-variables" @click="toggleValues">
v-if="hasValues" {{ getToggleButtonText }}
type="button"
class="btn btn-default group js-reveal-variables"
@click="toggleValues"
>
{{ __(getToggleButtonText) }}
</gl-button> </gl-button>
</p> </p>
<table class="js-build-variables trigger-variables-table trigger-build-variables"> <table class="js-build-variables trigger-build-variables">
<tr v-for="variable in trigger.variables"> <tr v-for="variable in trigger.variables">
<td <td
v-bind:key="`${variable.key}-variable`" :key="`${variable.key}-variable`"
class="js-build-variable trigger-build-variable" class="js-build-variable trigger-build-variable trigger-variables-table-cell"
> >
{{ variable.key }} {{ variable.key }}
</td> </td>
<td v-bind:key="`${variable.key}-value`" class="js-build-value trigger-build-value"> <td
:key="`${variable.key}-value`"
class="js-build-value trigger-build-value trigger-variables-table-cell"
>
{{ getDisplayValue(variable.value) }} {{ getDisplayValue(variable.value) }}
</td> </td>
</tr> </tr>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment