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

services_item.vue « accordion_items « job_assistant_drawer « components « pipeline_editor « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9bada3ef1103a18e6a078454d61e5ad7801a4081 (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 { GlAccordionItem, GlFormInput, GlButton, GlFormGroup, GlFormTextarea } from '@gitlab/ui';
import { i18n } from '../constants';

export default {
  i18n,
  placeholderText: i18n.ENTRYPOINT_PLACEHOLDER_TEXT,
  components: {
    GlAccordionItem,
    GlFormGroup,
    GlFormInput,
    GlFormTextarea,
    GlButton,
  },
  props: {
    job: {
      type: Object,
      required: true,
    },
  },
  computed: {
    canDeleteServices() {
      return this.job.services.length > 1;
    },
  },
  methods: {
    deleteService(index) {
      if (!this.canDeleteServices) {
        return;
      }
      this.$emit('update-job', `services[${index}]`);
    },
    addService() {
      this.$emit('update-job', `services[${this.job.services.length}]`, {
        name: '',
        entrypoint: [''],
      });
    },
    serviceEntryPoint(service) {
      const { entrypoint = [''] } = service;
      return entrypoint.join('\n');
    },
  },
};
</script>
<template>
  <gl-accordion-item :title="$options.i18n.SERVICE">
    <div
      v-for="(service, index) in job.services"
      :key="index"
      class="gl-relative gl-bg-gray-10 gl-mb-5 gl-p-5"
    >
      <gl-button
        v-if="canDeleteServices"
        class="gl-absolute gl-right-3 gl-top-3"
        category="tertiary"
        icon="remove"
        :data-testid="`delete-job-service-button-${index}`"
        @click="deleteService(index)"
      />
      <gl-form-group :label="$options.i18n.SERVICE_NAME">
        <gl-form-input
          :data-testid="`service-name-input-${index}`"
          :value="service.name"
          @input="$emit('update-job', `services[${index}].name`, $event)"
        />
      </gl-form-group>
      <gl-form-group
        :label="$options.i18n.SERVICE_ENTRYPOINT"
        :description="$options.i18n.ARRAY_FIELD_DESCRIPTION"
        class="gl-mb-0"
      >
        <gl-form-textarea
          :no-resize="false"
          :placeholder="$options.placeholderText"
          :data-testid="`service-entrypoint-input-${index}`"
          :value="serviceEntryPoint(service)"
          @input="$emit('update-job', `services[${index}].entrypoint`, $event.split('\n'))"
        />
      </gl-form-group>
    </div>
    <gl-button
      category="secondary"
      variant="confirm"
      data-testid="add-job-service-button"
      @click="addService"
      >{{ $options.i18n.ADD_SERVICE }}</gl-button
    >
  </gl-accordion-item>
</template>