in src/routes/Plugin/Discovery/UpstreamTable.js [127:175]
title: getIntlContent("SHENYU.DISCOVERY.SELECTOR.UPSTREAM.OPERATION"),
dataIndex: 'operation',
align: 'center',
render: (text, record) =>
this.props.dataSource.length >= 1 ? (
<Popconfirm title={getIntlContent("SHENYU.DISCOVERY.SELECTOR.UPSTREAM.DELETE")} onConfirm={() => this.handleDelete(record.key)}>
<a>{getIntlContent("SHENYU.BUTTON.SYSTEM.DELETE")}</a>
</Popconfirm>
) : null,
},
];
}
handleDelete = key => {
const { dataSource } = this.props;
const newData = dataSource.filter(item => item.key !== key);
this.props.onTableChange(newData);
};
handleAdd = () => {
const { dataSource, recordCount} = this.props;
const newRecordCount = recordCount + 1;
const newData = {
key: newRecordCount,
protocol: 'protocol',
url: 'url',
status: '0',
weight: '0',
};
this.props.onTableChange([...dataSource, newData]);
this.props.onCountChange(newRecordCount);
};
handleSave = row => {
const newData = [...this.props.dataSource];
const index = newData.findIndex(item => row.key === item.key);
const item = newData[index];
newData.splice(index, 1, {
...item,
...row,
});
this.props.onTableChange(newData);
};
render() {
const { dataSource } = this.props;
const components = {
body: {