diff --git a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java index da8e031240..b8b10f1d0f 100644 --- a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java +++ b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java @@ -136,7 +136,7 @@ public class ApiScenarioEnvService { if (!StringUtils.equalsIgnoreCase(httpSamplerProxy.getReferenced(), "Created") || (httpSamplerProxy.getIsRefEnvironment() != null && httpSamplerProxy.getIsRefEnvironment())) { env.getProjectIds().add(httpSamplerProxy.getProjectId()); - env.setFullUrl(false); + env.setFullUrl(httpSamplerProxy.getIsRefEnvironment() == null ? true : false); } } else if (StringUtils.equals(testElement.getType(), "JDBCSampler") || StringUtils.equals(testElement.getType(), "TCPSampler")) { env.getProjectIds().add(testElement.getProjectId()); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 9608e15007..83efa99aea 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -1151,13 +1151,14 @@ export default { setComponent(type, this, plugin); } }, + nodeClick(data, node) { if ((data.referenced != 'REF' && data.referenced != 'Deleted' && !data.disabled && this.stepFilter) || data.refType === 'CASE') { this.operatingElements = this.stepFilter.get(data.type); } else { this.operatingElements = []; } - if (!this.operatingElements && this.stepFilter) { + if ((!this.operatingElements && this.stepFilter)|| this.stepFilter.get("AllSamplerProxy").indexOf(data.type) !== -1) { this.operatingElements = this.stepFilter.get("ALL"); } this.selectedTreeNode = data; @@ -1227,9 +1228,14 @@ export default { addCustomizeApi(request) { this.customizeVisible = false; request.enable === undefined ? request.enable = true : request.enable; - if (this.selectedTreeNode !== undefined) { - this.selectedTreeNode.hashTree.push(request); - } else { + if(this.selectedTreeNode !== undefined){ + if(this.stepFilter.get("AllSamplerProxy").indexOf(this.selectedTreeNode.type) !== -1){ + this.scenarioDefinition.splice(this.selectedTreeNode.index,0,request); + this.$store.state.forceRerenderIndex = getUUID(); + }else{ + this.selectedTreeNode.hashTree.push(request) ; + } + }else{ this.scenarioDefinition.push(request); } this.customizeRequest = {}; @@ -1250,9 +1256,14 @@ export default { this.resetResourceId(item.hashTree); item.enable === undefined ? item.enable = true : item.enable; item.variableEnable = item.variableEnable === undefined ? true : item.variableEnable; - if (this.selectedTreeNode !== undefined) { - this.selectedTreeNode.hashTree.push(item); - } else { + if(this.selectedTreeNode !== undefined){ + if(this.stepFilter.get("AllSamplerProxy").indexOf(this.selectedTreeNode.type) !== -1){ + this.scenarioDefinition.splice(this.selectedTreeNode.index,0,item); + this.$store.state.forceRerenderIndex = getUUID(); + }else{ + this.selectedTreeNode.hashTree.push(item) ; + } + }else{ this.scenarioDefinition.push(item); } }) @@ -1297,9 +1308,14 @@ export default { if (referenced === 'REF' && request.hashTree) { this.recursiveSorting(request.hashTree); } - if (this.selectedTreeNode !== undefined) { - this.selectedTreeNode.hashTree.push(request); - } else { + if(this.selectedTreeNode !== undefined){ + if(this.stepFilter.get("AllSamplerProxy").indexOf(this.selectedTreeNode.type) !== -1){ + this.scenarioDefinition.splice(this.selectedTreeNode.index,0,request); + this.$store.state.forceRerenderIndex = getUUID(); + }else{ + this.selectedTreeNode.hashTree.push(request) ; + } + }else{ this.scenarioDefinition.push(request); } }, diff --git a/frontend/src/business/components/api/automation/scenario/menu/Menu.js b/frontend/src/business/components/api/automation/scenario/menu/Menu.js index cc87e80b5f..e451ed0a18 100644 --- a/frontend/src/business/components/api/automation/scenario/menu/Menu.js +++ b/frontend/src/business/components/api/automation/scenario/menu/Menu.js @@ -145,56 +145,56 @@ export function buttons(this_) { ]; return buttons.filter(btn => btn.show); } - +export function setNode(_this,node) { + if(_this.selectedTreeNode !== undefined){ + if(_this.stepFilter.get("AllSamplerProxy").indexOf(_this.selectedTreeNode.type) !== -1){ + _this.scenarioDefinition.splice(_this.selectedTreeNode.index,0,node); + _this.$store.state.forceRerenderIndex = getUUID(); + }else{ + _this.selectedTreeNode.hashTree.push(node) ; + } + }else{ + _this.scenarioDefinition.push(node); + } +} export function setComponent(type, _this, plugin) { switch (type) { case ELEMENT_TYPE.IfController: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new IfController()) : - _this.scenarioDefinition.push(new IfController()); + setNode(_this,new IfController()); break; case ELEMENT_TYPE.ConstantTimer: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new ConstantTimer({label: "SCENARIO-REF-STEP"})) : - _this.scenarioDefinition.push(new ConstantTimer()); + setNode(_this,new ConstantTimer({label: "SCENARIO-REF-STEP"})); break; case ELEMENT_TYPE.JSR223Processor: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({label: "SCENARIO-REF-STEP"})) : - _this.scenarioDefinition.push(new JSR223Processor()); + setNode(_this,new JSR223Processor({label: "SCENARIO-REF-STEP"})); break; case ELEMENT_TYPE.JSR223PreProcessor: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PreProcessor", label: "SCENARIO-REF-STEP"})) : - _this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PreProcessor"})); + setNode(_this, new JSR223Processor({type: "JSR223PreProcessor", label: "SCENARIO-REF-STEP"})); break; case ELEMENT_TYPE.JSR223PostProcessor: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PostProcessor", label: "SCENARIO-REF-STEP"})) : - _this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PostProcessor"})); + setNode(_this, new JSR223Processor({type: "JSR223PostProcessor", label: "SCENARIO-REF-STEP"})); break; case ELEMENT_TYPE.JDBCPreProcessor: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPreProcessor", label: "SCENARIO-REF-STEP"})) : - _this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPreProcessor"})); + setNode(_this, new JDBCProcessor({type: "JDBCPreProcessor", label: "SCENARIO-REF-STEP"})); break; case ELEMENT_TYPE.JDBCPostProcessor: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPostProcessor", label: "SCENARIO-REF-STEP"})) : - _this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPostProcessor"})); + setNode(_this, new JDBCProcessor({type: "JDBCPostProcessor", label: "SCENARIO-REF-STEP"})); break; case ELEMENT_TYPE.Assertions: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Assertions({label: "SCENARIO-REF-STEP", id: getUUID()})) : - _this.scenarioDefinition.push(new Assertions()); + setNode(_this, new Assertions({label: "SCENARIO-REF-STEP", id: getUUID()})); break; case ELEMENT_TYPE.Extract: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Extract({label: "SCENARIO-REF-STEP", id: getUUID()})) : - _this.scenarioDefinition.push(new Extract()); + setNode(_this, new Extract({label: "SCENARIO-REF-STEP", id: getUUID()})); break; case ELEMENT_TYPE.CustomizeReq: _this.customizeRequest = {protocol: "HTTP", type: "API", hashTree: [], referenced: 'Created', active: false}; _this.customizeVisible = true; break; case ELEMENT_TYPE.LoopController: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new LoopController()) : - _this.scenarioDefinition.push(new LoopController()); + setNode(_this, new LoopController()); break; case ELEMENT_TYPE.TransactionController: - _this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new TransactionController()) : - _this.scenarioDefinition.push(new TransactionController()); + setNode(_this, new TransactionController()); break; case ELEMENT_TYPE.scenario: _this.isBtnHide = true;