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

fix: fix chinese and special characters #136

Merged
merged 1 commit into from
Mar 7, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: vesoft/nebula-graph-studio:v3.2.1
tags: vesoft/nebula-graph-studio:v3.2.2
3 changes: 2 additions & 1 deletion app/config/explore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ export const downloadCSVFiles = ({ headers, tables, title }) => {
// Non-Internet Explorer
// Use the download property of the A tag to implement the download function
const link = document.createElement('a');
link.href = 'data:text/csv;charset=utf-8,\uFEFF' + encodeURIComponent(result);
link.href =
'data:text/csv;charset=utf-8,\uFEFF' + encodeURIComponent(result);
link.download = `${title}.csv`;
document.body.appendChild(link);
link.click();
Expand Down
6 changes: 1 addition & 5 deletions app/config/rules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NAME_REGEX, POSITIVE_INTEGER_REGEX } from '#app/utils/constant';
import { POSITIVE_INTEGER_REGEX } from '#app/utils/constant';

export const hostRulesFn = intl => [
{
Expand Down Expand Up @@ -37,10 +37,6 @@ export const nameRulesFn = intl => [
required: true,
message: intl.get('formRules.nameRequired'),
},
{
pattern: NAME_REGEX,
message: intl.get('formRules.nameValidate'),
},
];

export const numberRulesFn = intl => [
Expand Down
22 changes: 8 additions & 14 deletions app/modules/Schema/Edge/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import _ from 'lodash';
import React from 'react';
import intl from 'react-intl-universal';
import { connect } from 'react-redux';
import { match, RouteComponentProps, withRouter } from 'react-router-dom';
import { RouteComponentProps, withRouter } from 'react-router-dom';

import GQLCodeMirror from '#app/components/GQLCodeMirror';
import { nameRulesFn, numberRulesFn } from '#app/config/rules';
Expand Down Expand Up @@ -46,9 +46,7 @@ interface IProps
extends ReturnType<typeof mapState>,
ReturnType<typeof mapDispatch>,
FormComponentProps,
RouteComponentProps {
match: match<{ space: string }>;
}
RouteComponentProps {}

interface IState {
fieldRequired: boolean;
Expand Down Expand Up @@ -327,10 +325,6 @@ class CreateEdge extends React.Component<IProps, IState> {

handleCreate = () => {
const { getFieldsValue } = this.props.form;
const { match } = this.props;
const {
params: { space },
} = match;
this.props.form.validateFields(err => {
const form = getFieldsValue();
if (!err) {
Expand All @@ -349,7 +343,10 @@ class CreateEdge extends React.Component<IProps, IState> {
.then(res => {
if (res.code === 0) {
message.success(intl.get('schema.createSuccess'));
this.props.history.push(`/space/${space}/edge/edit/${name}`);
this.props.history.push({
pathname: '/space/edge/edit',
state: { edge: name },
});
} else {
message.warning(res.message);
}
Expand All @@ -361,17 +358,14 @@ class CreateEdge extends React.Component<IProps, IState> {

goBack = e => {
e.preventDefault();
const { match, history } = this.props;
const {
params: { space },
} = match;
const { history } = this.props;
confirm({
title: intl.get('schema.leavePage'),
content: intl.get('schema.leavePagePrompt'),
okText: intl.get('common.confirm'),
cancelText: intl.get('common.cancel'),
onOk() {
history.push(`/space/${space}/edge/list`);
history.push(`/space/edge/list`);
trackEvent('navigation', 'view_edge_list', 'from_edge_create');
},
});
Expand Down
96 changes: 41 additions & 55 deletions app/modules/Schema/Edge/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import _ from 'lodash';
import React from 'react';
import intl from 'react-intl-universal';
import { connect } from 'react-redux';
import { match, RouteComponentProps, withRouter } from 'react-router-dom';
import { RouteComponentProps, withRouter } from 'react-router-dom';

import GQLCodeMirror from '#app/components/GQLCodeMirror';
import { IDispatch, IRootState } from '#app/store';
import {
DATA_TYPE,
EXPLAIN_DATA_TYPE,
NAME_REGEX,
POSITIVE_INTEGER_REGEX,
} from '#app/utils/constant';
import { convertBigNumberToString } from '#app/utils/function';
Expand All @@ -41,6 +40,7 @@ const confirm = Modal.confirm;
const mapState = (state: IRootState) => ({
loading: state.loading.effects.nebula.asyncGetEdgeDetail,
editLoading: state.loading.effects.nebula.asyncAlterField,
currentSpace: state.nebula.currentSpace,
});

const mapDispatch = (dispatch: IDispatch) => ({
Expand All @@ -54,10 +54,6 @@ interface IProps
extends ReturnType<typeof mapState>,
ReturnType<typeof mapDispatch>,
RouteComponentProps {
match: match<{
space: string;
edge: string;
}>;
asyncUpdateEditStatus: (status: boolean) => void;
}

Expand Down Expand Up @@ -88,6 +84,7 @@ interface IState extends IRequired {
editTtlConfig: ITtl | null;
comment: string;
temporaryComment: string;
edge: string;
}

type AlterType = 'ADD' | 'DROP' | 'CHANGE' | 'TTL';
Expand Down Expand Up @@ -120,6 +117,7 @@ class EditEdge extends React.Component<IProps, IState> {
editTtlConfig: null,
comment: '',
temporaryComment: '',
edge: '',
};
}

Expand All @@ -128,11 +126,26 @@ class EditEdge extends React.Component<IProps, IState> {
this.getDetails();
}

componentDidUpdate(prevProps) {
if (
prevProps.currentSpace &&
prevProps.currentSpace !== this.props.currentSpace
) {
this.props.history.push('/space/edge/list');
}
}

getDetails = async () => {
const { match } = this.props;
const {
params: { edge },
} = match;
location: { state },
history,
} = this.props;
if (!(state as any).edge) {
history.push('/space/edge/list');
return;
}
const edge = (state as any).edge;
this.setState({ edge });
const { code, data } = await this.props.asyncGetEdgeDetail(edge);
const {
code: propCode,
Expand All @@ -146,7 +159,7 @@ class EditEdge extends React.Component<IProps, IState> {
};

handleData = (data: string, fieldInfo: IEdgeFeild[]) => {
const reg = /CREATE EDGE\s`\w+`\s\((.*)\)\s+(ttl_duration = \d+),\s+(ttl_col = "\w*")(, comment = ".*")?/gm;
const reg = /CREATE EDGE\s`.+`\s\((.*)\)\s+(ttl_duration = \d+),\s+(ttl_col = ".*?")(, comment = ".*")?$/gm;
const str = data.replace(/[\r\n]/g, ' ');
const infoList = reg.exec(str) || [];
const fieldList: IField[] = fieldInfo.map(i => ({
Expand Down Expand Up @@ -204,10 +217,7 @@ class EditEdge extends React.Component<IProps, IState> {
};

handleDeleteField = async (fields: IField[]) => {
const { match } = this.props;
const {
params: { edge },
} = match;
const { edge } = this.state;
const res = await this.props.asyncAlterField({
type: 'EDGE',
name: edge,
Expand Down Expand Up @@ -296,19 +306,12 @@ class EditEdge extends React.Component<IProps, IState> {
};

handleUpdateField = async () => {
const { match } = this.props;
const {
params: { edge },
} = match;
const { editField } = this.state;
const { editField, edge } = this.state;
if (editField) {
const { name, type, alterType, fixedLength } = editField;
if (name === '' || type === '') {
return message.warning(intl.get('schema.fieldRequired'));
}
if (name !== '' && !NAME_REGEX.test(name)) {
return message.warning(intl.get('formRules.nameValidate'));
}
if (
type === 'fixed_string' &&
!fixedLength?.match(POSITIVE_INTEGER_REGEX)
Expand Down Expand Up @@ -338,11 +341,7 @@ class EditEdge extends React.Component<IProps, IState> {
};

handleUpdateTtl = async () => {
const { match } = this.props;
const {
params: { edge },
} = match;
const { editTtlConfig } = this.state;
const { editTtlConfig, edge } = this.state;
if (editTtlConfig) {
const { col, duration } = editTtlConfig;
if (col === '' || duration === '') {
Expand Down Expand Up @@ -375,10 +374,7 @@ class EditEdge extends React.Component<IProps, IState> {
};

handleTogglePanels = async (e: string | string[], type: string) => {
const { match } = this.props;
const {
params: { edge },
} = match;
const { edge } = this.state;
if (e.length > 0) {
if (type === 'field') {
this.handleAddField();
Expand Down Expand Up @@ -423,10 +419,7 @@ class EditEdge extends React.Component<IProps, IState> {
};

handleDeleteTtl = async () => {
const { match } = this.props;
const {
params: { edge },
} = match;
const { edge } = this.state;
const res = await this.props.asyncAlterField({
type: 'EDGE',
name: edge,
Expand Down Expand Up @@ -463,7 +456,7 @@ class EditEdge extends React.Component<IProps, IState> {
/>
);
} else {
return <span>{record}</span>;
return <span>{record.toString()}</span>;
}
},
},
Expand Down Expand Up @@ -737,12 +730,9 @@ class EditEdge extends React.Component<IProps, IState> {
editTtlConfig,
editComment,
temporaryComment,
edge,
} = this.state;
if (editField || editTtlConfig || editComment) {
const { match } = this.props;
const {
params: { edge },
} = match;
let action;
let config = {};
if (editField) {
Expand Down Expand Up @@ -775,24 +765,21 @@ class EditEdge extends React.Component<IProps, IState> {

goBack = e => {
e.preventDefault();
const { match, history } = this.props;
const { history } = this.props;
const { editRow, editTtl } = this.state;
const {
params: { space },
} = match;
if (editRow !== null || editTtl) {
confirm({
title: intl.get('schema.leavePage'),
content: intl.get('schema.leavePagePrompt'),
okText: intl.get('common.confirm'),
cancelText: intl.get('common.cancel'),
onOk() {
history.push(`/space/${space}/edge/list`);
history.push(`/space/edge/list`);
trackEvent('navigation', 'view_edge_list', 'from_edge_edit');
},
});
} else {
history.push(`/space/${space}/edge/list`);
history.push(`/space/edge/list`);
trackEvent('navigation', 'view_edge_list', 'from_edge_edit');
}
};
Expand All @@ -806,11 +793,7 @@ class EditEdge extends React.Component<IProps, IState> {
};

handleCommentUpdate = async () => {
const { match } = this.props;
const {
params: { edge },
} = match;
const { temporaryComment } = this.state;
const { temporaryComment, edge } = this.state;
const res = await this.props.asyncAlterField({
type: 'EDGE',
name: edge,
Expand Down Expand Up @@ -847,11 +830,14 @@ class EditEdge extends React.Component<IProps, IState> {
};

render() {
const { match, editLoading } = this.props;
const { fieldRequired, ttlRequired, comment, editComment } = this.state;
const { editLoading } = this.props;
const {
params: { edge },
} = match;
fieldRequired,
ttlRequired,
comment,
editComment,
edge,
} = this.state;
const outItemLayout = {
labelCol: {
span: 2,
Expand Down
Loading