Welcome to mirror list, hosted at ThFree Co, Russian Federation.

form_url_mask_item.vue « components « webhooks « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3b75f9b6c0db25bb9b34b6f826df447f57a49021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<script>
import { GlButton, GlFormGroup, GlFormInput } from '@gitlab/ui';
import { s__ } from '~/locale';

export default {
  components: {
    GlButton,
    GlFormGroup,
    GlFormInput,
  },
  props: {
    index: {
      type: Number,
      required: false,
      default: null,
    },
    itemKey: {
      type: String,
      required: false,
      default: null,
    },
    itemValue: {
      type: String,
      required: false,
      default: null,
    },
  },
  computed: {
    keyInputId() {
      return this.inputId('key');
    },
    valueInputId() {
      return this.inputId('value');
    },
  },
  methods: {
    inputId(type) {
      return `webhook-url-mask-item-${type}-${this.index}`;
    },
    inputName(type) {
      return `hook[url_variables][][${type}]`;
    },
    onKeyInput(key) {
      this.$emit('input', { index: this.index, key, value: this.itemValue });
    },
    onValueInput(value) {
      this.$emit('input', { index: this.index, key: this.itemKey, value });
    },
    onRemoveClick() {
      this.$emit('remove', this.index);
    },
  },
  i18n: {
    keyLabel: s__('Webhooks|How it looks in the UI'),
    valueLabel: s__('Webhooks|Sensitive portion of URL'),
  },
};
</script>

<template>
  <div class="gl-display-flex gl-align-items-flex-end gl-gap-3 gl-mb-3">
    <gl-form-group
      :label="$options.i18n.valueLabel"
      :label-for="valueInputId"
      class="gl-flex-grow-1 gl-mb-0"
      data-testid="mask-item-value"
    >
      <gl-form-input
        :id="valueInputId"
        :name="inputName('value')"
        :value="itemValue"
        @input="onValueInput"
      />
    </gl-form-group>
    <gl-form-group
      :label="$options.i18n.keyLabel"
      :label-for="keyInputId"
      class="gl-flex-grow-1 gl-mb-0"
      data-testid="mask-item-key"
    >
      <gl-form-input
        :id="keyInputId"
        :name="inputName('key')"
        :value="itemKey"
        @input="onKeyInput"
      />
    </gl-form-group>
    <gl-button icon="remove" :aria-label="__('Remove')" @click="onRemoveClick" />
  </div>
</template>