@@ -16,6 +16,7 @@ import { GlBreakpointInstance } from '@gitlab/ui/dist/utils';
16
16
import { uniqueId } from ' lodash' ;
17
17
import * as Sentry from ' ~/sentry/sentry_browser_wrapper' ;
18
18
import { fetchPolicies } from ' ~/lib/graphql' ;
19
+ import glFeatureFlagsMixin from ' ~/vue_shared/mixins/gl_feature_flags_mixin' ;
19
20
import SafeHtml from ' ~/vue_shared/directives/safe_html' ;
20
21
import { visitUrl } from ' ~/lib/utils/url_utility' ;
21
22
import { s__ , __ , n__ } from ' ~/locale' ;
@@ -24,14 +25,15 @@ import { helpPagePath } from '~/helpers/help_page_helper';
24
25
import {
25
26
IDENTITY_VERIFICATION_REQUIRED_ERROR ,
26
27
CONFIG_VARIABLES_TIMEOUT ,
27
- FILE_TYPE ,
28
- VARIABLE_TYPE ,
28
+ CI_VARIABLE_TYPE_FILE ,
29
+ CI_VARIABLE_TYPE_ENV_VAR ,
29
30
} from ' ../constants' ;
30
31
import createPipelineMutation from ' ../graphql/mutations/create_pipeline.mutation.graphql' ;
31
32
import ciConfigVariablesQuery from ' ../graphql/queries/ci_config_variables.graphql' ;
32
33
import filterVariables from ' ../utils/filter_variables' ;
33
34
import RefsDropdown from ' ./refs_dropdown.vue' ;
34
35
import VariableValuesListbox from ' ./variable_values_listbox.vue' ;
36
+ import PipelineVariablesForm from ' ./pipeline_variables_form.vue' ;
35
37
36
38
let pollTimeout;
37
39
export const POLLING_INTERVAL = 2000 ;
@@ -71,12 +73,14 @@ export default {
71
73
GlLink,
72
74
GlSprintf,
73
75
GlLoadingIcon,
76
+ PipelineVariablesForm,
74
77
RefsDropdown,
75
78
VariableValuesListbox,
76
79
PipelineAccountVerificationAlert : () =>
77
80
import (' ee_component/vue_shared/components/pipeline_account_verification_alert.vue' ),
78
81
},
79
82
directives: { SafeHtml },
83
+ mixins: [glFeatureFlagsMixin ()],
80
84
props: {
81
85
pipelinesPath: {
82
86
type: String ,
@@ -155,9 +159,9 @@ export default {
155
159
ciConfigVariables: {
156
160
fetchPolicy: fetchPolicies .NO_CACHE ,
157
161
query: ciConfigVariablesQuery,
158
- // Skip when variables already cached in `form`
162
+ // Skip when variables already cached in `form` or feature flag is enabled
159
163
skip () {
160
- return Object .keys (this .form ).includes (this .refFullName );
164
+ return Object .keys (this .form ).includes (this .refFullName ) || this . isUsingPipelineInputs ;
161
165
},
162
166
variables () {
163
167
return {
@@ -207,6 +211,9 @@ export default {
207
211
isLoading () {
208
212
return this .$apollo .queries .ciConfigVariables .loading || this .isFetchingCiConfigVariables ;
209
213
},
214
+ isUsingPipelineInputs () {
215
+ return this .glFeatures .ciInputsForPipelines ;
216
+ },
210
217
overMaxWarningsLimit () {
211
218
return this .totalWarnings > this .maxWarnings ;
212
219
},
@@ -240,11 +247,11 @@ export default {
240
247
variableTypeListboxItems () {
241
248
return [
242
249
{
243
- value: VARIABLE_TYPE ,
250
+ value: CI_VARIABLE_TYPE_ENV_VAR ,
244
251
text: s__ (' Pipeline|Variable' ),
245
252
},
246
253
{
247
- value: FILE_TYPE ,
254
+ value: CI_VARIABLE_TYPE_FILE ,
248
255
text: s__ (' Pipeline|File' ),
249
256
},
250
257
];
@@ -261,7 +268,7 @@ export default {
261
268
262
269
variables .push ({
263
270
uniqueId: uniqueId (` var-${ refValue} ` ),
264
- variable_type : VARIABLE_TYPE ,
271
+ variableType : CI_VARIABLE_TYPE_ENV_VAR ,
265
272
key: ' ' ,
266
273
value: ' ' ,
267
274
});
@@ -295,17 +302,17 @@ export default {
295
302
// Add default variables from yml
296
303
this .setVariableParams (
297
304
this .refFullName ,
298
- VARIABLE_TYPE ,
305
+ CI_VARIABLE_TYPE_ENV_VAR ,
299
306
this .configVariablesWithDescription .values ,
300
307
);
301
308
302
309
// Add/update variables, e.g. from query string
303
310
if (this .variableParams ) {
304
- this .setVariableParams (this .refFullName , VARIABLE_TYPE , this .variableParams );
311
+ this .setVariableParams (this .refFullName , CI_VARIABLE_TYPE_ENV_VAR , this .variableParams );
305
312
}
306
313
307
314
if (this .fileParams ) {
308
- this .setVariableParams (this .refFullName , FILE_TYPE , this .fileParams );
315
+ this .setVariableParams (this .refFullName , CI_VARIABLE_TYPE_FILE , this .fileParams );
309
316
}
310
317
311
318
// Adds empty var at the end of the form
@@ -324,7 +331,7 @@ export default {
324
331
uniqueId: uniqueId (` var-${ refValue} ` ),
325
332
key,
326
333
value,
327
- variable_type : type,
334
+ variableType : type,
328
335
});
329
336
}
330
337
},
@@ -469,119 +476,132 @@ export default {
469
476
< / p>
470
477
< / details>
471
478
< / 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>
479
487
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
+ / >
481
538
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>
524
564
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>
544
589
< / template>
545
- < / div>
546
- < div v- if = " descriptions[variable.key]" class = " gl-text-subtle" >
547
- {{ descriptions[variable .key ] }}
548
- < / div>
590
+ < / gl- form- group>
549
591
< / div>
550
592
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>
585
605
< / div>
586
606
< / gl- form>
587
607
< / template>
0 commit comments