Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/routes/Plugin/Common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export default class Common extends Component {
startupTime: item.startupTime,
props: JSON.stringify({
warmupTime: item.warmupTime,
gray: `${item.gray}`,
}),
namespaceId: currentNamespaceId,
}));
Expand Down Expand Up @@ -482,6 +483,7 @@ export default class Common extends Component {
weight: item.weight,
props: JSON.stringify({
warmupTime: item.warmupTime,
gray: `${item.gray}`,
}),
discoveryHandlerId,
namespaceId: currentNamespaceId,
Expand Down Expand Up @@ -543,9 +545,15 @@ export default class Common extends Component {
if (item.props === null) {
propsObj = {
warmupTime: 10,
gray: "false",
};
}
return { ...item, key: item.id, warmupTime: propsObj.warmupTime };
return {
...item,
key: item.id,
warmupTime: propsObj.warmupTime,
gray: propsObj.gray,
};
});
}
let discoveryHandlerId = selector.discoveryHandler
Expand Down
72 changes: 63 additions & 9 deletions src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
InputNumber,
Popconfirm,
Select,
Switch,
Table,
} from "antd";
import { getIntlContent } from "../../../utils/IntlUtils";
Expand All @@ -43,6 +44,8 @@ class EditableCell extends Component {
<Option value="1">close</Option>
</Select>
);
} else if (this.props.inputType === "switch") {
return <Switch />;
}
return <Input />;
};
Expand All @@ -62,15 +65,26 @@ class EditableCell extends Component {
<td {...restProps}>
{editing ? (
<Form.Item style={{ margin: 0 }}>
{getFieldDecorator(dataIndex, {
rules: [
{
required: true,
message: `Please Input ${title}!`,
},
],
initialValue: record[dataIndex],
})(this.getInput())}
{dataIndex === "gray"
? getFieldDecorator(dataIndex, {
rules: [
{
required: true,
message: `Please Input ${title}!`,
},
],
valuePropName: "checked",
initialValue: record[dataIndex],
})(this.getInput())
: getFieldDecorator(dataIndex, {
rules: [
{
required: true,
message: `Please Input ${title}!`,
},
],
initialValue: record[dataIndex],
})(this.getInput())}
</Form.Item>
) : (
children
Expand Down Expand Up @@ -136,6 +150,24 @@ class EditableTable extends Component {
editable: true,
align: "center",
},
{
title: "gray",
dataIndex: "gray",
editable: true,
align: "center",
render: (text, record) => {
return (
<Switch
disabled={record.status === 1}
checked={record.gray === "true" || record.gray === true}
onChange={(v) => {
record.gray = v;
this.saveGray(record, record.key);
}}
/>
);
},
},
{
title: getIntlContent("SHENYU.DISCOVERY.SELECTOR.UPSTREAM.OPERATION"),
dataIndex: "operation",
Expand Down Expand Up @@ -228,6 +260,7 @@ class EditableTable extends Component {
weight: 50,
startupTime: 0,
warmupTime: 10,
gray: false,
};
this.props.onTableChange([...dataSource, newData]);
this.props.onCountChange(newRecordCount);
Expand Down Expand Up @@ -259,6 +292,25 @@ class EditableTable extends Component {
});
}

saveGray(row, key) {
const newData = [...this.props.dataSource];
const index = newData.findIndex((item) => key === item.key);
if (index > -1) {
const item = newData[index];
newData.splice(index, 1, {
...item,
...row,
});
this.props.onTableChange(newData);
} else {
const { recordCount } = this.props;
row.key = recordCount + 1;
newData.push(row);
this.props.onCountChange(recordCount + 1);
this.props.onTableChange(newData);
}
}

edit(key) {
this.setState({ editingKey: key });
}
Expand All @@ -284,6 +336,8 @@ class EditableTable extends Component {
inputType = "number";
} else if (col.dataIndex === "status") {
inputType = "dropdown";
} else if (col.dataIndex === "gray") {
inputType = "switch";
}
return {
...col,
Expand Down
10 changes: 9 additions & 1 deletion src/routes/Plugin/Discovery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ export default class DiscoveryProxy extends Component {
startupTime: item.startupTime,
props: JSON.stringify({
warmupTime: item.warmupTime,
gray: `${item.gray}`,
}),
}));
dispatch({
Expand Down Expand Up @@ -406,9 +407,15 @@ export default class DiscoveryProxy extends Component {
if (item.props === null) {
propsObj = {
warmupTime: 10,
gray: "false",
};
}
return { ...item, key: item.id, warmupTime: propsObj.warmupTime };
return {
...item,
key: item.id,
warmupTime: propsObj.warmupTime,
gray: propsObj.gray,
};
});
this.setState({
popup: (
Expand Down Expand Up @@ -441,6 +448,7 @@ export default class DiscoveryProxy extends Component {
startupTime: item.startupTime,
props: JSON.stringify({
warmupTime: item.warmupTime,
gray: `${item.gray}`,
}),
}));
dispatch({
Expand Down
Loading