Skip to content
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
5 changes: 5 additions & 0 deletions i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1263,12 +1263,14 @@ ui:
site_name:
label: Site name
msg: Site name cannot be empty.
msg_max_length: Site name must be at maximum 30 characters in length.
site_url:
label: Site URL
text: The address of your site.
msg:
empty: Site URL cannot be empty.
incorrect: Site URL incorrect format.
max_length: Site URL must be at maximum 512 characters in length.
contact_email:
label: Contact email
text: Email address of key contact responsible for this site.
Expand All @@ -1283,12 +1285,15 @@ ui:
label: Name
msg: Name cannot be empty.
character: 'Must use the character set "a-z", "0-9", " - . _"'
msg_max_length: Name must be at maximum 30 characters in length.
admin_password:
label: Password
text: >-
You will need this password to log in. Please store it in a secure
location.
msg: Password cannot be empty.
msg_min_length: Password must be at least 8 characters in length.
msg_max_length: Password must be at maximum 32 characters in length.
admin_email:
label: Email
text: You will need this email to log in.
Expand Down
14 changes: 9 additions & 5 deletions ui/src/components/BaseUserCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface Props {
avatarSearchStr?: string;
className?: string;
avatarClass?: string;
nameMaxWidth?: string;
}

const Index: FC<Props> = ({
Expand All @@ -22,11 +23,14 @@ const Index: FC<Props> = ({
className = 'small',
avatarSearchStr = 's=48',
showReputation = true,
nameMaxWidth = '300px',
}) => {
return (
<div className={`d-flex align-items-center text-secondary ${className}`}>
{data?.status !== 'deleted' ? (
<Link to={`/users/${data?.username}`}>
<Link
to={`/users/${data?.username}`}
className="d-flex align-items-center">
{showAvatar && (
<Avatar
avatar={data?.avatar}
Expand All @@ -36,7 +40,9 @@ const Index: FC<Props> = ({
alt={data?.display_name}
/>
)}
<span className="me-1 text-truncate-1" style={{ maxWidth: '300px' }}>
<span
className="me-1 name-ellipsis"
style={{ maxWidth: nameMaxWidth }}>
{data?.display_name}
</span>
</Link>
Expand All @@ -51,9 +57,7 @@ const Index: FC<Props> = ({
alt={data?.display_name}
/>
)}
<span className="me-1 text-truncate-1" style={{ maxWidth: '300px' }}>
{data?.display_name}
</span>
<span className="me-1 name-ellipsis">{data?.display_name}</span>
</>
)}

Expand Down
45 changes: 22 additions & 23 deletions ui/src/components/Editor/toolItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, useContext, useEffect } from 'react';
import { Dropdown, OverlayTrigger, Tooltip, Button } from 'react-bootstrap';
import { Dropdown, Button } from 'react-bootstrap';

import { EditorContext } from './EditorContext';

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

const btnRender = () => (
<OverlayTrigger placement="bottom" overlay={<Tooltip>{tip}</Tooltip>}>
<Button
variant="link"
className={`p-0 b-0 btn-no-border toolbar icon-${label} ${
disable ? 'disabled' : ''
} `}
disabled={disable}
tabIndex={-1}
onClick={(e) => {
e.preventDefault();
if (typeof onClick === 'function') {
onClick();
}
}}
onBlur={(e) => {
e.preventDefault();
if (typeof onBlur === 'function') {
onBlur();
}
}}
/>
</OverlayTrigger>
<Button
variant="link"
title={tip}
className={`p-0 b-0 btn-no-border toolbar icon-${label} ${
disable ? 'disabled' : ''
} `}
disabled={disable}
tabIndex={-1}
onClick={(e) => {
e.preventDefault();
if (typeof onClick === 'function') {
onClick();
}
}}
onBlur={(e) => {
e.preventDefault();
if (typeof onBlur === 'function') {
onBlur();
}
}}
/>
);

if (!context) {
Expand Down
7 changes: 7 additions & 0 deletions ui/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ img[src=""] {
}
}

.name-ellipsis {
display: inline-block;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}

.text-truncate-1,
.text-truncate-2,
.text-truncate-3,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Admin/Answers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const Answers: FC = () => {
<td>{li.vote_count}</td>
<td>
<Stack>
<BaseUserCard data={li.user_info} />
<BaseUserCard data={li.user_info} nameMaxWidth="200px" />

<FormatTime
className="small text-secondary"
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Admin/Questions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const Questions: FC = () => {
</td>
<td>
<Stack>
<BaseUserCard data={li.user_info} />
<BaseUserCard data={li.user_info} nameMaxWidth="130px" />
<FormatTime
className="small text-secondary"
time={li.create_time}
Expand Down
1 change: 1 addition & 0 deletions ui/src/pages/Admin/Users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ const Users: FC = () => {
avatarSearchStr="s=48"
avatarClass="me-2"
showReputation={false}
nameMaxWidth="160px"
/>
</td>
<td>{formatCount(user.rank)}</td>
Expand Down
46 changes: 42 additions & 4 deletions ui/src/pages/Install/components/FourthStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
};
}

if (site_name.value && site_name.value.length > 30) {
bol = false;
data.site_url = {
value: site_name.value,
isInvalid: true,
errorMsg: t('site_name.msg_max_length'),
};
}

if (!site_url.value) {
bol = false;
data.site_url = {
Expand All @@ -36,6 +45,7 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
errorMsg: t('site_name.msg.empty'),
};
}

const reg = /^(http|https):\/\//g;
if (site_url.value && !site_url.value.match(reg)) {
bol = false;
Expand All @@ -44,6 +54,13 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
isInvalid: true,
errorMsg: t('site_url.msg.incorrect'),
};
} else if (site_url.value.length > 512) {
bol = false;
data.site_url = {
value: site_url.value,
isInvalid: true,
errorMsg: t('site_url.msg.max_length'),
};
}

if (!contact_email.value) {
Expand Down Expand Up @@ -78,6 +95,13 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
isInvalid: true,
errorMsg: t('admin_name.character'),
};
} else if (data.name.value.length > 30) {
bol = false;
data.name = {
value: data.name.value,
isInvalid: true,
errorMsg: t('admin_name.msg_max_length'),
};
}

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

if (password.value && password.value.length < 4) {
bol = false;
data.password = {
value: data.password.value,
isInvalid: true,
errorMsg: t('admin_password.msg_min_length'),
};
}

if (password.value && password.value.length > 32) {
bol = false;
data.password = {
value: data.password.value,
isInvalid: true,
errorMsg: t('admin_password.msg_max_length'),
};
}

if (!email.value) {
bol = false;
data.email = {
Expand Down Expand Up @@ -132,7 +174,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
required
value={data.site_name.value}
isInvalid={data.site_name.isInvalid}
maxLength={30}
onChange={(e) => {
changeCallback({
site_name: {
Expand All @@ -153,7 +194,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
required
value={data.site_url.value}
isInvalid={data.site_url.isInvalid}
maxLength={512}
onChange={(e) => {
changeCallback({
site_url: {
Expand Down Expand Up @@ -220,7 +260,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
required
value={data.name.value}
isInvalid={data.name.isInvalid}
maxLength={30}
onChange={(e) => {
changeCallback({
name: {
Expand All @@ -241,7 +280,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
<Form.Control
required
type="password"
maxLength={32}
value={data.password.value}
isInvalid={data.password.isInvalid}
onChange={(e) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Install/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {

const Index: FC = () => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
const [step, setStep] = useState(1);
const [step, setStep] = useState(4);
const [loading, setLoading] = useState(true);
const [errorData, setErrorData] = useState<{ [propName: string]: any }>({
msg: '',
Expand Down
22 changes: 13 additions & 9 deletions ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@ const SearchQuestion = ({ similarQuestions }) => {
{item.accepted_answer ? (
<span className="ms-3 text-success">
<Icon type="bi" name="check-circle-fill" />
<span className="ms-1">{item.answer_count}</span>
<span className="ms-1">
{t('x_answers', {
keyPrefix: 'question',
count: item.answer_count,
})}
</span>
</span>
) : (
item.answer_count > 0 && (
<span className="ms-3">
<Icon
type="bi"
name="chat-square-text-fill"
className="text-secondary"
/>
<span className="ms-1 text-primary">
{item.answer_count}
<span className="ms-3 text-secondary">
<Icon type="bi" name="chat-square-text-fill" />
<span className="ms-1">
{t('x_answers', {
keyPrefix: 'question',
count: item.answer_count,
})}
</span>
</span>
)
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/Users/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ const Index: React.FC = () => {
tabIndex={1}
type="password"
// value={formData.pass.value}
maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) =>
handleChange({
Expand Down
2 changes: 0 additions & 2 deletions ui/src/pages/Users/PasswordReset/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ const Index: React.FC = () => {
autoComplete="off"
required
type="password"
maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) => {
handleChange({
Expand All @@ -150,7 +149,6 @@ const Index: React.FC = () => {
autoComplete="off"
required
type="password"
maxLength={32}
isInvalid={formData.passSecond.isInvalid}
onChange={(e) => {
handleChange({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ const Index: React.FC<Props> = ({ callback }) => {
autoComplete="off"
required
type="password"
maxLength={32}
isInvalid={formData.pass.isInvalid}
value={formData.pass.value}
onChange={(e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ const Index: FC = () => {
autoComplete="new-password"
required
type="password"
maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) =>
handleChange({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ const Index: FC = () => {
autoComplete="off"
required
type="password"
maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) =>
handleChange({
Expand All @@ -208,7 +207,6 @@ const Index: FC = () => {
autoComplete="off"
required
type="password"
maxLength={32}
isInvalid={formData.pass2.isInvalid}
onChange={(e) =>
handleChange({
Expand Down
4 changes: 3 additions & 1 deletion ui/src/services/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export const addComment = (params) => {
};

export const queryTags = (tag: string) => {
return request.get(`/answer/api/v1/question/tags?tag=${tag}`);
return request.get(
`/answer/api/v1/question/tags?tag=${encodeURIComponent(tag)}`,
);
};

export const useQueryAnswerInfo = (id: string) => {
Expand Down