Skip to content

Commit

Permalink
improvements for leave node api and UI (alibaba#10748)
Browse files Browse the repository at this point in the history
  • Loading branch information
maoling authored and wukong121 committed Aug 3, 2023
1 parent 6dc94c4 commit 31f0f86
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
3 changes: 3 additions & 0 deletions console-ui/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ const I18N_CONF = {
extendInfo: 'NodeMetaData',
operation: 'Operation',
leave: 'Leave',
leaveSucc: 'Leave successfully',
leaveFail: 'Leave failed',
leavePrompt: 'prompt',
confirm: 'Confirm',
confirmTxt: 'Confirm that you want to go offline this cluster node?',
},
Expand Down
3 changes: 3 additions & 0 deletions console-ui/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ const I18N_CONF = {
extendInfo: '节点元数据',
operation: '操作',
leave: '下线',
leaveSucc: '下线成功',
leaveFail: '下线失败',
leavePrompt: '提示',
confirm: '确认',
confirmTxt: '确认要下线此集群节点?',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
Table,
Dialog,
ConfigProvider,
Message,
} from '@alifd/next';
import { request } from '../../../globalLib';
import RegionGroup from '../../../components/RegionGroup';
Expand Down Expand Up @@ -105,19 +106,38 @@ class ClusterNodeList extends React.Component {
}

leave(nodes) {
const { locale = {} } = this.props;
const accessToken = JSON.parse(localStorage.token || '{}').accessToken;
this.openLoading();
axios
.post('v1/core/cluster/server/leave', nodes)
.then(() => {
.post(`v1/core/cluster/server/leave?accessToken=${accessToken}`, nodes)
.then(response => {
if (response.data.code === 200) {
Message.success(locale.leaveSucc);
} else {
const errorMessage = response.data.message || locale.leaveFail;
this.showErrorDialog(locale.leavePrompt, errorMessage);
}

this.queryClusterStateList();
this.closeLoading();
})
.catch(() => {
.catch(error => {
const errorMessage = error.response?.data?.message || locale.leaveFail;
this.showErrorDialog(locale.leavePrompt, errorMessage);

this.queryClusterStateList();
this.closeLoading();
});
}

showErrorDialog(title, content) {
Dialog.alert({
title,
content,
});
}

showLeaveDialog(value) {
const { locale = {} } = this.props;
Dialog.confirm({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public RestResult<String> switchLookup(@RequestParam(name = "type") String type)
@Secured(resource = Commons.NACOS_CORE_CONTEXT + "/cluster", action = ActionTypes.WRITE, signType = SignType.CONSOLE)
public RestResult<String> leave(@RequestBody Collection<String> params,
@RequestParam(defaultValue = "true") Boolean notifyOtherMembers) throws Exception {
return RestResultUtils.failed(405, "/v1/core/cluster/server/leave API not allow to use temporarily.");
return RestResultUtils.failed(405, null, "/v1/core/cluster/server/leave API not allow to use temporarily.");
}

}

0 comments on commit 31f0f86

Please sign in to comment.