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

add_request.vue « components « performance_bar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9a8ebedaf1517a1d006c2b379c77fb8ef3c8139d (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
<script>
import { GlForm, GlFormInput, GlButton, GlTooltipDirective } from '@gitlab/ui';
import { __ } from '~/locale';

export default {
  i18n: {
    buttonLabel: __('Add request manually'),
    inputLabel: __('URL or request ID'),
  },
  components: {
    GlForm,
    GlButton,
    GlFormInput,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  data() {
    return {
      inputEnabled: false,
      urlOrRequestId: '',
    };
  },
  methods: {
    toggleInput() {
      this.inputEnabled = !this.inputEnabled;
    },
    addRequest() {
      this.$emit('add-request', this.urlOrRequestId);
      this.clearForm();
    },
    clearForm() {
      this.urlOrRequestId = '';
      this.toggleInput();
    },
  },
};
</script>
<template>
  <div id="peek-view-add-request" class="view gl-display-flex">
    <gl-form class="gl-display-flex gl-align-items-center" @submit.prevent>
      <gl-button
        v-gl-tooltip.viewport
        class="gl-mr-2"
        category="tertiary"
        variant="link"
        icon="plus"
        size="small"
        :title="$options.i18n.buttonLabel"
        :aria-label="$options.i18n.buttonLabel"
        @click="toggleInput"
      />
      <gl-form-input
        v-if="inputEnabled"
        v-model="urlOrRequestId"
        type="text"
        :placeholder="$options.i18n.inputLabel"
        :aria-label="$options.i18n.inputLabel"
        class="gl-ml-2 gl-px-3! gl-py-2!"
        @keyup.enter="addRequest"
        @keyup.esc="clearForm"
      />
    </gl-form>
  </div>
</template>