mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/ui-0.5.0' of git.backyard.segmentfault.com:opensource/answer into feat/ui-0.5.0
This commit is contained in:
commit
7d27edf79b
|
@ -1,4 +1,4 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
@ -10,7 +10,7 @@ import { marked } from 'marked';
|
|||
import * as Types from '@/common/interface';
|
||||
import { Modal } from '@/components';
|
||||
import { usePageUsers, useReportModal } from '@/hooks';
|
||||
import { matchedUsers, parseUserInfo } from '@/utils';
|
||||
import { matchedUsers, parseUserInfo, scrollTop } from '@/utils';
|
||||
import { tryNormalLogged } from '@/utils/guard';
|
||||
import {
|
||||
useQueryComments,
|
||||
|
@ -40,6 +40,13 @@ const Comment = ({ objectId, mode, commentId }) => {
|
|||
const reportModal = useReportModal();
|
||||
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'comment' });
|
||||
const scrollCallback = useCallback((el, co) => {
|
||||
if (pageIndex === 0 && co.comment_id === commentId) {
|
||||
setTimeout(() => {
|
||||
scrollTop(el);
|
||||
}, 100);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!data) {
|
||||
|
@ -224,6 +231,9 @@ const Comment = ({ objectId, mode, commentId }) => {
|
|||
return (
|
||||
<div
|
||||
key={item.comment_id}
|
||||
ref={(el) => {
|
||||
scrollCallback(el, item);
|
||||
}}
|
||||
className={classNames(
|
||||
'border-bottom py-2 comment-item',
|
||||
index === 0 && 'border-top',
|
||||
|
|
|
@ -225,6 +225,24 @@ const SchemaForm: FC<IProps> = ({
|
|||
}
|
||||
};
|
||||
|
||||
const handleCheckboxChange = (
|
||||
e: React.ChangeEvent<HTMLInputElement>,
|
||||
index: number,
|
||||
) => {
|
||||
const { name } = e.target;
|
||||
const data = {
|
||||
...formData,
|
||||
[name]: {
|
||||
...formData[name],
|
||||
value: schema.properties[name]?.enum?.[index],
|
||||
isInvalid: false,
|
||||
},
|
||||
};
|
||||
if (onChange instanceof Function) {
|
||||
onChange(data);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Form noValidate onSubmit={handleSubmit}>
|
||||
{keys.map((key) => {
|
||||
|
@ -265,13 +283,14 @@ const SchemaForm: FC<IProps> = ({
|
|||
inline
|
||||
required
|
||||
type={widget}
|
||||
name={title}
|
||||
name={key}
|
||||
id={String(item)}
|
||||
label={properties[key].enumNames?.[index]}
|
||||
checked={formData[key]?.value === item}
|
||||
feedback={formData[key]?.errorMsg}
|
||||
feedbackType="invalid"
|
||||
isInvalid={formData[key].isInvalid}
|
||||
onChange={(e) => handleCheckboxChange(e, index)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
|
|
@ -37,7 +37,7 @@ const Smtp: FC = () => {
|
|||
type: 'boolean',
|
||||
title: t('encryption.label'),
|
||||
description: t('encryption.text'),
|
||||
enum: [true, false],
|
||||
enum: ['SSL', ''],
|
||||
enumNames: ['SSL', ''],
|
||||
},
|
||||
smtp_port: {
|
||||
|
|
Loading…
Reference in New Issue