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

feature: migrate the console to the naming server #7157

Merged
merged 19 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] support fury undolog parser
- [[#7069](https://github.com/apache/incubator-seata/pull/7069)] Raft cluster mode supports address translation
- [[#7038](https://github.com/apache/incubator-seata/pull/7038)] support fury serializer
- [[#7157](https://github.com/apache/incubator-seata/pull/7157)] migrate the console to the naming server

### bugfix:

Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] 支持UndoLog的fury序列化方式
- [[#7069](https://github.com/apache/incubator-seata/pull/7069)] Raft集群模式支持地址转换
- [[#7038](https://github.com/apache/incubator-seata/pull/7038)] 支持Fury序列化器
- [[#7157](https://github.com/apache/incubator-seata/pull/7157)] 将console迁移至namingserver中

### bugfix:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const enUs: ILocale = {
subTitle: 'list',
createTimeLabel: 'CreateTime',
selectFilerPlaceholder: 'Please select filter criteria',
selectNamespaceFilerPlaceholder: 'Please select namespace',
selectClusterFilerPlaceholder: 'Please select cluster',
selectVGroupFilerPlaceholder: 'Please select vgroup',
inputFilterPlaceholder: 'Please enter filter criteria',
branchSessionSwitchLabel: 'Whether to include branch sessions',
resetButtonLabel: 'Reset',
Expand All @@ -77,6 +80,9 @@ const enUs: ILocale = {
subTitle: 'list',
createTimeLabel: 'CreateTime',
inputFilterPlaceholder: 'Please enter filter criteria',
selectNamespaceFilerPlaceholder: 'Please select namespace',
selectClusterFilerPlaceholder: 'Please select cluster',
selectVGroupFilerPlaceholder: 'Please select vgroup',
resetButtonLabel: 'Reset',
searchButtonLabel: 'Search',
operateTitle: 'operate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const zhCn: ILocale = {
subTitle: '基础列表页',
createTimeLabel: '创建时间',
selectFilerPlaceholder: '请选择筛选条件',
selectNamespaceFilerPlaceholder: '请选择命名空间',
selectClusterFilerPlaceholder: '请选择集群',
selectVGroupFilerPlaceholder: '请选择事务分组',
inputFilterPlaceholder: '请输入筛选条件',
branchSessionSwitchLabel: '是否包含分支事务',
resetButtonLabel: '重置',
Expand All @@ -77,6 +80,9 @@ const zhCn: ILocale = {
subTitle: '基础列表页',
createTimeLabel: '创建时间',
inputFilterPlaceholder: '请输入筛选条件',
selectNamespaceFilerPlaceholder: '请选择命名空间',
selectClusterFilerPlaceholder: '请选择集群',
selectVGroupFilerPlaceholder: '请选择事务分组',
resetButtonLabel: '重置',
searchButtonLabel: '搜索',
operateTitle: '操作',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@
* limitations under the License.
*/
import React from 'react';
import { ConfigProvider, Table, Button, DatePicker, Form, Icon, Pagination, Input, Dialog, Message } from '@alicloud/console-components';
import {
ConfigProvider,
Table,
Button,
DatePicker,
Form,
Icon,
Pagination,
Input,
Dialog,
Message,
Select
} from '@alicloud/console-components';
import Actions, { LinkButton } from '@alicloud/console-components-actions';
import { withRouter } from 'react-router-dom';
import Page from '@/components/Page';
Expand All @@ -28,13 +40,17 @@ import moment from 'moment';
import './index.scss';
import {get} from "lodash";
import {enUsKey, getCurrentLanguage} from "@/reducers/locale";
import {fetchNamespace} from "@/service/transactionInfo";

const { RangePicker } = DatePicker;
const FormItem = Form.Item;

type GlobalLockInfoState = {
list: Array<any>;
total: number;
namespaceOptions: Map<string, { clusters: string[], vgroups: string[] }>;
clusters: Array<string>;
vgroups: Array<string>;
loading: boolean;
globalLockParam: GlobalLockParam;
}
Expand All @@ -55,28 +71,66 @@ class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
pageSize: 10,
pageNum: 1,
},
namespaceOptions: new Map<string, { clusters: string[], vgroups: string[] }>(),
clusters: [],
vgroups: [],
}

componentDidMount = () => {
// @ts-ignore
const { query } = this.props.history.location;
if (query !== undefined) {
const { xid } = query;
if (xid !== undefined) {
const { xid,vgroup ,namespace,cluster} = query;
if (xid !== undefined && vgroup !== undefined) {
this.setState({
globalLockParam: {
xid,
vgroup,
namespace,
cluster,
pageSize: 10,
pageNum: 1,
},
}, () => this.search());
return;
}
}
// search once by default anyway
this.search();
this.loadNamespaces();
}
loadNamespaces = async () => {
try {
const namespaces = await fetchNamespace();
const namespaceOptions = new Map<string, { clusters: string[], vgroups: string[] }>();
Object.keys(namespaces).forEach(namespaceKey => {
const namespaceData = namespaces[namespaceKey];
namespaceOptions.set(namespaceKey, {
clusters: namespaceData.clusters,
vgroups: namespaceData.vgroups,
});
});
if (namespaceOptions.size > 0) {
// Set default namespace to the first option
const firstNamespace = Array.from(namespaceOptions.keys())[0];
const selectedNamespace = namespaceOptions.get(firstNamespace);
this.setState({
namespaceOptions,
globalLockParam: {
...this.state.globalLockParam,
namespace: firstNamespace,
cluster: selectedNamespace ? selectedNamespace.clusters[0] : undefined,
},
clusters: selectedNamespace ? selectedNamespace.clusters : [],
});
this.search();
} else {
this.setState({
namespaceOptions,
});
}
} catch (error) {
console.error('Failed to fetch namespaces:', error);
}
}

resetSearchFilter = () => {
this.setState({
globalLockParam: {
Expand Down Expand Up @@ -128,10 +182,19 @@ class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
}

searchFilterOnChange = (key:string, val:string) => {
this.setState({
globalLockParam: Object.assign(this.state.globalLockParam,
{ [key]: val }),
});
if (key === 'namespace') {
const selectedNamespace = this.state.namespaceOptions.get(val);
this.setState({
clusters: selectedNamespace ? selectedNamespace.clusters : [],
vgroups: selectedNamespace ? selectedNamespace.vgroups : [],
globalLockParam: Object.assign(this.state.globalLockParam, {[key]: val}),
});
} else {
this.setState({
globalLockParam: Object.assign(this.state.globalLockParam,
{[key]: val}),
});
}
}

paginationOnChange = (current: number, e: {}) => {
Expand Down Expand Up @@ -194,6 +257,9 @@ class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
const { locale = {} } = this.props;
const { title, subTitle, createTimeLabel,
inputFilterPlaceholder,
selectNamespaceFilerPlaceholder,
selectClusterFilerPlaceholder,
selectVGroupFilerPlaceholder,
searchButtonLabel,
resetButtonLabel,
operateTitle,
Expand Down Expand Up @@ -248,7 +314,38 @@ class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
onChange={(value: string) => { this.searchFilterOnChange('branchId', value); }}
/>
</FormItem>

<FormItem name="namespace" label="namespace">
<Select
hasClear
placeholder={selectNamespaceFilerPlaceholder}
onChange={(value: string) => {
this.searchFilterOnChange('namespace', value);
}}
dataSource={Array.from(this.state.namespaceOptions.keys()).map(key => ({ label: key, value: key }))}
value={this.state.globalLockParam.namespace}
/>
</FormItem>
<FormItem name="cluster" label="cluster">
<Select
hasClear
placeholder={selectClusterFilerPlaceholder}
onChange={(value: string) => {
this.searchFilterOnChange('cluster', value);
}}
dataSource={this.state.clusters.map(value => ({ label: value, value }))}
value={this.state.globalLockParam.cluster}
/>
</FormItem>
<FormItem name="vgroup" label="vgroup">
<Select
hasClear
placeholder={selectVGroupFilerPlaceholder}
onChange={(value: string) => {
this.searchFilterOnChange('vgroup', value);
}}
dataSource={this.state.vgroups.map(value => ({ label: value, value }))}
/>
</FormItem>
{/* {reset search filter button} */}
<FormItem>
<Form.Reset onClick={this.resetSearchFilter}>
Expand Down
Loading
Loading