Skip to content

Commit

Permalink
feat: add tips when use space err after creating
Browse files Browse the repository at this point in the history
  • Loading branch information
hetao92 committed Dec 30, 2021
1 parent 081cdc7 commit b43ff23
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
1 change: 1 addition & 0 deletions app/assets/config/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"schema": {
"spaceList": "Graph Space List",
"backToSpaceList": "Graph Space List",
"useSpaceErrTip": "Trying to use a newly created graph space may fail because the creation is implemented asynchronously. To make sure the follow-up operations work as expected, Wait for two heartbeat cycles, i.e., 20 seconds.",
"partitionNumDescription": "partition_num specifies the number of partitions in one replica. The default value is 100. It is usually 5 times the number of hard disks in the cluster.",
"replicaFactorDescription": "replica_factor specifies the number of replicas in the cluster. The default replica factor is 1. The suggested number is 3 in cluster. It is usually 3 in production. Due to the majority voting principle, it must set to be odd.",
"charsetDescription": "charset is short for character set. A character set is a set of symbols and encodings. The default value is utf8.",
Expand Down
1 change: 1 addition & 0 deletions app/assets/config/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"schema": {
"spaceList": "图空间列表",
"backToSpaceList": "图空间列表",
"useSpaceErrTip": "立刻尝试使用刚创建的图空间可能会失败,因为创建是异步实现的。为确保数据同步,后续操作能顺利进行,请等待 2 个心跳周期(20 秒)。",
"partitionNumDescription": "partition_num 表示数据分片数量。默认值为 100。建议为硬盘数量的 5 倍。",
"replicaFactorDescription": "replica_factor 表示副本数量。默认值是 1,生产集群建议为 3。由于采用多数表决原理,因此需为奇数。",
"charsetDescription": "charset 表示字符集,定义了字符以及字符的编码,默认为 utf8。",
Expand Down
42 changes: 24 additions & 18 deletions app/assets/modules/Schema/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ const mapState = (state: IRootState) => ({
const mapDispatch = (dispatch: IDispatch) => ({
asyncGetSpacesList: dispatch.nebula.asyncGetSpacesList,
asyncDeleteSpace: dispatch.nebula.asyncDeleteSpace,
asyncSwitchSpace: async space => {
await dispatch.nebula.asyncSwitchSpace(space);
await dispatch.explore.clear();
},
asyncSwitchSpace: dispatch.nebula.asyncSwitchSpace,
asyncClearExplore: dispatch.explore.clear,
clearCurrentSpace: () =>
dispatch.nebula.update({
currentSpace: '',
Expand Down Expand Up @@ -60,6 +58,16 @@ class Schema extends React.Component<IProps> {
}
};

handleSwitchSpace = async (space: string) => {
const { asyncSwitchSpace, history, asyncClearExplore } = this.props;
const err = await asyncSwitchSpace(space);
if (!err) {
await asyncClearExplore();
history.push(`/space/${space}/tag/list`);
} else {
message.warning(intl.get('schema.useSpaceErrTip'));
}
};
render() {
const { loading, spaceList, asyncSwitchSpace } = this.props;
const columns = [
Expand All @@ -73,15 +81,15 @@ class Schema extends React.Component<IProps> {
dataIndex: 'Name',
align: 'center' as const,
render: value => (
<Link
to={`/space/${value}/tag/list`}
onClick={() => asyncSwitchSpace(value)}
<Button
type="link"
onClick={() => this.handleSwitchSpace(value)}
data-track-category="navigation"
data-track-action="view_space_list"
data-track-label="from_space_list"
>
{value}
</Link>
</Button>
),
},
{
Expand Down Expand Up @@ -163,16 +171,14 @@ class Schema extends React.Component<IProps> {
return (
<div className="operation">
<div>
<Button shape="circle">
<Link
to={`/space/${space.Name}/tag/list`}
onClick={() => asyncSwitchSpace(space.Name)}
data-track-category="navigation"
data-track-action="view_space_list"
data-track-label="from_space_list"
>
<Icon type="tool" theme="twoTone" />
</Link>
<Button
shape="circle"
onClick={() => asyncSwitchSpace(space.Name)}
data-track-category="navigation"
data-track-action="view_space_list"
data-track-label="from_space_list"
>
<Icon type="tool" theme="twoTone" />
</Button>
<Popconfirm
onConfirm={() => this.handleDeleteSpace(space.Name)}
Expand Down
4 changes: 3 additions & 1 deletion app/assets/store/models/nebula.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export const nebula = createModel({
},

async asyncSwitchSpace(space: string) {
const { code } = (await service.execNGQL({
const { code, message } = (await service.execNGQL({
// HACK: Processing keyword
gql: 'use' + '`' + space + '`;',
})) as any;
Expand All @@ -329,6 +329,8 @@ export const nebula = createModel({
spaceVidType,
});
sessionStorage.setItem('currentSpace', space);
} else {
return message;
}
},

Expand Down

0 comments on commit b43ff23

Please sign in to comment.