fix(接口自动化): 场景步骤权限控制

This commit is contained in:
fit2-zhao 2020-12-18 16:37:27 +08:00
parent 55c26387dd
commit ee9c1ba153
6 changed files with 41 additions and 35 deletions

@ -1 +1 @@
Subproject commit 7e32340f93c59e1b26332632ebae2eb83fbb6059 Subproject commit 61397c16728a63493507679f7e0940d9099f337f

View File

@ -197,37 +197,37 @@
<el-col :span="3" class="ms-left-cell"> <el-col :span="3" class="ms-left-cell">
<el-button type="primary" icon="el-icon-refresh" size="small" @click="showAll">{{$t('commons.show_all')}}</el-button> <el-button type="primary" icon="el-icon-refresh" size="small" @click="showAll">{{$t('commons.show_all')}}</el-button>
<br/> <br/>
<div v-if="operatingElements.indexOf('HTTPSamplerProxy')>0 || operatingElements.indexOf('DubboSampler')>0 || operatingElements.indexOf('JDBCSampler')>0 || operatingElements.indexOf('TCPSampler')>0 "> <div v-if="operatingElements.indexOf('HTTPSamplerProxy')!=-1 || operatingElements.indexOf('DubboSampler')!=-1 || operatingElements.indexOf('JDBCSampler')!=-1 || operatingElements.indexOf('TCPSampler')!=-1 ">
<el-button class="ms-right-buttion ms-btn-1" size="small" @click="apiListImport">+{{$t('api_test.automation.api_list_import')}}</el-button> <el-button class="ms-right-buttion ms-btn-1" size="small" @click="apiListImport">+{{$t('api_test.automation.api_list_import')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('OT_IMPORT')>0"> <div v-if="operatingElements.indexOf('OT_IMPORT')!=-1">
<el-button class="ms-right-buttion" size="small" style="color: #409EFF;background-color: #EEF5FE" @click="addComponent('OT_IMPORT')">+{{$t('api_test.automation.external_import')}}</el-button> <el-button class="ms-right-buttion" size="small" style="color: #409EFF;background-color: #EEF5FE" @click="addComponent('OT_IMPORT')">+{{$t('api_test.automation.external_import')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('ConstantTimer')>0"> <div v-if="operatingElements.indexOf('ConstantTimer')!=-1">
<el-button class="ms-right-buttion ms-btn-3" size="small" @click="addComponent('ConstantTimer')">+{{$t('api_test.automation.wait_controller')}}</el-button> <el-button class="ms-right-buttion ms-btn-3" size="small" @click="addComponent('ConstantTimer')">+{{$t('api_test.automation.wait_controller')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('IfController')>0"> <div v-if="operatingElements.indexOf('IfController')!=-1">
<el-button class="ms-right-buttion ms-btn-4" size="small" @click="addComponent('IfController')">+{{$t('api_test.automation.if_controller')}}</el-button> <el-button class="ms-right-buttion ms-btn-4" size="small" @click="addComponent('IfController')">+{{$t('api_test.automation.if_controller')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('scenario')===0"> <div v-if="operatingElements.indexOf('scenario')===0">
<el-button class="ms-right-buttion ms-btn-5" size="small" @click="addComponent('scenario')">+{{$t('api_test.automation.scenario_import')}}</el-button> <el-button class="ms-right-buttion ms-btn-5" size="small" @click="addComponent('scenario')">+{{$t('api_test.automation.scenario_import')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('JSR223Processor')>0"> <div v-if="operatingElements.indexOf('JSR223Processor')!=-1">
<el-button class="ms-right-buttion ms-btn-6" size="small" @click="addComponent('JSR223Processor')">+{{$t('api_test.automation.customize_script')}}</el-button> <el-button class="ms-right-buttion ms-btn-6" size="small" @click="addComponent('JSR223Processor')">+{{$t('api_test.automation.customize_script')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('CustomizeReq')>0"> <div v-if="operatingElements.indexOf('CustomizeReq')!=-1">
<el-button class="ms-right-buttion ms-btn-7" size="small" @click="addComponent('CustomizeReq')">+{{$t('api_test.automation.customize_req')}}</el-button> <el-button class="ms-right-buttion ms-btn-7" size="small" @click="addComponent('CustomizeReq')">+{{$t('api_test.automation.customize_req')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('JSR223PreProcessor')>0"> <div v-if="operatingElements.indexOf('JSR223PreProcessor')!=-1">
<el-button class="ms-right-buttion ms-btn-8" size="small" @click="addComponent('JSR223PreProcessor')">+{{$t('api_test.definition.request.pre_script')}}</el-button> <el-button class="ms-right-buttion ms-btn-8" size="small" @click="addComponent('JSR223PreProcessor')">+{{$t('api_test.definition.request.pre_script')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('JSR223PostProcessor')>0"> <div v-if="operatingElements.indexOf('JSR223PostProcessor')!=-1">
<el-button class="ms-right-buttion ms-btn-9" size="small" @click="addComponent('JSR223PostProcessor')">+{{$t('api_test.definition.request.post_script')}}</el-button> <el-button class="ms-right-buttion ms-btn-9" size="small" @click="addComponent('JSR223PostProcessor')">+{{$t('api_test.definition.request.post_script')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('Assertions')>0"> <div v-if="operatingElements.indexOf('Assertions')!=-1">
<el-button class="ms-right-buttion ms-btn-10" size="small" @click="addComponent('Assertions')">+{{$t('api_test.definition.request.assertions_rule')}}</el-button> <el-button class="ms-right-buttion ms-btn-10" size="small" @click="addComponent('Assertions')">+{{$t('api_test.definition.request.assertions_rule')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('Extract')>0"> <div v-if="operatingElements.indexOf('Extract')!=-1">
<el-button class="ms-right-buttion ms-btn-11" size="small" @click="addComponent('Extract')">+{{$t('api_test.definition.request.extract_param')}}</el-button> <el-button class="ms-right-buttion ms-btn-11" size="small" @click="addComponent('Extract')">+{{$t('api_test.definition.request.extract_param')}}</el-button>
</div> </div>
</el-col> </el-col>
@ -245,7 +245,6 @@
<!--自定义接口--> <!--自定义接口-->
<el-drawer :visible.sync="customizeVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('api_test.automation.customize_req')" style="overflow: auto" :modal="false" size="90%"> <el-drawer :visible.sync="customizeVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('api_test.automation.customize_req')" style="overflow: auto" :modal="false" size="90%">
<ms-api-customize :request="customizeRequest" @addCustomizeApi="addCustomizeApi"/> <ms-api-customize :request="customizeRequest" @addCustomizeApi="addCustomizeApi"/>
<el-button style="float: right;margin: 20px" @click="addCustomizeApi">{{$t('commons.save')}}</el-button>
</el-drawer> </el-drawer>
<!--场景导入 --> <!--场景导入 -->
<el-drawer :visible.sync="scenarioVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('api_test.automation.scenario_import')" style="overflow: auto" :modal="false" size="90%"> <el-drawer :visible.sync="scenarioVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('api_test.automation.scenario_import')" style="overflow: auto" :modal="false" size="90%">
@ -373,7 +372,13 @@
this.getApiScenario(); this.getApiScenario();
this.getEnvironments(); this.getEnvironments();
}, },
watch: {}, mounted() {
document.addEventListener('click', e => {
if (!this.$el.contains(e.target)) {
}
})
},
watch: {},
methods: { methods: {
addComponent(type) { addComponent(type) {
switch (type) { switch (type) {
@ -609,16 +614,16 @@
environmentConfigClose() { environmentConfigClose() {
this.getEnvironments(); this.getEnvironments();
}, },
allowDrop(draggingNode, dropNode, type) { allowDrop(draggingNode, dropNode, dropType) {
// if (draggingNode.level == dropNode.level) { if (dropType != "inner") {
// return true; return true;
// } }
// else if (ELEMENTS.get(dropNode.data.type).indexOf(draggingNode.data.type) != -1) { else if (dropType === "inner" && ELEMENTS.get(dropNode.data.type).indexOf(draggingNode.data.type) != -1) {
// return true; return true;
// } }
return true; return false;
}, },
allowDrag() { allowDrag(draggingNode, dropNode, dropType) {
this.sort(); this.sort();
this.reload(); this.reload();
}, },

View File

@ -1,19 +1,19 @@
export const ELEMENTS = new Map([ export const ELEMENTS = new Map([
['ALL', ["scenario", "HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "IfController", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract", "CustomizeReq"]], ['ALL', ["scenario", "HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "IfController", "ConstantTimer", "JSR223Processor", "CustomizeReq"]],
['scenario', ["API", "CASE", "OT_IMPORT", "IfController", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract", "CustomizeReq"]], ['scenario', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "CASE", "OT_IMPORT", "IfController", "ConstantTimer", "JSR223Processor", "CustomizeReq"]],
['HTTPSamplerProxy', ["IfController", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]], ['HTTPSamplerProxy', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]],
['DubboSampler', ["IfController", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]], ['DubboSampler', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]],
['JDBCSampler', ["IfController", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]], ['JDBCSampler', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]],
['TCPSampler', ["IfController", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]], ['TCPSampler', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]],
['OT_IMPORT', []], ['OT_IMPORT', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]],
['IfController', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract", "CustomizeReq"]], ['IfController', ["IfController", "HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract", "CustomizeReq"]],
['ConstantTimer', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "IfController", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract", "CustomizeReq"]], ['ConstantTimer', []],
['JSR223Processor', []], ['JSR223Processor', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]],
['JSR223PreProcessor', []], ['JSR223PreProcessor', []],
['JSR223PostProcessor', []], ['JSR223PostProcessor', []],
['Assertions', []], ['Assertions', []],
['Extract', []], ['Extract', []],
['CustomizeReq', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "IfController", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]], ['CustomizeReq', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]],
]) ])
export const ELEMENT_TYPE = { export const ELEMENT_TYPE = {

View File

@ -173,7 +173,7 @@
created() { created() {
this.getMaintainerOptions(); this.getMaintainerOptions();
this.httpForm = this.basisData; this.httpForm = JSON.parse(JSON.stringify(this.basisData));
} }
} }
</script> </script>

View File

@ -66,6 +66,7 @@
let validateURL = (rule, value, callback) => { let validateURL = (rule, value, callback) => {
try { try {
new URL(this.debugForm.url); new URL(this.debugForm.url);
callback();
} catch (e) { } catch (e) {
callback(this.$t('api_test.request.url_invalid')); callback(this.$t('api_test.request.url_invalid'));
} }

@ -1 +1 @@
Subproject commit 010ad7a5f072a5e9d368c756a2473bbd20781433 Subproject commit d39dafaf84b9c7a56cb51f2caf67dd7dfde5938c