diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-02 12:10:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-02 12:10:46 +0300 |
commit | f3b405856d99583bcd2f27c909abe779a48db512 (patch) | |
tree | 82d3ec2494523fb5b52f3f852be978c6b7263651 /app/assets/javascripts/vue_shared/components/runner_instructions | |
parent | 9ecca14b2b3f05673a15399a2d1cc439206f3e0f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/runner_instructions')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/runner_instructions/runner_instructions_modal.vue | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/app/assets/javascripts/vue_shared/components/runner_instructions/runner_instructions_modal.vue b/app/assets/javascripts/vue_shared/components/runner_instructions/runner_instructions_modal.vue index d5493aa5a66..9eaaf7d1c18 100644 --- a/app/assets/javascripts/vue_shared/components/runner_instructions/runner_instructions_modal.vue +++ b/app/assets/javascripts/vue_shared/components/runner_instructions/runner_instructions_modal.vue @@ -50,6 +50,11 @@ export default { required: false, default: null, }, + defaultPlatformName: { + type: String, + required: false, + default: null, + }, }, apollo: { platforms: { @@ -64,9 +69,10 @@ export default { }); }, result() { - // Select first platform by default - if (this.platforms?.[0]) { - this.selectPlatform(this.platforms[0]); + if (this.platforms.length) { + // If it is set and available, select the defaultSelectedPlatform. + // Otherwise, select the first available platform + this.selectPlatform(this.defaultPlatform() || this.platforms[0]); } }, error() { @@ -138,6 +144,14 @@ export default { show() { this.$refs.modal.show(); }, + focusSelected() { + // By default the first platform always gets the focus, but when the `defaultPlatformName` + // property is present, any other platform might actually be selected. + this.$refs[this.selectedPlatformName]?.[0].$el.focus(); + }, + defaultPlatform() { + return this.platforms.find((platform) => platform.name === this.defaultPlatformName); + }, selectPlatform(platform) { this.selectedPlatform = platform; @@ -182,6 +196,8 @@ export default { :title="$options.i18n.installARunner" :action-secondary="$options.closeButton" v-bind="$attrs" + v-on="$listeners" + @shown="focusSelected" > <gl-alert v-if="showAlert" variant="danger" @dismiss="toggleAlert(false)"> {{ $options.i18n.fetchError }} @@ -203,6 +219,7 @@ export default { <gl-button v-for="platform in platforms" :key="platform.name" + :ref="platform.name" :selected="selectedPlatform && selectedPlatform.name === platform.name" @click="selectPlatform(platform)" > |