Skip to content

Commit

Permalink
update: import intl (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
huaxiabuluo authored Mar 18, 2022
1 parent 32d851b commit c8665bc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
14 changes: 7 additions & 7 deletions app/config/rules.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { POSITIVE_INTEGER_REGEX } from '@app/utils/constant';
import intl from 'react-intl-universal';

export const hostRulesFn = intl => [
export const hostRulesFn = () => [
{
required: true,
message: intl.get('formRules.hostRequired'),
},
];

export const usernameRulesFn = intl => [
export const usernameRulesFn = () => [
{
required: true,
message: intl.get('formRules.usernameRequired'),
},
];

export const passwordRulesFn = intl => [
export const passwordRulesFn = () => [
{
required: true,
message: intl.get('formRules.passwordRequired'),
},
];


export const nameRulesFn = intl => [
export const nameRulesFn = () => [
{
required: true,
message: intl.get('formRules.nameRequired'),
},
];

export const numberRulesFn = intl => [
export const numberRulesFn = () => [
{
pattern: POSITIVE_INTEGER_REGEX,
message: intl.get('formRules.numberRequired'),
},
];

export const replicaRulesFn = (intl, activeMachineNum) => [
export const replicaRulesFn = (activeMachineNum) => [
{
pattern: POSITIVE_INTEGER_REGEX,
message: intl.get('formRules.numberRequired'),
Expand Down
6 changes: 3 additions & 3 deletions app/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ const LoginPage: React.FC = () => {
<FormItem noStyle={true}>
<span className="form-title">{intl.get('configServer.title')}</span>
</FormItem>
<FormItem name="host" rules={hostRulesFn(intl)}>
<FormItem name="host" rules={hostRulesFn()}>
<Input placeholder={intl.get('configServer.host')} bordered={false} />
</FormItem>
<FormItem name="username" rules={usernameRulesFn(intl)}>
<FormItem name="username" rules={usernameRulesFn()}>
<Input placeholder={intl.get('configServer.username')} bordered={false} />
</FormItem>
<FormItem name="password" rules={passwordRulesFn(intl)}>
<FormItem name="password" rules={passwordRulesFn()}>
<Input.Password placeholder={intl.get('configServer.password')} bordered={false} />
</FormItem>
<Button className="btn-submit" type="primary" htmlType="submit" loading={loading}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { DATA_TYPE, EXPLAIN_DATA_TYPE } from '@app/utils/constant';

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


const itemLayout = {
Expand Down Expand Up @@ -115,7 +114,7 @@ const PropertiesForm = (props: IProps) => {
name={[name, 'name']}
{...restField}
{...itemLayout}
rules={nameRulesFn(intl)}>
rules={nameRulesFn()}>
<Input />
</Form.Item>
</Col>
Expand Down Expand Up @@ -147,7 +146,7 @@ const PropertiesForm = (props: IProps) => {
className="item-string-length"
name={[name, 'fixedLength']}
rules={[
...numberRulesFn(intl),
...numberRulesFn(),
{
required: true,
message: intl.get('formRules.numberRequired'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const ConfigCreate = (props: IProps) => {
{...formItemLayout}>
<Row className="form-item">
<Col span={12}>
<Form.Item label={intl.get('common.name')} name="name" rules={nameRulesFn(intl)}>
<Form.Item label={intl.get('common.name')} name="name" rules={nameRulesFn()}>
<Input />
</Form.Item>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Schema/SchemaConfig/Create/IndexCreate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const IndexCreate = () => {
</Row>
<Row>
<Col span={12}>
<Form.Item label={intl.get('schema.indexName')} name="name" rules={nameRulesFn(intl)}>
<Form.Item label={intl.get('schema.indexName')} name="name" rules={nameRulesFn()}>
<Input />
</Form.Item>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const EditRow = (props: IEditProps) => {
<Form.Item
name="name"
initialValue={name}
rules={nameRulesFn(intl)}>
rules={nameRulesFn()}>
<Input disabled={alterType !== 'ADD'} />
</Form.Item>
</Col>
Expand Down Expand Up @@ -116,7 +116,7 @@ export const EditRow = (props: IEditProps) => {
name="fixedLength"
initialValue={fixedLength}
rules={[
...numberRulesFn(intl),
...numberRulesFn(),
{
required: true,
message: intl.get('formRules.numberRequired'),
Expand Down
8 changes: 4 additions & 4 deletions app/pages/Schema/SpaceCreate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const SpaceCreate = () => {
<Form className="space-form" form={form} layout="vertical" onFieldsChange={updateGql} {...formItemLayout}>
<Row>
<Col span={12}>
<Form.Item label={intl.get('common.name')} name="name" rules={nameRulesFn(intl)}>
<Form.Item label={intl.get('common.name')} name="name" rules={nameRulesFn()}>
<Input placeholder={intl.get('schema.spaceNameEnter')} />
</Form.Item>
</Col>
Expand All @@ -126,7 +126,7 @@ const SpaceCreate = () => {
required: true,
message: 'fix string length limit is required',
},
...numberRulesFn(intl),
...numberRulesFn(),
]}>
<Input />
</Form.Item>
Expand All @@ -152,7 +152,7 @@ const SpaceCreate = () => {
<span className="optional-item">({intl.get('common.optional')})</span>
</span>}
name="partitionNum"
rules={numberRulesFn(intl)}
rules={numberRulesFn()}
>
<Input placeholder="100" />
</Form.Item>
Expand All @@ -165,7 +165,7 @@ const SpaceCreate = () => {
<span className="optional-item">({intl.get('common.optional')})</span>
</span>}
name="replicaFactor"
rules={replicaRulesFn(intl, activeMachineNum)}
rules={replicaRulesFn(activeMachineNum)}
>
<Input placeholder="1" />
</Form.Item>
Expand Down

0 comments on commit c8665bc

Please sign in to comment.