-
+
{{ $t('api_test.environment.environment_config') }}
@@ -78,12 +78,12 @@ export default {
const project = this.projectList.find(p => p.id === id);
return project ? project.name : "";
},
- openEnvironmentConfig(projectId) {
+ openEnvironmentConfig(projectId, envId) {
if (!projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
- this.$refs.environmentConfig.open(projectId);
+ this.$refs.environmentConfig.open(projectId, envId);
},
handleConfirm() {
let map = new Map();
diff --git a/frontend/src/business/components/api/definition/components/case/MsEnvironmentSelect.vue b/frontend/src/business/components/api/definition/components/case/MsEnvironmentSelect.vue
index cdc1046818..9c3ca59f9f 100644
--- a/frontend/src/business/components/api/definition/components/case/MsEnvironmentSelect.vue
+++ b/frontend/src/business/components/api/definition/components/case/MsEnvironmentSelect.vue
@@ -77,7 +77,7 @@
this.$error(this.$t('api_test.select_project'));
return;
}
- this.$refs.environmentConfig.open(this.projectId);
+ this.$refs.environmentConfig.open(this.projectId, this.environmentId);
},
environmentChange(value) {
for (let i in this.environments) {
diff --git a/frontend/src/business/components/api/definition/components/environment/ApiEnvironmentConfig.vue b/frontend/src/business/components/api/definition/components/environment/ApiEnvironmentConfig.vue
index 5af6936688..4215d0de72 100644
--- a/frontend/src/business/components/api/definition/components/environment/ApiEnvironmentConfig.vue
+++ b/frontend/src/business/components/api/definition/components/environment/ApiEnvironmentConfig.vue
@@ -46,13 +46,15 @@
icon: 'el-icon-delete',
func: this.deleteEnvironment
}
- ]
+ ],
+ selectEnvironmentId: ''
}
},
methods: {
- open: function (projectId) {
+ open: function (projectId, envId) {
this.visible = true;
this.projectId = projectId;
+ this.selectEnvironmentId = envId;
this.getEnvironments();
listenGoBack(this.close);
},
@@ -114,7 +116,16 @@
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
if (this.environments.length > 0) {
- this.$refs.environmentItems.itemSelected(0, this.environments[0]);
+ if (this.selectEnvironmentId) {
+ const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
+ if (index !== -1) {
+ this.$refs.environmentItems.itemSelected(index, this.environments[index]);
+ } else {
+ this.$refs.environmentItems.itemSelected(0, this.environments[0]);
+ }
+ } else {
+ this.$refs.environmentItems.itemSelected(0, this.environments[0]);
+ }
} else {
let item = new Environment({
projectId: this.projectId
diff --git a/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue b/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue
index c534d2bd60..3c22c4b94f 100644
--- a/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue
+++ b/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue
@@ -46,13 +46,15 @@
icon: 'el-icon-delete',
func: this.deleteEnvironment
}
- ]
+ ],
+ selectEnvironmentId: ''
}
},
methods: {
- open: function (projectId) {
+ open: function (projectId, envId) {
this.visible = true;
this.projectId = projectId;
+ this.selectEnvironmentId = envId;
this.getEnvironments();
listenGoBack(this.close);
},
@@ -114,7 +116,16 @@
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
if (this.environments.length > 0) {
- this.$refs.environmentItems.itemSelected(0, this.environments[0]);
+ if (this.selectEnvironmentId) {
+ const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
+ if (index !== -1) {
+ this.$refs.environmentItems.itemSelected(index, this.environments[index]);
+ } else {
+ this.$refs.environmentItems.itemSelected(0, this.environments[0]);
+ }
+ } else {
+ this.$refs.environmentItems.itemSelected(0, this.environments[0]);
+ }
} else {
let item = new Environment({
projectId: this.projectId