Skip to content

Commit

Permalink
Merge pull request #405 from fengyangsy/issue-#404
Browse files Browse the repository at this point in the history
[#issue-404]Add delete network function
  • Loading branch information
fengyangsy authored Feb 15, 2022
2 parents d8328b2 + 1929a90 commit 9e06f7d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/dashboard/src/locales/en-US/operatorNetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export default {
'app.operator.network.table.header.creationTime': 'Creation Time',
'app.operator.network.table.header.type': 'Type',
'app.operator.network.new': 'New Network',
'app.operator.network.delete.fail': 'Delete Network {name} failed',
'app.operator.network.delete.success': 'Delete Network {name} success',
'app.operator.network.delete.fail': 'Delete Network failed.',
'app.operator.network.delete.success': 'Delete Network success.',
'app.operator.network.form.delete.title': 'Delete Network',
'app.operator.network.form.delete.content': 'Confirm to delete network {name}',
'app.operator.network.form.delete.content': 'Confirm to delete network {name}?',
'app.operator.network.table.header.version': 'Fabric version',
'app.operator.newNetwork.title': 'New Network',
'app.operator.newNetwork.label.name': 'Network Name',
Expand Down
6 changes: 3 additions & 3 deletions src/dashboard/src/locales/zh-CN/operatorNetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export default {
'app.operator.network.table.header.creationTime': '创建时间',
'app.operator.network.table.header.type': '类型',
'app.operator.network.new': '新建网络',
'app.operator.network.delete.fail': '删除网络 {name} 失败',
'app.operator.network.delete.success': '删除组织 {name} 成功',
'app.operator.network.delete.fail': '删除网络失败。',
'app.operator.network.delete.success': '删除组织成功。',
'app.operator.network.form.delete.title': '删除网络',
'app.operator.network.form.delete.content': '确认删除网络 {name}',
'app.operator.network.form.delete.content': '确认删除网络 {name}?',
'app.operator.network.table.header.version': '版本',
'app.operator.newNetwork.title': '新建网络',
'app.operator.newNetwork.label.name': '网络名称',
Expand Down
68 changes: 62 additions & 6 deletions src/dashboard/src/pages/Operator/Network/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ class Network extends PureComponent {
}

componentWillUnmount() {
const { dispatch } = this.props;

dispatch({
type: 'network/clear',
});
this.queryNetworkList();
}

handleTableChange = pagination => {
Expand All @@ -55,6 +51,66 @@ class Network extends PureComponent {
history.push('/operator/network/newNetwork');
};

queryNetworkList = () => {
const { dispatch } = this.props;

dispatch({
type: 'network/listNetwork',
});
};

handleDeleteNetwork = row => {
const { dispatch, intl } = this.props;
const { deleteCallBack } = this;
const { id } = row;

Modal.confirm({
title: intl.formatMessage({
id: 'app.operator.network.form.delete.title',
defaultMessage: 'Delete Network',
}),
content: intl.formatMessage(
{
id: 'app.operator.network.form.delete.content',
defaultMessage: 'Confirm to delete network {name}?',
},
{
name: row.name,
}
),
okText: intl.formatMessage({ id: 'form.button.confirm', defaultMessage: 'Confirm' }),
cancelText: intl.formatMessage({ id: 'form.button.cancel', defaultMessage: 'Cancel' }),
onOk() {
dispatch({
type: 'network/deleteNetwork',
payload: id,
callback: deleteCallBack,
});
},
});
};

deleteCallBack = response => {
const { intl } = this.props;
if (response.status === 'successful') {
message.success(
intl.formatMessage({
id: 'app.operator.network.delete.success',
defaultMessage: 'Delete Network success.',
})
);
this.queryNetworkList();
}
else {
message.error(
intl.formatMessage({
id: 'app.operator.network.delete.fail',
defaultMessage: 'Delete Network failed.',
})
);
}
};

render() {
const { selectedRows } = this.state;
const {
Expand Down Expand Up @@ -89,7 +145,7 @@ class Network extends PureComponent {
{intl.formatMessage({ id: 'form.menu.item.update', defaultMessage: 'Update' })}
</a>
<Divider type="vertical" />
<a className={styles.danger}>
<a className={styles.danger} onClick={() => this.handleDeleteNetwork(record)}>
{intl.formatMessage({ id: 'form.menu.item.delete', defaultMessage: 'Delete' })}
</a>
</Fragment>
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/src/pages/Operator/models/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
}
},
*deleteNetwork({ payload, callback }, { call }) {
const response = yield call(deleteNetwork, payload.id);
const response = yield call(deleteNetwork, payload);
if (callback) {
callback({
payload,
Expand Down

0 comments on commit 9e06f7d

Please sign in to comment.