This is an automated email from the ASF dual-hosted git repository.
dengliming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 81bd24a3 code optimization (#458)
81bd24a3 is described below
commit 81bd24a309279a4387ea6f1183bfe224240c8301
Author: Kerwin Bryant <[email protected]>
AuthorDate: Tue May 28 12:40:12 2024 +0800
code optimization (#458)
---
src/routes/Plugin/Common/Selector.js | 11 +++++++----
src/routes/Plugin/Common/index.js | 11 +++++++++--
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/routes/Plugin/Common/Selector.js
b/src/routes/Plugin/Common/Selector.js
index 62d1ea76..309e73c1 100644
--- a/src/routes/Plugin/Common/Selector.js
+++ b/src/routes/Plugin/Common/Selector.js
@@ -63,6 +63,10 @@ const formCheckLayout = {
labelCol: { sm: { span: 18 } },
wrapperCol: { sm: { span: 4 } },
};
+const isDivideUpstreamsRequiresForPlugin = (pluginId) => {
+ // 8: springCloud
+ return ["8"].includes(pluginId);
+};
let id = 0;
@@ -95,7 +99,7 @@ class AddModal extends Component {
discoveryConfig = {},
} = this.props;
- if (pluginId === "8") {
+ if (isDivideUpstreamsRequiresForPlugin(pluginId)) {
id = divideUpstreams.length;
}
@@ -219,7 +223,7 @@ class AddModal extends Component {
pluginHandleList.forEach((handleList, index) => {
handle[index] = {};
handleList.forEach((item) => {
- if (pluginId === "8") {
+ if (isDivideUpstreamsRequiresForPlugin(pluginId)) {
const { keys, divideUpstreams } = values;
const data = {
[item.field]: values[item.field],
@@ -471,8 +475,7 @@ class AddModal extends Component {
return;
}
- // plugin - springCloud
- if (pluginId === "8") {
+ if (isDivideUpstreamsRequiresForPlugin(pluginId)) {
getFieldDecorator("keys", {
initialValue: Array.from({
length: divideUpstreams.length,
diff --git a/src/routes/Plugin/Common/index.js
b/src/routes/Plugin/Common/index.js
index d17997a7..223bfafd 100755
--- a/src/routes/Plugin/Common/index.js
+++ b/src/routes/Plugin/Common/index.js
@@ -190,6 +190,13 @@ export default class Common extends Component {
this.getAllSelectors(selectorPage, selectorPageSize, plugins);
};
+ isDiscovery = (pluginId) => {
+ // 5: divide
+ // 15: grpc
+ // 26: websocket
+ return ["5", "15", "26"].includes(pluginId);
+ };
+
addSelector = () => {
const { selectorPage, selectorPageSize } = this.state;
const { dispatch, plugins } = this.props;
@@ -198,7 +205,7 @@ export default class Common extends Component {
const { id: pluginId, config } = plugin;
const multiSelectorHandle =
this.getPluginConfigField(config, "multiSelectorHandle") === "1";
- const isDiscovery = ["5", "15", "26"].includes(pluginId);
+ const isDiscovery = this.isDiscovery(pluginId);
if (isDiscovery) {
let discoveryConfig = {
discoveryType: "",
@@ -435,7 +442,7 @@ export default class Common extends Component {
const { id: pluginId, config } = plugin;
const multiSelectorHandle =
this.getPluginConfigField(config, "multiSelectorHandle") === "1";
- const isDiscovery = ["5", "15", "26"].includes(pluginId);
+ const isDiscovery = this.isDiscovery(pluginId);
const { id } = record;
dispatch({
type: "common/fetchSeItem",