Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for leave api and UI #10748

Merged
merged 2 commits into from
Jul 10, 2023
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
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.");
}

}