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 & remove pwd #139

Merged
merged 1 commit into from
Mar 8, 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
3 changes: 2 additions & 1 deletion app/config/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@
"link": {
"nGQLHref": "https://docs.nebula-graph.io/3.0.0/3.ngql-guide/1.nGQL-overview/1.overview/",
"mannualHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/about-studio/st-ug-what-is-graph-studio/",
"startStudioHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/quick-start/st-ug-plan-schema/"
"startStudioHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/quick-start/st-ug-plan-schema/",
"versionLogHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/about-studio/st-ug-release-note/"
}
}
3 changes: 2 additions & 1 deletion app/config/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@
"link": {
"nGQLHref": "https://docs.nebula-graph.com.cn/3.0.0/3.ngql-guide/1.nGQL-overview/1.overview/",
"mannualHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/about-studio/st-ug-what-is-graph-studio/",
"startStudioHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/quick-start/st-ug-plan-schema/"
"startStudioHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/quick-start/st-ug-plan-schema/",
"versionLogHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/about-studio/st-ug-release-note/"
}
}
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
2 changes: 0 additions & 2 deletions app/config/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const deteleFile = params => {
return _delete(`/api/files/${filename}`)();
};
const getFiles = get('/api/files');
const getAppInfo = get('/api/app');
const uploadFiles = (params?, config?) =>
put('/api/files')(params, {
...config,
Expand All @@ -46,6 +45,5 @@ export default {
getTaskDir,
deteleFile,
getFiles,
getAppInfo,
uploadFiles,
};
2 changes: 1 addition & 1 deletion app/pages/MainPage/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const RoutesList = [
exact: true,
},
{
path: '/schema/:space/:type?/:action?/:module?',
path: '/schema/:type?/:action?/:module?',
component: SchemaConfig,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DATA_TYPE, EXPLAIN_DATA_TYPE } from '@app/utils/constant';

const Option = Select.Option;
import './index.less';
import { cloneDeep } from 'lodash';


const itemLayout = {
Expand All @@ -18,14 +19,16 @@ const itemLayout = {
};

interface IProps {
formRef: FormInstance
formRef: FormInstance;
onUpdate: () => void;
}

const PropertiesForm = (props: IProps) => {
const { formRef } = props;
const { formRef, onUpdate } = props;
const handleClearProperties = e => {
if(!e.target.checked) {
formRef.resetFields(['properties', []]);
setTimeout(onUpdate, 300);
}
};
const handlePropertyAdd = callback => {
Expand Down Expand Up @@ -60,6 +63,13 @@ const PropertiesForm = (props: IProps) => {
}
callback(rowIndex);
};

const handleResetValue = (index) => {
const properties = formRef.getFieldValue('properties');
const _properties = [...properties];
_properties[index].value = '';
formRef.setFieldsValue({ 'properties': _properties });
};
return (
<Form.Item noStyle={true}>
<div className="form-item">
Expand Down Expand Up @@ -121,7 +131,7 @@ const PropertiesForm = (props: IProps) => {
message: intl.get('formRules.dataTypeRequired'),
},
]}>
<Select className="select-type" showSearch={true} dropdownMatchSelectWidth={false}>
<Select className="select-type" showSearch={true} onChange={() => handleResetValue(index)} dropdownMatchSelectWidth={false}>
{DATA_TYPE.map(item => {
return (
<Option value={item.value} key={item.value}>
Expand Down
6 changes: 4 additions & 2 deletions app/pages/Schema/SchemaConfig/Create/CommonCreate/TTLForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ const innerItemLayout = {
};

interface IProps {
formRef: FormInstance
formRef: FormInstance;
onUpdate: () => void;
}

const formRef = ((props: IProps) => {
const { formRef } = props;
const { formRef, onUpdate } = props;
const handleClearTtl = e => {
if(!e.target.checked) {
formRef.resetFields(['ttl_col', '']);
formRef.resetFields(['ttl_duration', '']);
setTimeout(onUpdate, 300);
}
};
return (
Expand Down
14 changes: 8 additions & 6 deletions app/pages/Schema/SchemaConfig/Create/CommonCreate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState } from 'react';
import intl from 'react-intl-universal';
import { observer } from 'mobx-react-lite';
import { nameRulesFn } from '@app/config/rules';
import { useHistory, useParams } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import { uniqBy } from 'lodash';
import GQLCodeMirror from '@app/components/GQLCodeMirror';
import { getTagOrEdgeCreateGQL } from '@app/utils/gql';
Expand All @@ -28,7 +28,6 @@ interface IProps {
const ConfigCreate = (props: IProps) => {
const { createType } = props;
const history = useHistory();
const { space } = useParams() as {space :string };
const [loading, setLoading] = useState(false);
const { schema: { createTagOrEdge } } = useStore();
const [gql, setGql] = useState('');
Expand Down Expand Up @@ -62,7 +61,10 @@ const ConfigCreate = (props: IProps) => {
setLoading(false);
if (res.code === 0) {
message.success(intl.get('schema.createSuccess'));
history.push(`/schema/${space}/${createType}/edit/${name}`);
history.push({
pathname: `/schema/${createType}/edit`,
state: { [createType]: name },
});
}
};
return (
Expand All @@ -86,14 +88,14 @@ const ConfigCreate = (props: IProps) => {
</Form.Item>
</Col>
</Row>
<PropertiesForm formRef={basicForm} />
<TTLForm formRef={basicForm} />
<PropertiesForm formRef={basicForm} onUpdate={updateGql} />
<TTLForm formRef={basicForm} onUpdate={updateGql} />
<Form.Item noStyle={true}>
<GQLCodeMirror currentGQL={gql} />
</Form.Item>
<Form.Item noStyle={true}>
<div className="studio-form-footer">
<Button onClick={() => history.push(`/schema/${space}/${createType}/list`)}>{intl.get('common.cancel')}</Button>
<Button onClick={() => history.push(`/schema/${createType}/list`)}>{intl.get('common.cancel')}</Button>
<Button type="primary" loading={loading} htmlType="submit">{intl.get('common.create')}</Button>
</div>
</Form.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import intl from 'react-intl-universal';
import { observer } from 'mobx-react-lite';
import { IField } from '@app/interfaces/schema';
import { POSITIVE_INTEGER_REGEX } from '@app/utils/constant';
import { handleKeyword } from '@app/utils/function';
import Instruction from '@app/components/Instruction';
const Option = Select.Option;

Expand All @@ -29,8 +30,8 @@ const FieldSelectModal = (props: IProps) => {
}
const newField =
selectedField?.Type === 'string'
? selectedField.Field + `(${indexLength})`
: selectedField!.Field;
? handleKeyword(selectedField.Field) + `(${indexLength})`
: handleKeyword(selectedField!.Field);
onAddField(newField);
handleClose();
};
Expand Down
11 changes: 5 additions & 6 deletions app/pages/Schema/SchemaConfig/Create/IndexCreate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import React, { useEffect, useState } from 'react';
import intl from 'react-intl-universal';
import { observer } from 'mobx-react-lite';
import { nameRulesFn } from '@app/config/rules';
import { useHistory, useParams } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import GQLCodeMirror from '@app/components/GQLCodeMirror';
import { getIndexCreateGQL } from '@app/utils/gql';
import { useStore } from '@app/stores';
import { IField, IndexType } from '@app/interfaces/schema';
import Icon from '@app/components/Icon';
import { trackPageView } from '@app/utils/stat';

import { handleKeyword } from '@app/utils/function';
import FieldSelectModal from './FieldSelectModal';
import DraggableTags from './DraggableTags';
const Option = Select.Option;
Expand All @@ -29,7 +29,6 @@ const formItemLayout = {

const IndexCreate = () => {
const history = useHistory();
const { space } = useParams() as {space :string };
const [loading, setLoading] = useState(false);
const { schema: { createIndex, getTags, getEdges, getTagOrEdgeInfo } } = useStore();
const [gql, setGql] = useState('');
Expand Down Expand Up @@ -61,7 +60,7 @@ const IndexCreate = () => {
setLoading(false);
if (res.code === 0) {
message.success(intl.get('schema.createSuccess'));
history.push(`/schema/${space}/index/list/${type}`);
history.push(`/schema/index/list/${type}`);
}
};

Expand Down Expand Up @@ -195,7 +194,7 @@ const IndexCreate = () => {
{({ getFieldValue }) => {
const fields = getFieldValue('fields') || [];
const filterList = fieldList.filter(
item => !fields.some(field => field.startsWith(item.Field)),
item => !fields.some(field => field.startsWith(handleKeyword(item.Field))),
);
return <>
<DraggableTags
Expand All @@ -220,7 +219,7 @@ const IndexCreate = () => {
</Form.Item>
<Form.Item noStyle={true}>
<div className="studio-form-footer">
<Button onClick={() => history.push(`/schema/${space}/index/list`)}>{intl.get('common.cancel')}</Button>
<Button onClick={() => history.push(`/schema/index/list`)}>{intl.get('common.cancel')}</Button>
<Button type="primary" loading={loading} htmlType="submit">{intl.get('common.create')}</Button>
</div>
</Form.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ const PropertiesForm = (props: IProps) => {
},
});
};

const handleResetValue = () => {
form.setFieldsValue({ value: '' });
};
return (
<Form
form={form}
Expand Down Expand Up @@ -174,7 +178,7 @@ const PropertiesForm = (props: IProps) => {
</Form.Item>
{list.map((item, index) => {
return editRow === index
? <EditRow key={index} data={editField} onEditCancel={handleEditCancel} />
? <EditRow key={index} data={editField} onUpdateType={handleResetValue} onEditCancel={handleEditCancel} />
: <DisplayRow
key={index}
data={item}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface IProps {
interface IEditProps {
data: IEditProperty | null;
onEditCancel: () => void;
onUpdateType: () => void;
}

export const DisplayRow = (props: IProps) => {
Expand Down Expand Up @@ -69,7 +70,7 @@ export const DisplayRow = (props: IProps) => {
};

export const EditRow = (props: IEditProps) => {
const { data, onEditCancel } = props;
const { data, onEditCancel, onUpdateType } = props;
if(!data) {
return null;
}
Expand Down Expand Up @@ -99,7 +100,7 @@ export const EditRow = (props: IEditProps) => {
message: intl.get('formRules.dataTypeRequired'),
},
]}>
<Select className="select-type" showSearch={true} dropdownMatchSelectWidth={false}>
<Select className="select-type" showSearch={true} onChange={onUpdateType} dropdownMatchSelectWidth={false}>
{DATA_TYPE.map(item => {
return (
<Option value={item.value} key={item.value}>
Expand Down
Loading