Skip to content
Closed
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
5 changes: 4 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 @@
startupTime: item.startupTime,
props: JSON.stringify({
warmupTime: item.warmupTime,
gray: item.gray + "",

Check failure on line 434 in src/routes/Plugin/Common/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected string concatenation

Check failure on line 434 in src/routes/Plugin/Common/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected string concatenation
}),
namespaceId: currentNamespaceId,
}));
Expand Down Expand Up @@ -482,6 +483,7 @@
weight: item.weight,
props: JSON.stringify({
warmupTime: item.warmupTime,
gray: item.gray + "",

Check failure on line 486 in src/routes/Plugin/Common/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected string concatenation

Check failure on line 486 in src/routes/Plugin/Common/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected string concatenation
}),
discoveryHandlerId,
namespaceId: currentNamespaceId,
Expand Down Expand Up @@ -543,9 +545,10 @@
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 };

Check failure on line 551 in src/routes/Plugin/Common/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `·...item,·key:·item.id,·warmupTime:·propsObj.warmupTime,·gray:·propsObj.gray` with `⏎················...item,⏎················key:·item.id,⏎················warmupTime:·propsObj.warmupTime,⏎················gray:·propsObj.gray,⏎·············`

Check failure on line 551 in src/routes/Plugin/Common/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `·...item,·key:·item.id,·warmupTime:·propsObj.warmupTime,·gray:·propsObj.gray` with `⏎················...item,⏎················key:·item.id,⏎················warmupTime:·propsObj.warmupTime,⏎················gray:·propsObj.gray,⏎·············`
});
}
let discoveryHandlerId = selector.discoveryHandler
Expand Down
71 changes: 62 additions & 9 deletions src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Popconfirm,
Select,
Table,
Switch,
} from "antd";
import { getIntlContent } from "../../../utils/IntlUtils";

Expand All @@ -43,6 +44,8 @@
<Option value="1">close</Option>
</Select>
);
} else if (this.props.inputType === "switch") {
return <Switch />;
}
return <Input />;
};
Expand All @@ -62,15 +65,26 @@
<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: [

Check failure on line 70 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`

Check failure on line 70 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
{

Check failure on line 71 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`

Check failure on line 71 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
required: true,

Check failure on line 72 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `····················` with `······················`

Check failure on line 72 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `····················` with `······················`
message: `Please Input ${title}!`,

Check failure on line 73 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`

Check failure on line 73 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
},

Check failure on line 74 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `··················` with `····················`

Check failure on line 74 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `··················` with `····················`
],

Check failure on line 75 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`

Check failure on line 75 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `··`
valuePropName: "checked",

Check failure on line 76 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `················` with `··················`

Check failure on line 76 in src/routes/Plugin/Discovery/DiscoveryUpstreamTable.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `················` with `··················`
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,23 @@
editable: true,
align: "center",
},
{
title: "gray",
dataIndex: "gray",
editable: true,
align: "center",
render: (text, record) => {
return (
<Switch
checked={Boolean(record.gray)}
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 +259,7 @@
weight: 50,
startupTime: 0,
warmupTime: 10,
gray: false,
};
this.props.onTableChange([...dataSource, newData]);
this.props.onCountChange(newRecordCount);
Expand Down Expand Up @@ -259,6 +291,25 @@
});
}

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 +335,8 @@
inputType = "number";
} else if (col.dataIndex === "status") {
inputType = "dropdown";
} else if (col.dataIndex === "gray") {
inputType = "switch";
}
return {
...col,
Expand Down
5 changes: 4 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,10 @@ 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 +443,7 @@ export default class DiscoveryProxy extends Component {
startupTime: item.startupTime,
props: JSON.stringify({
warmupTime: item.warmupTime,
gray: item.gray + "",
}),
}));
dispatch({
Expand Down
Loading