Commit 8c7b8139 authored by Jose Vargas's avatar Jose Vargas

Refactor update for apollo query

parent abf58f3a
...@@ -44,9 +44,7 @@ export default { ...@@ -44,9 +44,7 @@ export default {
}; };
}, },
update(data) { update(data) {
this.groupId = data.group?.id; return data;
this.projectId = data.project?.id;
return data?.runnerPlatforms?.nodes;
}, },
error() { error() {
this.showAlert = true; this.showAlert = true;
...@@ -59,9 +57,7 @@ export default { ...@@ -59,9 +57,7 @@ export default {
selectedPlatformArchitectures: [], selectedPlatformArchitectures: [],
selectedPlatform: {}, selectedPlatform: {},
selectedArchitecture: {}, selectedArchitecture: {},
runnerPlatforms: [], runnerPlatforms: {},
projectId: '',
groupId: '',
instructions: {}, instructions: {},
}; };
}, },
...@@ -72,10 +68,19 @@ export default { ...@@ -72,10 +68,19 @@ export default {
instructionsEmpty() { instructionsEmpty() {
return this.instructions && Object.keys(this.instructions).length === 0; return this.instructions && Object.keys(this.instructions).length === 0;
}, },
groupId() {
return this.runnerPlatforms?.group?.id ?? '';
},
projectId() {
return this.runnerPlatforms?.project?.id ?? '';
},
platforms() {
return this.runnerPlatforms.runnerPlatforms?.nodes;
},
}, },
methods: { methods: {
selectPlatform(name) { selectPlatform(name) {
this.selectedPlatform = this.runnerPlatforms.find(platform => platform.name === name); this.selectedPlatform = this.platforms.find(platform => platform.name === name);
this.selectedPlatformArchitectures = this.selectedPlatform?.architectures?.nodes; this.selectedPlatformArchitectures = this.selectedPlatform?.architectures?.nodes;
[this.selectedArchitecture] = this.selectedPlatformArchitectures; [this.selectedArchitecture] = this.selectedPlatformArchitectures;
this.selectArchitecture(this.selectedArchitecture); this.selectArchitecture(this.selectedArchitecture);
...@@ -88,8 +93,8 @@ export default { ...@@ -88,8 +93,8 @@ export default {
return { return {
platform: this.selectedPlatform.name, platform: this.selectedPlatform.name,
architecture: this.selectedArchitecture.name, architecture: this.selectedArchitecture.name,
projectId: this.projectId ? this.projectId : '', projectId: this.projectId,
groupId: this.groupId ? this.groupId : '', groupId: this.groupId,
}; };
}, },
query: getRunnerSetupInstructions, query: getRunnerSetupInstructions,
...@@ -138,7 +143,7 @@ export default { ...@@ -138,7 +143,7 @@ export default {
<h5>{{ __('Environment') }}</h5> <h5>{{ __('Environment') }}</h5>
<gl-button-group class="gl-mb-5"> <gl-button-group class="gl-mb-5">
<gl-button <gl-button
v-for="platform in runnerPlatforms" v-for="platform in platforms"
:key="platform.name" :key="platform.name"
data-testid="platform-button" data-testid="platform-button"
@click="selectPlatform(platform.name)" @click="selectPlatform(platform.name)"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment