fix: i18n & option card props

pull/12097/head
AkaraChen 1 year ago
parent 3d283a11b6
commit ec1c03f0a3

@ -75,6 +75,10 @@
cursor: pointer; cursor: pointer;
} }
.disabled {
cursor: not-allowed;
}
.indexItem.disabled:hover { .indexItem.disabled:hover {
background-color: #fcfcfd; background-color: #fcfcfd;
border-color: #f2f4f7; border-color: #f2f4f7;

@ -505,6 +505,9 @@ const StepTwo = ({
} }
const changeToEconomicalType = () => { const changeToEconomicalType = () => {
if (docForm === ChuckingMode.parentChild)
return
if (!hasSetIndexType) { if (!hasSetIndexType) {
setIndexType(IndexingType.ECONOMICAL) setIndexType(IndexingType.ECONOMICAL)
if (docForm === ChuckingMode.qa) if (docForm === ChuckingMode.qa)
@ -557,8 +560,12 @@ const StepTwo = ({
icon={<Image src={SettingCog} alt={t('datasetCreation.stepTwo.general')} />} icon={<Image src={SettingCog} alt={t('datasetCreation.stepTwo.general')} />}
activeHeaderClassName='bg-gradient-to-r from-[#EFF0F9] to-[#F9FAFB]' activeHeaderClassName='bg-gradient-to-r from-[#EFF0F9] to-[#F9FAFB]'
description={t('datasetCreation.stepTwo.generalTip')} description={t('datasetCreation.stepTwo.generalTip')}
isActive={docForm === ChuckingMode.qa || docForm === ChuckingMode.text} isActive={
onSelect={() => handleChangeDocform(ChuckingMode.text)} [ChuckingMode.text, ChuckingMode.qa].includes(docForm)
}
onSwitched={() =>
handleChangeDocform(ChuckingMode.text)
}
actions={ actions={
<> <>
<Button variant={'secondary-accent'} onClick={() => updatePreview()}> <Button variant={'secondary-accent'} onClick={() => updatePreview()}>
@ -653,7 +660,7 @@ const StepTwo = ({
activeHeaderClassName='bg-gradient-to-r from-[#F9F1EE] to-[#F9FAFB]' activeHeaderClassName='bg-gradient-to-r from-[#F9F1EE] to-[#F9FAFB]'
description={t('datasetCreation.stepTwo.parentChildTip')} description={t('datasetCreation.stepTwo.parentChildTip')}
isActive={docForm === ChuckingMode.parentChild} isActive={docForm === ChuckingMode.parentChild}
onSelected={() => handleChangeDocform(ChuckingMode.parentChild)} onSwitched={() => handleChangeDocform(ChuckingMode.parentChild)}
actions={ actions={
<> <>
<Button variant={'secondary-accent'} onClick={() => updatePreview()}> <Button variant={'secondary-accent'} onClick={() => updatePreview()}>
@ -817,6 +824,7 @@ const StepTwo = ({
!hasSetIndexType && indexType === IndexingType.ECONOMICAL && s.active, !hasSetIndexType && indexType === IndexingType.ECONOMICAL && s.active,
hasSetIndexType && s.disabled, hasSetIndexType && s.disabled,
hasSetIndexType && '!w-full !min-h-[96px]', hasSetIndexType && '!w-full !min-h-[96px]',
docForm === ChuckingMode.parentChild && s.disabled,
)} )}
onClick={changeToEconomicalType} onClick={changeToEconomicalType}
> >
@ -921,7 +929,10 @@ const StepTwo = ({
> >
<div className='flex items-center gap-2'> <div className='flex items-center gap-2'>
<DocumentPicker datasetId={datasetId || ''} value={{}} onChange={console.log} /> <DocumentPicker datasetId={datasetId || ''} value={{}} onChange={console.log} />
<Badge text='276 Estimated chunks' /> <Badge text={t(
'datasetCreation.stepTwo.previewChunkCount', {
count: estimate?.preview.length || estimate?.qa_preview?.length || 0,
}) as string} />
</div> </div>
</PreviewHeader>} </PreviewHeader>}
className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll')} className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll')}
@ -973,7 +984,9 @@ const StepTwo = ({
<div className='h-full w-full flex items-center justify-center'> <div className='h-full w-full flex items-center justify-center'>
<div className='flex flex-col items-center justify-center gap-3'> <div className='flex flex-col items-center justify-center gap-3'>
<RiSearchEyeLine className='size-10 text-text-empty-state-icon' /> <RiSearchEyeLine className='size-10 text-text-empty-state-icon' />
<p className='text-sm text-text-tertiary'>{'Click the \'Preview Chunk\' button on the left to load the preview'}</p> <p className='text-sm text-text-tertiary'>
{t('datasetCreation.stepTwo.previewChunkTip')}
</p>
</div> </div>
</div> </div>
)} )}

@ -50,11 +50,11 @@ type OptionCardProps = {
isActive?: boolean isActive?: boolean
actions?: ReactNode actions?: ReactNode
effectImg?: string effectImg?: string
onSelected?: () => void onSwitched?: () => void
} & Omit<ComponentProps<'div'>, 'title'> } & Omit<ComponentProps<'div'>, 'title'>
export const OptionCard: FC<OptionCardProps> = (props) => { export const OptionCard: FC<OptionCardProps> = (props) => {
const { icon, className, title, description, isActive, children, actions, activeHeaderClassName, style, effectImg, onSelected, onClick, ...rest } = props const { icon, className, title, description, isActive, children, actions, activeHeaderClassName, style, effectImg, onSwitched, onClick, ...rest } = props
return <div return <div
className={classNames( className={classNames(
'rounded-xl', 'rounded-xl',
@ -67,7 +67,7 @@ export const OptionCard: FC<OptionCardProps> = (props) => {
}} }}
onClick={(e) => { onClick={(e) => {
if (!isActive) if (!isActive)
onSelected?.() onSwitched?.()
onClick?.(e) onClick?.(e)
}} }}
{...rest}> {...rest}>

@ -164,6 +164,8 @@ const translation = {
indexSettingTip: 'To change the index method & embedding model, please go to the ', indexSettingTip: 'To change the index method & embedding model, please go to the ',
retrievalSettingTip: 'To change the retrieval setting, please go to the ', retrievalSettingTip: 'To change the retrieval setting, please go to the ',
datasetSettingLink: 'Knowledge settings.', datasetSettingLink: 'Knowledge settings.',
previewChunkTip: 'Click the \'Preview Chunk\' button on the left to load the preview',
previewChunkCount: '{{count}} Estimated chunks',
}, },
stepThree: { stepThree: {
creationTitle: '🎉 Knowledge created', creationTitle: '🎉 Knowledge created',

@ -164,6 +164,8 @@ const translation = {
indexSettingTip: '要更改索引方法和 embedding 模型,请转到', indexSettingTip: '要更改索引方法和 embedding 模型,请转到',
retrievalSettingTip: '要更改检索方法,请转到', retrievalSettingTip: '要更改检索方法,请转到',
datasetSettingLink: '知识库设置。', datasetSettingLink: '知识库设置。',
previewChunkTip: '点击左侧的“预览块”按钮来加载预览',
previewChunkCount: '{{count}} 预估块',
}, },
stepThree: { stepThree: {
creationTitle: '🎉 知识库已创建', creationTitle: '🎉 知识库已创建',

Loading…
Cancel
Save