Skip to content

Commit 12b96f0

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 733ec54 commit 12b96f0

File tree

76 files changed

+1349
-572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1349
-572
lines changed

app/assets/javascripts/ci/pipeline_new/components/pipeline_new_form.vue

+138-118
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { GlBreakpointInstance } from '@gitlab/ui/dist/utils';
1616
import { uniqueId } from 'lodash';
1717
import * as Sentry from '~/sentry/sentry_browser_wrapper';
1818
import { fetchPolicies } from '~/lib/graphql';
19+
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
1920
import SafeHtml from '~/vue_shared/directives/safe_html';
2021
import { visitUrl } from '~/lib/utils/url_utility';
2122
import { s__, __, n__ } from '~/locale';
@@ -24,14 +25,15 @@ import { helpPagePath } from '~/helpers/help_page_helper';
2425
import {
2526
IDENTITY_VERIFICATION_REQUIRED_ERROR,
2627
CONFIG_VARIABLES_TIMEOUT,
27-
FILE_TYPE,
28-
VARIABLE_TYPE,
28+
CI_VARIABLE_TYPE_FILE,
29+
CI_VARIABLE_TYPE_ENV_VAR,
2930
} from '../constants';
3031
import createPipelineMutation from '../graphql/mutations/create_pipeline.mutation.graphql';
3132
import ciConfigVariablesQuery from '../graphql/queries/ci_config_variables.graphql';
3233
import filterVariables from '../utils/filter_variables';
3334
import RefsDropdown from './refs_dropdown.vue';
3435
import VariableValuesListbox from './variable_values_listbox.vue';
36+
import PipelineVariablesForm from './pipeline_variables_form.vue';
3537
3638
let pollTimeout;
3739
export const POLLING_INTERVAL = 2000;
@@ -71,12 +73,14 @@ export default {
7173
GlLink,
7274
GlSprintf,
7375
GlLoadingIcon,
76+
PipelineVariablesForm,
7477
RefsDropdown,
7578
VariableValuesListbox,
7679
PipelineAccountVerificationAlert: () =>
7780
import('ee_component/vue_shared/components/pipeline_account_verification_alert.vue'),
7881
},
7982
directives: { SafeHtml },
83+
mixins: [glFeatureFlagsMixin()],
8084
props: {
8185
pipelinesPath: {
8286
type: String,
@@ -155,9 +159,9 @@ export default {
155159
ciConfigVariables: {
156160
fetchPolicy: fetchPolicies.NO_CACHE,
157161
query: ciConfigVariablesQuery,
158-
// Skip when variables already cached in `form`
162+
// Skip when variables already cached in `form` or feature flag is enabled
159163
skip() {
160-
return Object.keys(this.form).includes(this.refFullName);
164+
return Object.keys(this.form).includes(this.refFullName) || this.isUsingPipelineInputs;
161165
},
162166
variables() {
163167
return {
@@ -207,6 +211,9 @@ export default {
207211
isLoading() {
208212
return this.$apollo.queries.ciConfigVariables.loading || this.isFetchingCiConfigVariables;
209213
},
214+
isUsingPipelineInputs() {
215+
return this.glFeatures.ciInputsForPipelines;
216+
},
210217
overMaxWarningsLimit() {
211218
return this.totalWarnings > this.maxWarnings;
212219
},
@@ -240,11 +247,11 @@ export default {
240247
variableTypeListboxItems() {
241248
return [
242249
{
243-
value: VARIABLE_TYPE,
250+
value: CI_VARIABLE_TYPE_ENV_VAR,
244251
text: s__('Pipeline|Variable'),
245252
},
246253
{
247-
value: FILE_TYPE,
254+
value: CI_VARIABLE_TYPE_FILE,
248255
text: s__('Pipeline|File'),
249256
},
250257
];
@@ -261,7 +268,7 @@ export default {
261268
262269
variables.push({
263270
uniqueId: uniqueId(`var-${refValue}`),
264-
variable_type: VARIABLE_TYPE,
271+
variableType: CI_VARIABLE_TYPE_ENV_VAR,
265272
key: '',
266273
value: '',
267274
});
@@ -295,17 +302,17 @@ export default {
295302
// Add default variables from yml
296303
this.setVariableParams(
297304
this.refFullName,
298-
VARIABLE_TYPE,
305+
CI_VARIABLE_TYPE_ENV_VAR,
299306
this.configVariablesWithDescription.values,
300307
);
301308
302309
// Add/update variables, e.g. from query string
303310
if (this.variableParams) {
304-
this.setVariableParams(this.refFullName, VARIABLE_TYPE, this.variableParams);
311+
this.setVariableParams(this.refFullName, CI_VARIABLE_TYPE_ENV_VAR, this.variableParams);
305312
}
306313
307314
if (this.fileParams) {
308-
this.setVariableParams(this.refFullName, FILE_TYPE, this.fileParams);
315+
this.setVariableParams(this.refFullName, CI_VARIABLE_TYPE_FILE, this.fileParams);
309316
}
310317
311318
// Adds empty var at the end of the form
@@ -324,7 +331,7 @@ export default {
324331
uniqueId: uniqueId(`var-${refValue}`),
325332
key,
326333
value,
327-
variable_type: type,
334+
variableType: type,
328335
});
329336
}
330337
},
@@ -469,119 +476,132 @@ export default {
469476
</p>
470477
</details>
471478
</gl-alert>
472-
<gl-form-group :label="s__('Pipeline|Run for branch name or tag')">
473-
<refs-dropdown
474-
v-model="refValue"
475-
:project-id="projectId"
476-
@loadingError="onRefsLoadingError"
477-
/>
478-
</gl-form-group>
479+
<div class="gl-flex gl-flex-col gl-gap-4">
480+
<gl-form-group :label="s__('Pipeline|Run for branch name or tag')">
481+
<refs-dropdown
482+
v-model="refValue"
483+
:project-id="projectId"
484+
@loadingError="onRefsLoadingError"
485+
/>
486+
</gl-form-group>
479487
480-
<gl-loading-icon v-if="isLoading" class="gl-mb-5" size="md" />
488+
<pipeline-variables-form
489+
v-if="isUsingPipelineInputs"
490+
:default-branch="defaultBranch"
491+
:project-path="projectPath"
492+
:ref-param="refParam"
493+
/>
494+
<div v-else>
495+
<gl-loading-icon v-if="isLoading" class="gl-mb-5" size="md" />
496+
<gl-form-group v-else :label="s__('Pipeline|Variables')">
497+
<div
498+
v-for="(variable, index) in variables"
499+
:key="variable.uniqueId"
500+
class="gl-mb-4"
501+
data-testid="ci-variable-row-container"
502+
>
503+
<div class="gl-flex gl-flex-col gl-items-stretch gl-gap-4 md:gl-flex-row">
504+
<gl-collapsible-listbox
505+
:items="variableTypeListboxItems"
506+
:selected="variable.variableType"
507+
block
508+
fluid-width
509+
:aria-label="getPipelineAriaLabel(index)"
510+
:class="$options.formElementClasses"
511+
data-testid="pipeline-form-ci-variable-type"
512+
@select="setVariableAttribute(variable.key, 'variableType', $event)"
513+
/>
514+
<gl-form-input
515+
v-model="variable.key"
516+
:placeholder="s__('CiVariables|Input variable key')"
517+
:class="$options.formElementClasses"
518+
data-testid="pipeline-form-ci-variable-key-field"
519+
@change="addEmptyVariable(refFullName)"
520+
/>
521+
<variable-values-listbox
522+
v-if="shouldShowValuesDropdown(variable.key)"
523+
:items="createListItemsFromVariableOptions(variable.key)"
524+
:selected="variable.value"
525+
:class="$options.formElementClasses"
526+
class="!gl-mr-0 gl-grow"
527+
data-testid="pipeline-form-ci-variable-value-dropdown"
528+
@select="setVariableAttribute(variable.key, 'value', $event)"
529+
/>
530+
<gl-form-textarea
531+
v-else
532+
v-model="variable.value"
533+
:placeholder="s__('CiVariables|Input variable value')"
534+
:style="$options.textAreaStyle"
535+
:no-resize="false"
536+
data-testid="pipeline-form-ci-variable-value-field"
537+
/>
481538
482-
<gl-form-group v-else :label="s__('Pipeline|Variables')">
483-
<div
484-
v-for="(variable, index) in variables"
485-
:key="variable.uniqueId"
486-
class="gl-mb-4"
487-
data-testid="ci-variable-row-container"
488-
>
489-
<div class="gl-flex gl-flex-col gl-items-stretch gl-gap-4 md:gl-flex-row">
490-
<gl-collapsible-listbox
491-
:items="variableTypeListboxItems"
492-
:selected="variable.variable_type"
493-
block
494-
fluid-width
495-
:aria-label="getPipelineAriaLabel(index)"
496-
:class="$options.formElementClasses"
497-
data-testid="pipeline-form-ci-variable-type"
498-
@select="setVariableAttribute(variable.key, 'variable_type', $event)"
499-
/>
500-
<gl-form-input
501-
v-model="variable.key"
502-
:placeholder="s__('CiVariables|Input variable key')"
503-
:class="$options.formElementClasses"
504-
data-testid="pipeline-form-ci-variable-key-field"
505-
@change="addEmptyVariable(refFullName)"
506-
/>
507-
<variable-values-listbox
508-
v-if="shouldShowValuesDropdown(variable.key)"
509-
:items="createListItemsFromVariableOptions(variable.key)"
510-
:selected="variable.value"
511-
:class="$options.formElementClasses"
512-
class="!gl-mr-0 gl-grow"
513-
data-testid="pipeline-form-ci-variable-value-dropdown"
514-
@select="setVariableAttribute(variable.key, 'value', $event)"
515-
/>
516-
<gl-form-textarea
517-
v-else
518-
v-model="variable.value"
519-
:placeholder="s__('CiVariables|Input variable value')"
520-
:style="$options.textAreaStyle"
521-
:no-resize="false"
522-
data-testid="pipeline-form-ci-variable-value-field"
523-
/>
539+
<template v-if="variables.length > 1">
540+
<gl-button
541+
v-if="canRemove(index)"
542+
size="small"
543+
class="gl-shrink-0"
544+
data-testid="remove-ci-variable-row"
545+
:category="removeButtonCategory"
546+
:aria-label="$options.i18n.removeVariableLabel"
547+
@click="removeVariable(index)"
548+
>
549+
<gl-icon class="!gl-mr-0" name="remove" />
550+
<span class="md:gl-hidden">{{ $options.i18n.removeVariableLabel }}</span>
551+
</gl-button>
552+
<gl-button
553+
v-else
554+
class="gl-invisible gl-hidden gl-shrink-0 md:gl-block"
555+
icon="remove"
556+
:aria-label="$options.i18n.removeVariableLabel"
557+
/>
558+
</template>
559+
</div>
560+
<div v-if="descriptions[variable.key]" class="gl-text-subtle">
561+
{{ descriptions[variable.key] }}
562+
</div>
563+
</div>
524564
525-
<template v-if="variables.length > 1">
526-
<gl-button
527-
v-if="canRemove(index)"
528-
size="small"
529-
class="gl-shrink-0"
530-
data-testid="remove-ci-variable-row"
531-
:category="removeButtonCategory"
532-
:aria-label="$options.i18n.removeVariableLabel"
533-
@click="removeVariable(index)"
534-
>
535-
<gl-icon class="!gl-mr-0" name="remove" />
536-
<span class="md:gl-hidden">{{ $options.i18n.removeVariableLabel }}</span>
537-
</gl-button>
538-
<gl-button
539-
v-else
540-
class="gl-invisible gl-hidden gl-shrink-0 md:gl-block"
541-
icon="remove"
542-
:aria-label="$options.i18n.removeVariableLabel"
543-
/>
565+
<template #description>
566+
<gl-sprintf :message="$options.i18n.variablesDescription">
567+
<template #link="{ content }">
568+
<gl-link
569+
v-if="isMaintainer"
570+
:href="settingsLink"
571+
data-testid="ci-cd-settings-link"
572+
>{{ content }}</gl-link
573+
>
574+
<template v-else>{{ content }}</template>
575+
</template>
576+
</gl-sprintf>
577+
<gl-link :href="$options.learnMorePath" target="_blank">{{
578+
$options.i18n.learnMore
579+
}}</gl-link>
580+
<div class="gl-mt-4 gl-text-subtle">
581+
<gl-sprintf :message="$options.i18n.overrideNoteText">
582+
<template #bold="{ content }">
583+
<strong>
584+
{{ content }}
585+
</strong>
586+
</template>
587+
</gl-sprintf>
588+
</div>
544589
</template>
545-
</div>
546-
<div v-if="descriptions[variable.key]" class="gl-text-subtle">
547-
{{ descriptions[variable.key] }}
548-
</div>
590+
</gl-form-group>
549591
</div>
550592
551-
<template #description>
552-
<gl-sprintf :message="$options.i18n.variablesDescription">
553-
<template #link="{ content }">
554-
<gl-link v-if="isMaintainer" :href="settingsLink" data-testid="ci-cd-settings-link">{{
555-
content
556-
}}</gl-link>
557-
<template v-else>{{ content }}</template>
558-
</template>
559-
</gl-sprintf>
560-
<gl-link :href="$options.learnMorePath" target="_blank">{{
561-
$options.i18n.learnMore
562-
}}</gl-link>
563-
</template>
564-
</gl-form-group>
565-
<div class="gl-mb-4 gl-text-subtle">
566-
<gl-sprintf :message="$options.i18n.overrideNoteText">
567-
<template #bold="{ content }">
568-
<strong>
569-
{{ content }}
570-
</strong>
571-
</template>
572-
</gl-sprintf>
573-
</div>
574-
<div class="gl-flex gl-pt-5">
575-
<gl-button
576-
type="submit"
577-
category="primary"
578-
variant="confirm"
579-
class="js-no-auto-disable gl-mr-3"
580-
data-testid="run-pipeline-button"
581-
:disabled="submitted"
582-
>{{ s__('Pipeline|New pipeline') }}</gl-button
583-
>
584-
<gl-button :href="pipelinesPath">{{ __('Cancel') }}</gl-button>
593+
<div class="gl-mt-4 gl-flex">
594+
<gl-button
595+
type="submit"
596+
category="primary"
597+
variant="confirm"
598+
class="js-no-auto-disable gl-mr-3"
599+
data-testid="run-pipeline-button"
600+
:disabled="submitted"
601+
>{{ s__('Pipeline|New pipeline') }}</gl-button
602+
>
603+
<gl-button :href="pipelinesPath">{{ __('Cancel') }}</gl-button>
604+
</div>
585605
</div>
586606
</gl-form>
587607
</template>

0 commit comments

Comments
 (0)