in src/routes/Plugin/Common/Selector.js [228:366]
sort: Number(values.sort),
selectorConditions
});
}
}
});
};
handleAdd = () => {
let { selectorConditions } = this.state;
selectorConditions.push({
paramType: "uri",
operator: "pathPattern",
paramName: "/",
paramValue: ""
});
this.setState({ selectorConditions }, () => {
let len = selectorConditions.length || 0;
let key = `paramTypeValueEn${len - 1}`;
this.setState({ [key]: true });
});
};
handleDelete = index => {
let { selectorConditions } = this.state;
if (selectorConditions && selectorConditions.length > 1) {
selectorConditions.splice(index, 1);
} else {
message.destroy();
message.error("At least one condition");
}
this.setState({ selectorConditions });
};
handleAddHandle = () => {
let { pluginHandleList } = this.state;
let pluginHandle = pluginHandleList[0];
let toAddPluginHandle = pluginHandle.map(e => {
return { ...e, value: null };
});
pluginHandleList.push(toAddPluginHandle);
this.setState({
pluginHandleList
});
};
handleDeleteHandle = index => {
let { pluginHandleList } = this.state;
if (pluginHandleList.length === 1) {
message.destroy();
message.error(getIntlContent("SHENYU.PLUGIN.HANDLE.TIP"));
} else {
pluginHandleList.splice(index, 1);
this.setState({ pluginHandleList });
}
};
conditionChange = (index, name, value) => {
let { selectorConditions } = this.state;
selectorConditions[index][name] = value;
if (name === "paramType") {
let key = `paramTypeValueEn${index}`;
if (value === "uri" || value === "host" || value === "ip" || value === "req_method" || value === "domain") {
this.setState({ [key]: true });
selectorConditions[index].paramName = "/";
} else {
this.setState({ [key]: false });
}
if (value === "post") {
selectorConditions[index].paramName = "filedName";
}
if (value === "query") {
selectorConditions[index].paramName = "paramName";
}
if (value === "header") {
selectorConditions[index].paramName = "headerName";
}
if (value === "cookie") {
selectorConditions[index].paramName = "cookieName";
}
if (value === "uri") {
selectorConditions[index].operator = "pathPattern";
}
else if (value === "req_method") {
selectorConditions[index].operator = "=";
}
else {
selectorConditions[index].operator = "";
}
}
this.setState({ selectorConditions });
};
getSelectValue = value => {
this.setState({
selectValue: value
});
};
renderPluginHandler = () => {
const { pluginHandleList, divideUpstreams, gray, serviceId } = this.state;
const {
form: { getFieldDecorator, getFieldValue, setFieldsValue },
multiSelectorHandle,
pluginId
} = this.props;
const labelWidth = 75;
if (pluginId === "8") {
getFieldDecorator("keys", {
initialValue: Array.from({
length: divideUpstreams.length
}).map((_, i) => i)
});
const keys = getFieldValue("keys");
const Rule = keys.map((key, index) => (
<Item
required
key={key}
{...(index === 0
? { labelCol: { span: 4 }, wrapperCol: { span: 20 } }
: { wrapperCol: { span: 20, offset: 4 } })}
label={index === 0 ? "divideUpstreams" : ""}
>
<Card>
<div style={{ display: "flex", alignItems: "center" }}>
<div>
<Row gutter={30}>
<Col span={10}>
<Item label="protocol" {...{labelCol: { span: 8 }, wrapperCol: { span: 10 }}}>
{getFieldDecorator(`divideUpstreams[${key}].protocol`, {
initialValue: divideUpstreams[key]
? divideUpstreams[key].protocol
: "",
rules: [
{