diff --git a/backend/pom.xml b/backend/pom.xml index 8f9ad954d0..4e8cc9d5e5 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -444,7 +444,7 @@ io.metersphere metersphere-plugin-core - 1.0 + 1.0.1 diff --git a/backend/src/main/java/io/metersphere/api/jmeter/MenuFactory.java b/backend/src/main/java/io/metersphere/api/jmeter/MenuFactory.java deleted file mode 100644 index 681e4913f5..0000000000 --- a/backend/src/main/java/io/metersphere/api/jmeter/MenuFactory.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.metersphere.api.jmeter; - -public class MenuFactory { - -} diff --git a/backend/src/main/java/io/metersphere/base/domain/Plugin.java b/backend/src/main/java/io/metersphere/base/domain/Plugin.java index cfcc322899..cbada52edf 100644 --- a/backend/src/main/java/io/metersphere/base/domain/Plugin.java +++ b/backend/src/main/java/io/metersphere/base/domain/Plugin.java @@ -13,6 +13,8 @@ public class Plugin implements Serializable { private String scriptId; + private String jmeterClazz; + private String clazzName; private String sourcePath; diff --git a/backend/src/main/java/io/metersphere/base/domain/PluginExample.java b/backend/src/main/java/io/metersphere/base/domain/PluginExample.java index f855b9abe2..fb6f44fcc7 100644 --- a/backend/src/main/java/io/metersphere/base/domain/PluginExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/PluginExample.java @@ -384,6 +384,76 @@ public class PluginExample { return (Criteria) this; } + public Criteria andJmeterClazzIsNull() { + addCriterion("jmeter_clazz is null"); + return (Criteria) this; + } + + public Criteria andJmeterClazzIsNotNull() { + addCriterion("jmeter_clazz is not null"); + return (Criteria) this; + } + + public Criteria andJmeterClazzEqualTo(String value) { + addCriterion("jmeter_clazz =", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzNotEqualTo(String value) { + addCriterion("jmeter_clazz <>", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzGreaterThan(String value) { + addCriterion("jmeter_clazz >", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzGreaterThanOrEqualTo(String value) { + addCriterion("jmeter_clazz >=", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzLessThan(String value) { + addCriterion("jmeter_clazz <", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzLessThanOrEqualTo(String value) { + addCriterion("jmeter_clazz <=", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzLike(String value) { + addCriterion("jmeter_clazz like", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzNotLike(String value) { + addCriterion("jmeter_clazz not like", value, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzIn(List values) { + addCriterion("jmeter_clazz in", values, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzNotIn(List values) { + addCriterion("jmeter_clazz not in", values, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzBetween(String value1, String value2) { + addCriterion("jmeter_clazz between", value1, value2, "jmeterClazz"); + return (Criteria) this; + } + + public Criteria andJmeterClazzNotBetween(String value1, String value2) { + addCriterion("jmeter_clazz not between", value1, value2, "jmeterClazz"); + return (Criteria) this; + } + public Criteria andClazzNameIsNull() { addCriterion("clazz_name is null"); return (Criteria) this; diff --git a/backend/src/main/java/io/metersphere/base/mapper/PluginMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/PluginMapper.xml index 7acaf111bd..ca671513c5 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/PluginMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/PluginMapper.xml @@ -6,6 +6,7 @@ + @@ -77,8 +78,8 @@ - id, `name`, plugin_id, script_id, clazz_name, source_path, source_name, exec_entry, - create_time, update_time, create_user_id + id, `name`, plugin_id, script_id, jmeter_clazz, clazz_name, source_path, source_name, + exec_entry, create_time, update_time, create_user_id form_option, form_script @@ -133,15 +134,15 @@ insert into plugin (id, `name`, plugin_id, - script_id, clazz_name, source_path, - source_name, exec_entry, create_time, - update_time, create_user_id, form_option, - form_script) + script_id, jmeter_clazz, clazz_name, + source_path, source_name, exec_entry, + create_time, update_time, create_user_id, + form_option, form_script) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pluginId,jdbcType=VARCHAR}, - #{scriptId,jdbcType=VARCHAR}, #{clazzName,jdbcType=VARCHAR}, #{sourcePath,jdbcType=VARCHAR}, - #{sourceName,jdbcType=VARCHAR}, #{execEntry,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, - #{updateTime,jdbcType=BIGINT}, #{createUserId,jdbcType=VARCHAR}, #{formOption,jdbcType=LONGVARCHAR}, - #{formScript,jdbcType=LONGVARCHAR}) + #{scriptId,jdbcType=VARCHAR}, #{jmeterClazz,jdbcType=VARCHAR}, #{clazzName,jdbcType=VARCHAR}, + #{sourcePath,jdbcType=VARCHAR}, #{sourceName,jdbcType=VARCHAR}, #{execEntry,jdbcType=VARCHAR}, + #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{createUserId,jdbcType=VARCHAR}, + #{formOption,jdbcType=LONGVARCHAR}, #{formScript,jdbcType=LONGVARCHAR}) insert into plugin @@ -158,6 +159,9 @@ script_id, + + jmeter_clazz, + clazz_name, @@ -199,6 +203,9 @@ #{scriptId,jdbcType=VARCHAR}, + + #{jmeterClazz,jdbcType=VARCHAR}, + #{clazzName,jdbcType=VARCHAR}, @@ -249,6 +256,9 @@ script_id = #{record.scriptId,jdbcType=VARCHAR}, + + jmeter_clazz = #{record.jmeterClazz,jdbcType=VARCHAR}, + clazz_name = #{record.clazzName,jdbcType=VARCHAR}, @@ -287,6 +297,7 @@ `name` = #{record.name,jdbcType=VARCHAR}, plugin_id = #{record.pluginId,jdbcType=VARCHAR}, script_id = #{record.scriptId,jdbcType=VARCHAR}, + jmeter_clazz = #{record.jmeterClazz,jdbcType=VARCHAR}, clazz_name = #{record.clazzName,jdbcType=VARCHAR}, source_path = #{record.sourcePath,jdbcType=VARCHAR}, source_name = #{record.sourceName,jdbcType=VARCHAR}, @@ -306,6 +317,7 @@ `name` = #{record.name,jdbcType=VARCHAR}, plugin_id = #{record.pluginId,jdbcType=VARCHAR}, script_id = #{record.scriptId,jdbcType=VARCHAR}, + jmeter_clazz = #{record.jmeterClazz,jdbcType=VARCHAR}, clazz_name = #{record.clazzName,jdbcType=VARCHAR}, source_path = #{record.sourcePath,jdbcType=VARCHAR}, source_name = #{record.sourceName,jdbcType=VARCHAR}, @@ -329,6 +341,9 @@ script_id = #{scriptId,jdbcType=VARCHAR}, + + jmeter_clazz = #{jmeterClazz,jdbcType=VARCHAR}, + clazz_name = #{clazzName,jdbcType=VARCHAR}, @@ -364,6 +379,7 @@ set `name` = #{name,jdbcType=VARCHAR}, plugin_id = #{pluginId,jdbcType=VARCHAR}, script_id = #{scriptId,jdbcType=VARCHAR}, + jmeter_clazz = #{jmeterClazz,jdbcType=VARCHAR}, clazz_name = #{clazzName,jdbcType=VARCHAR}, source_path = #{sourcePath,jdbcType=VARCHAR}, source_name = #{sourceName,jdbcType=VARCHAR}, @@ -380,6 +396,7 @@ set `name` = #{name,jdbcType=VARCHAR}, plugin_id = #{pluginId,jdbcType=VARCHAR}, script_id = #{scriptId,jdbcType=VARCHAR}, + jmeter_clazz = #{jmeterClazz,jdbcType=VARCHAR}, clazz_name = #{clazzName,jdbcType=VARCHAR}, source_path = #{sourcePath,jdbcType=VARCHAR}, source_name = #{sourceName,jdbcType=VARCHAR}, diff --git a/backend/src/main/java/io/metersphere/service/PluginService.java b/backend/src/main/java/io/metersphere/service/PluginService.java index 4e08944784..3c37fc15b8 100644 --- a/backend/src/main/java/io/metersphere/service/PluginService.java +++ b/backend/src/main/java/io/metersphere/service/PluginService.java @@ -70,6 +70,7 @@ public class PluginService { plugin.setFormScript(item.getFormScript()); plugin.setClazzName(item.getClazzName()); plugin.setSourceName(name); + plugin.setJmeterClazz(item.getJmeterClazz()); plugin.setExecEntry(resource.getEntry()); plugin.setCreateUserId(SessionUtils.getUserId()); pluginMapper.insert(plugin); diff --git a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue index a9035ed2bf..9cfba87d09 100644 --- a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue @@ -67,7 +67,7 @@ import MsApiReportExport from "./ApiReportExport"; import MsApiReportViewHeader from "./ApiReportViewHeader"; import {RequestFactory} from "../../definition/model/ApiTestModel"; import {windowPrint, getCurrentProjectID, getUUID} from "@/common/js/utils"; -import {ELEMENTS} from "../scenario/Setting"; +import {STEP} from "../scenario/Setting"; import {scenario} from "@/business/components/track/plan/event-bus"; export default { @@ -100,7 +100,8 @@ export default { scenarioMap: new Map, exportFlag: false, messageWebSocket: {}, - websocket: {} + websocket: {}, + stepFilter: this.stepFilter, } }, activated() { @@ -221,13 +222,13 @@ export default { let name = item.name ? item.name : this.getType(item.type); let obj = {resId: item.resourceId + "_" + item.parentIndex, index: Number(item.index), label: name, value: {name: name, responseResult: {}, unexecute: true, testing: false}, children: [], unsolicited: true}; tree.children.push(obj); - if (ELEMENTS.get("AllSamplerProxy").indexOf(item.type) != -1) { + if (this.stepFilter.get("AllSamplerProxy").indexOf(item.type) !== -1) { obj.unsolicited = false; obj.type = item.type; } else if (item.type === 'scenario') { this.content.scenarioTotal += 1; } - if (item.hashTree && item.hashTree.length > 0 && ELEMENTS.get("AllSamplerProxy").indexOf(item.type) === -1) { + if (item.hashTree && item.hashTree.length > 0 && this.stepFilter && this.stepFilter.get("AllSamplerProxy").indexOf(item.type) === -1) { this.formatContent(item.hashTree, obj, item.parentIndex); } } diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index a979a2f6cd..4083bd0ba2 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -325,7 +325,7 @@ import {API_STATUS, PRIORITY} from "../../definition/model/JsonData"; import {buttons, setComponent} from './menu/Menu'; import {parseEnvironment} from "../../definition/model/EnvironmentModel"; -import {ELEMENT_TYPE, ELEMENTS,TYPE_TO_C} from "./Setting"; +import {ELEMENT_TYPE, STEP, TYPE_TO_C, PLUGIN_ELEMENTS} from "./Setting"; import { getUUID, objToStrMap, @@ -448,7 +448,8 @@ export default { message: "", websocket: {}, messageWebSocket: {}, - buttonData: [] + buttonData: [], + stepFilter: new STEP, } }, created() { @@ -457,7 +458,9 @@ export default { } this.debug = false; this.debugLoading = false; - this.operatingElements = ELEMENTS.get("ALL"); + if (this.stepFilter) { + this.operatingElements = this.stepFilter.get("ALL"); + } this.getWsProjects(); this.getMaintainerOptions(); this.getApiScenario(); @@ -487,7 +490,7 @@ export default { data.forEach(item => { let plugin = { title: item.name, - show: this.showButton(item.name), + show: this.showButton(item.jmeterClazz), titleColor: "#555855", titleBgColor: "#F4F4FF", icon: "colorize", @@ -495,7 +498,9 @@ export default { this.addComponent(item.name, item) } } - this.buttonData.push(plugin); + if (this.operatingElements && this.operatingElements.includes(item.jmeterClazz)) { + this.buttonData.push(plugin); + } }); } }); @@ -847,18 +852,19 @@ export default { setComponent(type, this, plugin); }, nodeClick(data, node) { - if (data.referenced != 'REF' && data.referenced != 'Deleted' && !data.disabled) { - this.operatingElements = ELEMENTS.get(data.type); + if (data.referenced != 'REF' && data.referenced != 'Deleted' && !data.disabled && this.stepFilter) { + this.operatingElements = this.stepFilter.get(data.type); } else { this.operatingElements = []; } - if (!this.operatingElements) { - this.operatingElements = ELEMENTS.get("ALL"); + if (!this.operatingElements && this.stepFilter) { + this.operatingElements = this.stepFilter.get("ALL"); } this.selectedTreeNode = data; this.selectedNode = node; this.$store.state.selectStep = data; this.buttonData = buttons(this); + this.initPlugins(); }, suggestClick(node) { this.response = {}; @@ -869,7 +875,7 @@ export default { showAll() { // 控制当有弹出页面操作时禁止刷新按钮列表 if (!this.customizeVisible && !this.isBtnHide) { - this.operatingElements = ELEMENTS.get("ALL"); + this.operatingElements = this.stepFilter.get("ALL"); this.selectedTreeNode = undefined; this.$store.state.selectStep = undefined; } @@ -1144,10 +1150,12 @@ export default { this.getEnvironments(); }, allowDrop(draggingNode, dropNode, dropType) { + // 增加插件权限控制 if (dropType != "inner") { return true; } else if (dropType === "inner" && dropNode.data.referenced !== 'REF' && dropNode.data.referenced !== 'Deleted' - && ELEMENTS.get(dropNode.data.type) && ELEMENTS.get(dropNode.data.type).indexOf(draggingNode.data.type) != -1 && !draggingNode.data.disabled) { + && (this.stepFilter.get(dropNode.data.type) && this.stepFilter.get(dropNode.data.type).indexOf(draggingNode.data.type) != -1) + && !draggingNode.data.disabled) { return true; } return false; @@ -1177,7 +1185,7 @@ export default { this.$refs['currentScenario'].validate((valid) => { if (valid) { this.setParameter(); - saveScenario(this.path, this.currentScenario, this.scenarioDefinition, this,(response) => { + saveScenario(this.path, this.currentScenario, this.scenarioDefinition, this, (response) => { this.$success(this.$t('commons.save_success')); this.path = "/api/automation/update"; this.$store.state.pluginFiles = []; diff --git a/frontend/src/business/components/api/automation/scenario/MenuFactory.js b/frontend/src/business/components/api/automation/scenario/MenuFactory.js deleted file mode 100644 index 9dfde7f351..0000000000 --- a/frontend/src/business/components/api/automation/scenario/MenuFactory.js +++ /dev/null @@ -1,28 +0,0 @@ -export const ELEMENTS = new Map([ - ['menu_post_processors', ['HtmlExtractor', 'JMESPathExtractor', 'JSONPostProcessor', 'RegexExtractor', 'BoundaryExtractor', 'JSR223PostProcessor', 'Separator', 'JDBCPostProcessor', 'XPath2Extractor', 'XPathExtractor', 'ResultAction', 'DebugPostProcessor', 'BeanShellPostProcessor']], - ['menu_assertions', ['Assertion', 'JSONPathAssertion', 'SizeAssertion', 'JSR223Assertion', 'XPath2Assertion', 'Separator', 'HTMLAssertion', 'JMESPathAssertion', 'MD5HexAssertion', 'SMIMEAssertion', 'XMLSchemaAssertion', 'XMLAssertion', 'XPathAssertion', 'DurationAssertion', 'CompareAssertion', 'BeanShellAssertion']], - ['menu_listener', ['ViewResultsFullVisualizer', 'SummaryReport', 'StatVisualizer', 'BackendListener', 'Separator', 'JSR223Listener', 'ResultSaver', 'RespTimeGraphVisualizer', 'GraphVisualizer', 'AssertionVisualizer', 'ComparisonVisualizer', 'StatGraphVisualizer', 'Summariser', 'TableVisualizer', 'SimpleDataWriter', 'MailerVisualizer', 'BeanShellListener']], - ['menu_pre_processors', ['JSR223PreProcessor', 'UserParameters', 'Separator', 'AnchorModifier', 'URLRewritingModifier', 'JDBCPreProcessor', 'SampleTimeout', 'RegExUserParameters', 'BeanShellPreProcessor']], - ['menu_logic_controller', ['IfControllerPanel', 'TransactionController', 'LoopControlPanel', 'WhileController', 'Separator', 'ForeachControlPanel', 'IncludeController', 'RunTime', 'CriticalSectionController', 'InterleaveControl', 'OnceOnlyController', 'RecordController', 'LogicController', 'RandomControl', 'RandomOrderController', 'ThroughputController', 'SwitchController', 'ModuleController']], - ['menu_fragments', ['TestFragmentController']], - ['menu_non_test_elements', ['ProxyControl', 'HttpMirrorControl', 'GenerateTree', 'PropertyControl']], - ['menu_generative_controller', ['HttpTestSample', 'TestAction', 'DebugSampler', 'JSR223Sampler', 'Separator', 'AjpSampler', 'AccessLogSampler', 'BeanShellSampler', 'BoltSampler', 'FtpTestSampler', 'GraphQLHTTPSampler', 'JDBCSampler', 'JMSPublisher', 'JMSSampler', 'JMSSubscriber', 'JUnitTestSampler', 'JavaTestSampler', 'LdapExtTestSampler', 'LdapTestSampler', 'SystemSampler', 'SmtpSampler', 'TCPSampler', 'MailReaderSampler']], - ['menu_threads', ['SetupThreadGroup', 'PostThreadGroup', 'ThreadGroup']], - ['menu_timer', ['ConstantTimer', 'UniformRandomTimer', 'PreciseThroughputTimer', 'ConstantThroughputTimer', 'Separator', 'JSR223Timer', 'SyncTimer', 'PoissonRandomTimer', 'GaussianRandomTimer', 'BeanShellTimer']], - ['menu_config_element', ['CSVDataSet', 'HeaderPanel', 'CookiePanel', 'CacheManager', 'HttpDefaults', 'Separator', 'BoltConnectionElement', 'DNSCachePanel', 'FtpConfig', 'AuthPanel', 'DataSourceElement', 'JavaConfig', 'LdapExtConfig', 'LdapConfig', 'TCPConfig', 'KeystoreConfig', 'ArgumentsPanel', 'LoginConfig', 'SimpleConfig', 'CounterConfig', 'RandomVariableConfig']], -]) - -export function getDefaultSamplerMenu() { - let array = []; - array.push(ELEMENTS.get('menu_assertions')); - array.push(ELEMENTS.get('menu_timer')); - array.push(ELEMENTS.get('menu_pre_processors')); - array.push(ELEMENTS.get('menu_post_processors')); - array.push(ELEMENTS.get('menu_config_element')); - array.push(ELEMENTS.get('menu_listener')); - return array; -} - -export function getLogicMenu() { - return ELEMENTS.values(); -} diff --git a/frontend/src/business/components/api/automation/scenario/Setting.js b/frontend/src/business/components/api/automation/scenario/Setting.js index 2ff578f386..a19c99c518 100644 --- a/frontend/src/business/components/api/automation/scenario/Setting.js +++ b/frontend/src/business/components/api/automation/scenario/Setting.js @@ -1,28 +1,32 @@ -export const ELEMENTS = new Map([ - ['ALL', ["Plugin","scenario", "HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "IfController", "TransactionController", "LoopController", "ConstantTimer", "JSR223Processor", "CustomizeReq"]], - ['scenario', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "CASE", "OT_IMPORT", "IfController", "ConstantTimer", "JSR223Processor", "CustomizeReq"]], - ['HTTPSamplerProxy', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract"]], - ['DubboSampler', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract"]], - ['JDBCSampler', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract"]], - ['TCPSampler', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract"]], - ['OT_IMPORT', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract"]], - ['IfController', ["IfController", "LoopController", "TransactionController", "scenario", "HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract", "CustomizeReq"]], - ['TransactionController', ["TransactionController", "scenario", "HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract", "CustomizeReq"]], - ['LoopController', ["IfController", "TransactionController", "scenario", "HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "OT_IMPORT", "ConstantTimer", "JSR223Processor", "JSR223PreProcessor", "JSR223PostProcessor", 'JDBCPreProcessor', 'JDBCPostProcessor', "Assertions", "Extract", "CustomizeReq"]], - ['ConstantTimer', []], - ['JSR223Processor', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "Assertions", "Extract"]], - ['JSR223PreProcessor', []], - ['JSR223PostProcessor', []], - ['JDBCPreProcessor', []], - ['JDBCPostProcessor', []], - ['Assertions', []], - ['Extract', []], - ['JmeterElement', []], - ['CustomizeReq', ["ConstantTimer", "JSR223PreProcessor", "JSR223PostProcessor", "JDBCPostProcessor", "JDBCPreProcessor", "Assertions", "Extract"]], - ['MaxSamplerProxy', ["JSR223PreProcessor", "JSR223PostProcessor", "JDBCPreProcessor", "JDBCPostProcessor", "Assertions", "Extract"]], - ['AllSamplerProxy', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler","Sampler"]], - ['AllCanExecType', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "JSR223Processor"]] -]) +export function STEP() { + let map = new Map([ + ['ALL', init()], + ['scenario', init()], + ['HTTPSamplerProxy', getDefaultSamplerMenu()], + ['DubboSampler', getDefaultSamplerMenu()], + ['JDBCSampler', getDefaultSamplerMenu()], + ['TCPSampler', getDefaultSamplerMenu()], + ['OT_IMPORT', getDefaultSamplerMenu()], + ['AbstractSampler', getDefaultSamplerMenu()], + ['IfController', getAll()], + ['TransactionController', getAll()], + ['LoopController', getAll()], + ['ConstantTimer', []], + ['JSR223Processor', getDefaultSamplerMenu()], + ['JSR223PreProcessor', []], + ['JSR223PostProcessor', []], + ['JDBCPreProcessor', []], + ['JDBCPostProcessor', []], + ['Assertions', []], + ['Extract', []], + ['JmeterElement', []], + ['CustomizeReq', getDefaultSamplerMenu()], + ['MaxSamplerProxy', getDefaultSamplerMenu()], + ['GenericController', getAll()], + ['AllSamplerProxy', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "Sampler", "AbstractSampler"]], + ['AllCanExecType', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "JSR223Processor", "AbstractSampler"]]]); + return map +} export const ELEMENT_TYPE = { scenario: "scenario", @@ -67,3 +71,46 @@ export const TYPE_TO_C = new Map([ ['DebugSampler', "io.metersphere.api.dto.definition.request.sampler.MsDebugSampler"], ]) + +export const PLUGIN_ELEMENTS = new Map([ + ['menu_post_processors', ['HtmlExtractor', 'JMESPathExtractor', 'JSONPostProcessor', 'RegexExtractor', 'BoundaryExtractor', 'JSR223PostProcessor', 'Separator', 'JDBCPostProcessor', 'XPath2Extractor', 'XPathExtractor', 'ResultAction', 'DebugPostProcessor', 'BeanShellPostProcessor']], + ['menu_assertions', ["Assertions", "Extract", 'Assertion', 'JSONPathAssertion', 'SizeAssertion', 'JSR223Assertion', 'XPath2Assertion', 'Separator', 'HTMLAssertion', 'JMESPathAssertion', 'MD5HexAssertion', 'SMIMEAssertion', 'XMLSchemaAssertion', 'XMLAssertion', 'XPathAssertion', 'DurationAssertion', 'CompareAssertion', 'BeanShellAssertion']], + ['menu_listener', ['AbstractVisualizer', 'AbstractListener', 'ViewResultsFullVisualizer', 'SummaryReport', 'StatVisualizer', 'BackendListener', 'Separator', 'JSR223Listener', 'ResultSaver', 'RespTimeGraphVisualizer', 'GraphVisualizer', 'AssertionVisualizer', 'ComparisonVisualizer', 'StatGraphVisualizer', 'Summariser', 'TableVisualizer', 'SimpleDataWriter', 'MailerVisualizer', 'BeanShellListener']], + ['menu_pre_processors', ['AbstractPostProcessor', 'JSR223PreProcessor', 'UserParameters', 'Separator', 'AnchorModifier', 'URLRewritingModifier', 'JDBCPreProcessor', 'SampleTimeout', 'RegExUserParameters', 'BeanShellPreProcessor']], + ['menu_logic_controller', ['GenericController', "IfController", "LoopController", 'IfControllerPanel', 'TransactionController', 'LoopControlPanel', 'WhileController', 'Separator', 'ForeachControlPanel', 'IncludeController', 'RunTime', 'CriticalSectionController', 'InterleaveControl', 'OnceOnlyController', 'RecordController', 'LogicController', 'RandomControl', 'RandomOrderController', 'ThroughputController', 'SwitchController', 'ModuleController']], + ['menu_fragments', ['TestFragmentController']], + ['menu_non_test_elements', ['ProxyControl', 'HttpMirrorControl', 'GenerateTree', 'PropertyControl']], + ['menu_generative_controller', ['AbstractSampler', 'CustomizeReq', 'HttpTestSample', 'TestAction', 'DebugSampler', 'JSR223Sampler', 'Separator', 'AjpSampler', 'AccessLogSampler', 'BeanShellSampler', 'BoltSampler', 'FtpTestSampler', 'GraphQLHTTPSampler', 'JDBCSampler', 'JMSPublisher', 'JMSSampler', 'JMSSubscriber', 'JUnitTestSampler', 'JavaTestSampler', 'LdapExtTestSampler', 'LdapTestSampler', 'SystemSampler', 'SmtpSampler', 'TCPSampler', 'MailReaderSampler']], + ['menu_threads', ['SetupThreadGroup', 'PostThreadGroup', 'ThreadGroup']], + ['menu_timer', ['ConstantTimer', 'UniformRandomTimer', 'PreciseThroughputTimer', 'ConstantThroughputTimer', 'Separator', 'JSR223Timer', 'SyncTimer', 'PoissonRandomTimer', 'GaussianRandomTimer', 'BeanShellTimer']], + ['menu_config_element', ['CSVDataSet', 'HeaderPanel', 'CookiePanel', 'CacheManager', 'HttpDefaults', 'Separator', 'BoltConnectionElement', 'DNSCachePanel', 'FtpConfig', 'AuthPanel', 'DataSourceElement', 'JavaConfig', 'LdapExtConfig', 'LdapConfig', 'TCPConfig', 'KeystoreConfig', 'ArgumentsPanel', 'LoginConfig', 'SimpleConfig', 'CounterConfig', 'RandomVariableConfig']], +]) + +export function getDefaultSamplerMenu() { + let array = []; + array = array.concat(PLUGIN_ELEMENTS.get('menu_assertions')); + array = array.concat(PLUGIN_ELEMENTS.get('menu_timer')); + array = array.concat(PLUGIN_ELEMENTS.get('menu_pre_processors')); + array = array.concat(PLUGIN_ELEMENTS.get('menu_post_processors')); + array = array.concat(PLUGIN_ELEMENTS.get('menu_config_element')); + array = array.concat(PLUGIN_ELEMENTS.get('menu_listener')); + return array; +} + +export function init() { + let allArray = []; + allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_generative_controller')); + allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_logic_controller')); + allArray = allArray.concat(["scenario", "ConstantTimer", "JSR223Processor"]); + return allArray; +} + +export function getAll() { + let allArray = []; + allArray = allArray.concat(getDefaultSamplerMenu()); + allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_logic_controller')); + allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_non_test_elements')); + allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_generative_controller')); + allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_threads')); + return allArray; +} diff --git a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue index de57ec8209..b1cebd82ff 100644 --- a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue @@ -64,7 +64,7 @@