Skip to content

Commit 6aed7a2

Browse files
authored
placeholder and tips (#49)
1 parent c9dd1fc commit 6aed7a2

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

renderer/src/pages/Git/components/GitDirFormItemLabel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default () => {
1111
align="t"
1212
delay={200}
1313
>
14-
该目录下的 Git 项目都将使用此配置,详细说明查看<a href="https://git-scm.com/docs/git-config#_conditional_includes" target="__blank">文档</a>
14+
该目录下的 Git 项目都将使用此 Git 配置,详细说明参考<a href="https://appworks.site/pack/basic/toolkit.html#使用不同的-git-配置" target="__blank">文档</a>
1515
</Tooltip>
1616
</span>
1717
);

renderer/src/pages/Git/components/GlobalGitConfig/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const GlobalGitConfig: FC<{}> = () => {
1313
const { globalGitConfig } = state;
1414

1515
const onFieldChange = debounce(async () => {
16+
const { errors } = await field.validatePromise();
17+
if (errors) {
18+
return;
19+
}
1620
const values: any = field.getValues();
1721
await dispatcher.updateGlobalGitConfig(removeObjEmptyValue(values));
1822
Message.success('更新全局 Git 配置成功');
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Icon, Balloon } from '@alifd/next';
2+
3+
const { Tooltip } = Balloon;
4+
5+
export default () => {
6+
return (
7+
<span>
8+
Git 服务器域名
9+
<Tooltip
10+
trigger={<Icon type="prompt" style={{ marginLeft: 4 }} />}
11+
align="t"
12+
delay={200}
13+
>
14+
如何查看 Git 服务器域名,请参考<a href="https://appworks.site/pack/basic/toolkit.html#新增配置" target="__blank">文档</a>
15+
</Tooltip>
16+
</span>
17+
);
18+
};

renderer/src/pages/Git/components/SSHKeyFormItemLabel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default () => {
1111
align="t"
1212
delay={200}
1313
>
14-
添加 SSH 公钥教程,请查看<a href="https://appworks.site/pack/basic/toolkit.html" target="__blank">文档</a>
14+
添加 SSH 公钥教程,请参考<a href="https://appworks.site/pack/basic/toolkit.html#使用-ssh-公钥" target="__blank">文档</a>
1515
</Tooltip>
1616
</span>
1717
);

renderer/src/pages/Git/components/UserGitConfig/index.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Icon from '@/components/Icon';
77
import store from '../../store';
88
import SSHKeyFormItemLabel from '../SSHKeyFormItemLabel';
99
import GitDirsForm from '../GitDirsForm';
10+
import HostNameFormItemLabel from '../HostNameFormItemLabel';
1011
import styles from './index.module.scss';
1112

1213
const { Row, Col } = Grid;
@@ -28,6 +29,10 @@ const UserGitConfig: FC<UserGitConfigProps> = ({ configName, gitDirs, SSHPublicK
2829
const field = Field.useField({
2930
parseName: true,
3031
onChange: debounce(async () => {
32+
const { errors } = await field.validatePromise();
33+
if (errors) {
34+
return;
35+
}
3136
const values: any = field.getValues();
3237
await dispatcher.updateUserGitConfig({
3338
configName,
@@ -49,13 +54,29 @@ const UserGitConfig: FC<UserGitConfigProps> = ({ configName, gitDirs, SSHPublicK
4954
return (
5055
<div className={styles.userGitConfig}>
5156
<Row align="center" className={styles.row}>
52-
<Col span={10} className={styles.label}>Git 服务器域名</Col>
57+
<Col span={10} className={styles.label}><HostNameFormItemLabel /></Col>
5358
<Col span={14}>
5459
<Input
55-
{...field.init('user.hostName')}
60+
{...field.init('user.hostName', {
61+
rules: [
62+
{
63+
required: true,
64+
pattern: /^(?!http:\/\/|https:\/\/).*/i,
65+
message: 'Git 服务器域名不需要带 http(s)://,如 github.com',
66+
trigger: 'onChange',
67+
},
68+
],
69+
})}
5670
className={styles.input}
57-
placeholder="如 github.com、gitlab.com"
71+
placeholder="如 github.com"
5872
/>
73+
{field.getError('user.hostName') ? (
74+
<div style={{ color: 'red', marginTop: 4 }}>
75+
{field.getError('user.hostName').join(',')}
76+
</div>
77+
) : (
78+
''
79+
)}
5980
</Col>
6081
</Row>
6182
<Row align="center" className={styles.row}>

renderer/src/pages/Git/components/UserGitConfigDialogForm/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FC, useEffect } from 'react';
22
import { Dialog, Form, Field, Input, Message, Icon, Button } from '@alifd/next';
33
import store from '../../store';
4+
import HostNameFormItemLabel from '../HostNameFormItemLabel';
45
import styles from './index.module.scss';
56

67
interface UserGitConfigDialogFormProps {
@@ -80,7 +81,7 @@ const UserGitConfigDialogForm: FC<UserGitConfigDialogFormProps> = ({ refresh })
8081
<Dialog
8182
visible={userGitConfigFormVisible}
8283
title={'新增用户配置'}
83-
style={{ width: 600 }}
84+
style={{ width: 700 }}
8485
onOk={submit}
8586
onCancel={close}
8687
closeable={false}
@@ -99,11 +100,13 @@ const UserGitConfigDialogForm: FC<UserGitConfigDialogFormProps> = ({ refresh })
99100
<Input name="configName" placeholder="请输入配置名称,仅支持字母和数字的组合,如 Github" />
100101
</Form.Item>
101102
<Form.Item
102-
label="Git 服务器域名"
103+
label={<HostNameFormItemLabel />}
103104
required
104105
requiredMessage="请输入 Git 服务器域名,如 github.com"
106+
pattern={/^(?!http:\/\/|https:\/\/).*/i}
107+
patternMessage="Git 服务器域名不需要带 http(s)://,如 github.com"
105108
>
106-
<Input name="user.hostName" placeholder="请输入 Git 服务器域名" />
109+
<Input name="user.hostName" placeholder="请输入 Git 服务器域名,如 github.com" />
107110
</Form.Item>
108111
<Form.Item
109112
label="用户名"

0 commit comments

Comments
 (0)