Skip to content

Commit 9ee06d7

Browse files
author
dashuai
authored
Merge pull request #496 from answerdev/feat/1.1.3/ui
Feat/1.1.3/UI
2 parents f7602dd + 8f471d9 commit 9ee06d7

16 files changed

Lines changed: 105 additions & 52 deletions

File tree

i18n/en_US.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,12 +1263,14 @@ ui:
12631263
site_name:
12641264
label: Site name
12651265
msg: Site name cannot be empty.
1266+
msg_max_length: Site name must be at maximum 30 characters in length.
12661267
site_url:
12671268
label: Site URL
12681269
text: The address of your site.
12691270
msg:
12701271
empty: Site URL cannot be empty.
12711272
incorrect: Site URL incorrect format.
1273+
max_length: Site URL must be at maximum 512 characters in length.
12721274
contact_email:
12731275
label: Contact email
12741276
text: Email address of key contact responsible for this site.
@@ -1283,12 +1285,15 @@ ui:
12831285
label: Name
12841286
msg: Name cannot be empty.
12851287
character: 'Must use the character set "a-z", "0-9", " - . _"'
1288+
msg_max_length: Name must be at maximum 30 characters in length.
12861289
admin_password:
12871290
label: Password
12881291
text: >-
12891292
You will need this password to log in. Please store it in a secure
12901293
location.
12911294
msg: Password cannot be empty.
1295+
msg_min_length: Password must be at least 8 characters in length.
1296+
msg_max_length: Password must be at maximum 32 characters in length.
12921297
admin_email:
12931298
label: Email
12941299
text: You will need this email to log in.

ui/src/components/BaseUserCard/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface Props {
1212
avatarSearchStr?: string;
1313
className?: string;
1414
avatarClass?: string;
15+
nameMaxWidth?: string;
1516
}
1617

1718
const Index: FC<Props> = ({
@@ -22,11 +23,14 @@ const Index: FC<Props> = ({
2223
className = 'small',
2324
avatarSearchStr = 's=48',
2425
showReputation = true,
26+
nameMaxWidth = '300px',
2527
}) => {
2628
return (
2729
<div className={`d-flex align-items-center text-secondary ${className}`}>
2830
{data?.status !== 'deleted' ? (
29-
<Link to={`/users/${data?.username}`}>
31+
<Link
32+
to={`/users/${data?.username}`}
33+
className="d-flex align-items-center">
3034
{showAvatar && (
3135
<Avatar
3236
avatar={data?.avatar}
@@ -36,7 +40,9 @@ const Index: FC<Props> = ({
3640
alt={data?.display_name}
3741
/>
3842
)}
39-
<span className="me-1 text-truncate-1" style={{ maxWidth: '300px' }}>
43+
<span
44+
className="me-1 name-ellipsis"
45+
style={{ maxWidth: nameMaxWidth }}>
4046
{data?.display_name}
4147
</span>
4248
</Link>
@@ -51,9 +57,7 @@ const Index: FC<Props> = ({
5157
alt={data?.display_name}
5258
/>
5359
)}
54-
<span className="me-1 text-truncate-1" style={{ maxWidth: '300px' }}>
55-
{data?.display_name}
56-
</span>
60+
<span className="me-1 name-ellipsis">{data?.display_name}</span>
5761
</>
5862
)}
5963

ui/src/components/Editor/toolItem.tsx

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FC, useContext, useEffect } from 'react';
2-
import { Dropdown, OverlayTrigger, Tooltip, Button } from 'react-bootstrap';
2+
import { Dropdown, Button } from 'react-bootstrap';
33

44
import { EditorContext } from './EditorContext';
55

@@ -49,28 +49,27 @@ const ToolItem: FC<IProps> = (props) => {
4949
}, []);
5050

5151
const btnRender = () => (
52-
<OverlayTrigger placement="bottom" overlay={<Tooltip>{tip}</Tooltip>}>
53-
<Button
54-
variant="link"
55-
className={`p-0 b-0 btn-no-border toolbar icon-${label} ${
56-
disable ? 'disabled' : ''
57-
} `}
58-
disabled={disable}
59-
tabIndex={-1}
60-
onClick={(e) => {
61-
e.preventDefault();
62-
if (typeof onClick === 'function') {
63-
onClick();
64-
}
65-
}}
66-
onBlur={(e) => {
67-
e.preventDefault();
68-
if (typeof onBlur === 'function') {
69-
onBlur();
70-
}
71-
}}
72-
/>
73-
</OverlayTrigger>
52+
<Button
53+
variant="link"
54+
title={tip}
55+
className={`p-0 b-0 btn-no-border toolbar icon-${label} ${
56+
disable ? 'disabled' : ''
57+
} `}
58+
disabled={disable}
59+
tabIndex={-1}
60+
onClick={(e) => {
61+
e.preventDefault();
62+
if (typeof onClick === 'function') {
63+
onClick();
64+
}
65+
}}
66+
onBlur={(e) => {
67+
e.preventDefault();
68+
if (typeof onBlur === 'function') {
69+
onBlur();
70+
}
71+
}}
72+
/>
7473
);
7574

7675
if (!context) {

ui/src/index.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ img[src=""] {
141141
}
142142
}
143143

144+
.name-ellipsis {
145+
display: inline-block;
146+
text-overflow: ellipsis;
147+
white-space: nowrap;
148+
overflow: hidden;
149+
}
150+
144151
.text-truncate-1,
145152
.text-truncate-2,
146153
.text-truncate-3,

ui/src/pages/Admin/Answers/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const Answers: FC = () => {
155155
<td>{li.vote_count}</td>
156156
<td>
157157
<Stack>
158-
<BaseUserCard data={li.user_info} />
158+
<BaseUserCard data={li.user_info} nameMaxWidth="200px" />
159159

160160
<FormatTime
161161
className="small text-secondary"

ui/src/pages/Admin/Questions/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const Questions: FC = () => {
160160
</td>
161161
<td>
162162
<Stack>
163-
<BaseUserCard data={li.user_info} />
163+
<BaseUserCard data={li.user_info} nameMaxWidth="130px" />
164164
<FormatTime
165165
className="small text-secondary"
166166
time={li.create_time}

ui/src/pages/Admin/Users/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ const Users: FC = () => {
254254
avatarSearchStr="s=48"
255255
avatarClass="me-2"
256256
showReputation={false}
257+
nameMaxWidth="160px"
257258
/>
258259
</td>
259260
<td>{formatCount(user.rank)}</td>

ui/src/pages/Install/components/FourthStep/index.tsx

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
2828
};
2929
}
3030

31+
if (site_name.value && site_name.value.length > 30) {
32+
bol = false;
33+
data.site_url = {
34+
value: site_name.value,
35+
isInvalid: true,
36+
errorMsg: t('site_name.msg_max_length'),
37+
};
38+
}
39+
3140
if (!site_url.value) {
3241
bol = false;
3342
data.site_url = {
@@ -36,6 +45,7 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
3645
errorMsg: t('site_name.msg.empty'),
3746
};
3847
}
48+
3949
const reg = /^(http|https):\/\//g;
4050
if (site_url.value && !site_url.value.match(reg)) {
4151
bol = false;
@@ -44,6 +54,13 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
4454
isInvalid: true,
4555
errorMsg: t('site_url.msg.incorrect'),
4656
};
57+
} else if (site_url.value.length > 512) {
58+
bol = false;
59+
data.site_url = {
60+
value: site_url.value,
61+
isInvalid: true,
62+
errorMsg: t('site_url.msg.max_length'),
63+
};
4764
}
4865

4966
if (!contact_email.value) {
@@ -78,6 +95,13 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
7895
isInvalid: true,
7996
errorMsg: t('admin_name.character'),
8097
};
98+
} else if (data.name.value.length > 30) {
99+
bol = false;
100+
data.name = {
101+
value: data.name.value,
102+
isInvalid: true,
103+
errorMsg: t('admin_name.msg_max_length'),
104+
};
81105
}
82106

83107
if (!password.value) {
@@ -89,6 +113,24 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
89113
};
90114
}
91115

116+
if (password.value && password.value.length < 4) {
117+
bol = false;
118+
data.password = {
119+
value: data.password.value,
120+
isInvalid: true,
121+
errorMsg: t('admin_password.msg_min_length'),
122+
};
123+
}
124+
125+
if (password.value && password.value.length > 32) {
126+
bol = false;
127+
data.password = {
128+
value: data.password.value,
129+
isInvalid: true,
130+
errorMsg: t('admin_password.msg_max_length'),
131+
};
132+
}
133+
92134
if (!email.value) {
93135
bol = false;
94136
data.email = {
@@ -132,7 +174,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
132174
required
133175
value={data.site_name.value}
134176
isInvalid={data.site_name.isInvalid}
135-
maxLength={30}
136177
onChange={(e) => {
137178
changeCallback({
138179
site_name: {
@@ -153,7 +194,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
153194
required
154195
value={data.site_url.value}
155196
isInvalid={data.site_url.isInvalid}
156-
maxLength={512}
157197
onChange={(e) => {
158198
changeCallback({
159199
site_url: {
@@ -220,7 +260,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
220260
required
221261
value={data.name.value}
222262
isInvalid={data.name.isInvalid}
223-
maxLength={30}
224263
onChange={(e) => {
225264
changeCallback({
226265
name: {
@@ -241,7 +280,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
241280
<Form.Control
242281
required
243282
type="password"
244-
maxLength={32}
245283
value={data.password.value}
246284
isInvalid={data.password.isInvalid}
247285
onChange={(e) => {

ui/src/pages/Install/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323

2424
const Index: FC = () => {
2525
const { t } = useTranslation('translation', { keyPrefix: 'install' });
26-
const [step, setStep] = useState(1);
26+
const [step, setStep] = useState(4);
2727
const [loading, setLoading] = useState(true);
2828
const [errorData, setErrorData] = useState<{ [propName: string]: any }>({
2929
msg: '',

ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,22 @@ const SearchQuestion = ({ similarQuestions }) => {
4040
{item.accepted_answer ? (
4141
<span className="ms-3 text-success">
4242
<Icon type="bi" name="check-circle-fill" />
43-
<span className="ms-1">{item.answer_count}</span>
43+
<span className="ms-1">
44+
{t('x_answers', {
45+
keyPrefix: 'question',
46+
count: item.answer_count,
47+
})}
48+
</span>
4449
</span>
4550
) : (
4651
item.answer_count > 0 && (
47-
<span className="ms-3">
48-
<Icon
49-
type="bi"
50-
name="chat-square-text-fill"
51-
className="text-secondary"
52-
/>
53-
<span className="ms-1 text-primary">
54-
{item.answer_count}
52+
<span className="ms-3 text-secondary">
53+
<Icon type="bi" name="chat-square-text-fill" />
54+
<span className="ms-1">
55+
{t('x_answers', {
56+
keyPrefix: 'question',
57+
count: item.answer_count,
58+
})}
5559
</span>
5660
</span>
5761
)

0 commit comments

Comments
 (0)