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

runner_form_fields.vue « components « runner « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 180c41e7ed65a6519f87192d3f02182bfe518474 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<script>
import { isEqual } from 'lodash';
import {
  GlFormGroup,
  GlFormCheckbox,
  GlFormInput,
  GlIcon,
  GlLink,
  GlSprintf,
  GlSkeletonLoader,
} from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper';
import { ACCESS_LEVEL_NOT_PROTECTED, ACCESS_LEVEL_REF_PROTECTED, PROJECT_TYPE } from '../constants';

export default {
  name: 'RunnerFormFields',
  components: {
    GlFormGroup,
    GlFormCheckbox,
    GlFormInput,
    GlIcon,
    GlLink,
    GlSprintf,
    GlSkeletonLoader,
    RunnerMaintenanceNoteField: () =>
      import('ee_component/ci/runner/components/runner_maintenance_note_field.vue'),
  },
  props: {
    value: {
      type: Object,
      default: null,
      required: false,
    },
    loading: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  data() {
    return {
      model: null,
    };
  },
  computed: {
    canBeLockedToProject() {
      return this.value?.runnerType === PROJECT_TYPE;
    },
  },
  watch: {
    value: {
      handler(newVal, oldVal) {
        // update only when values change, avoids infinite loop
        if (!isEqual(newVal, oldVal)) {
          this.model = { ...newVal };
        }
      },
      immediate: true,
    },
    model: {
      handler() {
        this.$emit('input', this.model);
      },
      deep: true,
    },
  },
  HELP_LABELS_PAGE_PATH: helpPagePath('ci/runners/configure_runners', {
    anchor: 'use-tags-to-control-which-jobs-a-runner-can-run',
  }),
  ACCESS_LEVEL_NOT_PROTECTED,
  ACCESS_LEVEL_REF_PROTECTED,
};
</script>
<template>
  <div>
    <h2 class="gl-font-size-h2 gl-my-5">
      {{ s__('Runners|Details') }}
      {{ __('(optional)') }}
    </h2>

    <gl-skeleton-loader v-if="loading" :lines="9" />
    <template v-else-if="model">
      <gl-form-group :label="s__('Runners|Runner description')" label-for="runner-description">
        <gl-form-input id="runner-description" v-model="model.description" name="description" />
      </gl-form-group>
      <runner-maintenance-note-field v-model="model.maintenanceNote" class="gl-mt-5" />
    </template>

    <hr aria-hidden="true" />

    <h2 class="gl-font-size-h2 gl-my-5">
      {{ s__('Runners|Configuration') }}
      {{ __('(optional)') }}
    </h2>

    <gl-skeleton-loader v-if="loading" :lines="27" />
    <template v-else-if="model">
      <div class="gl-mb-5">
        <gl-form-checkbox v-model="model.paused" name="paused">
          {{ __('Paused') }}
          <template #help>
            {{ s__('Runners|Stop the runner from accepting new jobs.') }}
          </template>
        </gl-form-checkbox>

        <gl-form-checkbox
          v-model="model.accessLevel"
          name="protected"
          :value="$options.ACCESS_LEVEL_REF_PROTECTED"
          :unchecked-value="$options.ACCESS_LEVEL_NOT_PROTECTED"
        >
          {{ __('Protected') }}
          <template #help>
            {{ s__('Runners|Use the runner on pipelines for protected branches only.') }}
          </template>
        </gl-form-checkbox>

        <gl-form-checkbox v-model="model.runUntagged" name="run-untagged">
          {{ __('Run untagged jobs') }}
          <template #help>
            {{ s__('Runners|Use the runner for jobs without tags in addition to tagged jobs.') }}
          </template>
        </gl-form-checkbox>

        <gl-form-checkbox v-if="canBeLockedToProject" v-model="model.locked" name="locked">
          {{ __('Lock to current projects') }} <gl-icon name="lock" />
          <template #help>
            {{
              s__(
                'Runners|Use the runner for the currently assigned projects only. Only administrators can change the assigned projects.',
              )
            }}
          </template>
        </gl-form-checkbox>
      </div>

      <gl-form-group :label="__('Tags')" label-for="runner-tags">
        <template #description>
          <gl-sprintf
            :message="
              s__('Runners|Multiple tags must be separated by a comma. For example, %{example}.')
            "
          >
            <template #example>
              <!-- eslint-disable-next-line @gitlab/vue-require-i18n-strings -->
              <code>macos, shared</code>
            </template>
          </gl-sprintf>
        </template>
        <template #label-description>
          <gl-sprintf
            :message="
              s__(
                'Runners|Add tags for the types of jobs the runner processes to ensure that the runner only runs jobs that you intend it to. %{helpLinkStart}Learn more.%{helpLinkEnd}',
              )
            "
          >
            <template #helpLink="{ content }">
              <gl-link :href="$options.HELP_LABELS_PAGE_PATH" target="_blank">{{
                content
              }}</gl-link>
            </template>
          </gl-sprintf>
        </template>
        <gl-form-input id="runner-tags" v-model="model.tagList" name="tags" />
      </gl-form-group>

      <gl-form-group
        :label="__('Maximum job timeout')"
        :label-description="
          s__(
            'Runners|Maximum amount of time the runner can run before it terminates. If a project has a shorter job timeout period, the job timeout period of the instance runner is used instead.',
          )
        "
        label-for="runner-max-timeout"
        :description="s__('Runners|Enter the number of seconds.')"
      >
        <gl-form-input
          id="runner-max-timeout"
          v-model.number="model.maximumTimeout"
          name="max-timeout"
          type="number"
        />
      </gl-form-group>
    </template>
  </div>
</template>