199
199
:rules =" isFieldRequired('repository') ? [v => !!v || $t('repository_required')] : []"
200
200
outlined
201
201
dense
202
+ hide-details
202
203
:required =" isFieldRequired('repository')"
203
204
:disabled =" formSaving"
204
205
v-if =" needField('repository')"
205
206
></v-autocomplete >
206
207
208
+ <div class =" mb-3 text-right" >
209
+
210
+ <a
211
+ v-if =" !item.git_branch && !setBranch"
212
+ @click =" setBranch = true"
213
+ >Set branch</a >
214
+
215
+ </div >
216
+
217
+ <div v-if =" item.git_branch || setBranch" >
218
+ <div v-if =" branches != null" >
219
+ <v-autocomplete
220
+ clearable
221
+ :items =" branches"
222
+ v-model =" item.git_branch"
223
+ :label =" fieldLabel('branch')"
224
+ outlined
225
+ dense
226
+ :disabled =" formSaving"
227
+ :placeholder =" $t('branch')"
228
+ ></v-autocomplete >
229
+ </div >
230
+ <div v-else >
231
+ <v-text-field
232
+ clearable
233
+ v-model =" item.git_branch"
234
+ :label =" fieldLabel('branch')"
235
+ outlined
236
+ dense
237
+ :disabled =" formSaving"
238
+ :placeholder =" $t('branch')"
239
+ ></v-text-field >
240
+ </div >
241
+ </div >
242
+
207
243
<v-autocomplete
208
244
v-model =" item.environment_id"
209
245
:label =" fieldLabel('environment')"
237
273
<h2 class =" mb-4" >{{ $t('template_advanced') }}</h2 >
238
274
239
275
<div class =" mb-4" >
240
- <v-text-field
241
- v-model =" item.git_branch"
242
- :label =" fieldLabel('branch')"
243
- outlined
244
- dense
245
- :disabled =" formSaving"
246
- :placeholder =" $t('branch')"
247
- ></v-text-field >
248
276
249
277
<v-autocomplete
250
278
v-if =" premiumFeatures.project_runners"
@@ -533,10 +561,22 @@ export default {
533
561
534
562
args: [],
535
563
runnerTags: null ,
564
+ branches: null ,
565
+ setBranch: false ,
536
566
};
537
567
},
538
568
539
569
watch: {
570
+ gitBranch () {
571
+ this .setBranch = false ;
572
+ },
573
+
574
+ async repositoryId () {
575
+ this .branches = null ;
576
+
577
+ await this .loadBranches ();
578
+ },
579
+
540
580
needReset (val ) {
541
581
if (val) {
542
582
if (this .item != null ) {
@@ -555,7 +595,19 @@ export default {
555
595
},
556
596
},
557
597
598
+ async created () {
599
+ await this .loadBranches ();
600
+ },
601
+
558
602
computed: {
603
+ repositoryId () {
604
+ return this .item ? .repository_id ;
605
+ },
606
+
607
+ gitBranch () {
608
+ return this .item ? .git_branch ;
609
+ },
610
+
559
611
allow_override_inventory: {
560
612
get () {
561
613
return this .item .task_params .allow_override_inventory ;
@@ -630,6 +682,16 @@ export default {
630
682
},
631
683
632
684
methods: {
685
+ async loadBranches () {
686
+ if (this .repositoryId == null ) {
687
+ return ;
688
+ }
689
+
690
+ this .branches = await this .loadProjectEndpoint (
691
+ ` /repositories/${ this .repositoryId } /branches` ,
692
+ );
693
+ },
694
+
633
695
validateBackendFilename (v ) {
634
696
if (! v) {
635
697
return true ;
0 commit comments