chore: action i18n and remove confirm

pull/12097/head
Joel 1 year ago
parent 768073ddac
commit 91666c4394

@ -1,8 +1,12 @@
import React, { type FC } from 'react' import React, { type FC } from 'react'
import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react' import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import { useBoolean } from 'ahooks'
import Divider from '@/app/components/base/divider' import Divider from '@/app/components/base/divider'
import classNames from '@/utils/classnames' import classNames from '@/utils/classnames'
import Confirm from '@/app/components/base/confirm'
const i18nPrefix = 'dataset.batchAction'
type IBatchActionProps = { type IBatchActionProps = {
className?: string className?: string
selectedIds: string[] selectedIds: string[]
@ -22,6 +26,11 @@ const BatchAction: FC<IBatchActionProps> = ({
onBatchDelete, onBatchDelete,
onCancel, onCancel,
}) => { }) => {
const { t } = useTranslation()
const [isShowDeleteConfirm, {
setTrue: showDeleteConfirm,
setFalse: hideDeleteConfirm,
}] = useBoolean(false)
return ( return (
<div className={classNames('w-full flex justify-center gap-x-2', className)}> <div className={classNames('w-full flex justify-center gap-x-2', className)}>
<div className='flex items-center gap-x-1 p-1 rounded-[10px] bg-components-actionbar-bg-accent border border-components-actionbar-border-accent shadow-xl shadow-shadow-shadow-5 backdrop-blur-[5px]'> <div className='flex items-center gap-x-1 p-1 rounded-[10px] bg-components-actionbar-bg-accent border border-components-actionbar-border-accent shadow-xl shadow-shadow-shadow-5 backdrop-blur-[5px]'>
@ -29,41 +38,53 @@ const BatchAction: FC<IBatchActionProps> = ({
<span className='w-5 h-5 flex items-center justify-center px-1 py-0.5 bg-text-accent rounded-md text-text-primary-on-surface text-xs font-medium'> <span className='w-5 h-5 flex items-center justify-center px-1 py-0.5 bg-text-accent rounded-md text-text-primary-on-surface text-xs font-medium'>
{selectedIds.length} {selectedIds.length}
</span> </span>
<span className='text-text-accent text-[13px] font-semibold leading-[16px]'>Selected</span> <span className='text-text-accent text-[13px] font-semibold leading-[16px]'>{t(`${i18nPrefix}.selected`)}</span>
</div> </div>
<Divider type='vertical' className='mx-0.5 h-3.5 bg-divider-regular' /> <Divider type='vertical' className='mx-0.5 h-3.5 bg-divider-regular' />
<div className='flex items-center gap-x-0.5 px-3 py-2'> <div className='flex items-center gap-x-0.5 px-3 py-2'>
<RiCheckboxCircleLine className='w-4 h-4 text-components-button-ghost-text' /> <RiCheckboxCircleLine className='w-4 h-4 text-components-button-ghost-text' />
<button className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchEnable}> <button className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchEnable}>
Enable {t(`${i18nPrefix}.enable`)}
</button> </button>
</div> </div>
<div className='flex items-center gap-x-0.5 px-3 py-2'> <div className='flex items-center gap-x-0.5 px-3 py-2'>
<RiCloseCircleLine className='w-4 h-4 text-components-button-ghost-text' /> <RiCloseCircleLine className='w-4 h-4 text-components-button-ghost-text' />
<button className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchDisable}> <button className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchDisable}>
Disable {t(`${i18nPrefix}.disable`)}
</button> </button>
</div> </div>
{onArchive && ( {onArchive && (
<div className='flex items-center gap-x-0.5 px-3 py-2'> <div className='flex items-center gap-x-0.5 px-3 py-2'>
<RiArchive2Line className='w-4 h-4 text-components-button-ghost-text' /> <RiArchive2Line className='w-4 h-4 text-components-button-ghost-text' />
<button className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchDisable}> <button className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchDisable}>
Archive {t(`${i18nPrefix}.archive`)}
</button> </button>
</div> </div>
)} )}
<div className='flex items-center gap-x-0.5 px-3 py-2'> <div className='flex items-center gap-x-0.5 px-3 py-2'>
<RiDeleteBinLine className='w-4 h-4 text-components-button-destructive-ghost-text' /> <RiDeleteBinLine className='w-4 h-4 text-components-button-destructive-ghost-text' />
<button className='px-0.5 text-components-button-destructive-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchDelete}> <button className='px-0.5 text-components-button-destructive-ghost-text text-[13px] font-medium leading-[16px]' onClick={showDeleteConfirm}>
Delete {t(`${i18nPrefix}.delete`)}
</button> </button>
</div> </div>
<Divider type='vertical' className='mx-0.5 h-3.5 bg-divider-regular' /> <Divider type='vertical' className='mx-0.5 h-3.5 bg-divider-regular' />
<button className='px-3.5 py-2 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onCancel}> <button className='px-3.5 py-2 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onCancel}>
Cancel {t(`${i18nPrefix}.cancel`)}
</button> </button>
</div> </div>
{
isShowDeleteConfirm && (
<Confirm
isShow
title={t('datasetDocuments.list.delete.title')}
content={t('datasetDocuments.list.delete.content')}
confirmText={t('common.operation.sure')}
onConfirm={onBatchDelete}
onCancel={hideDeleteConfirm}
/>
)
}
</div> </div>
) )
} }

@ -150,6 +150,14 @@ const translation = {
nTo1RetrievalLegacy: 'N-to-1 retrieval will be officially deprecated from September. It is recommended to use the latest Multi-path retrieval to obtain better results. ', nTo1RetrievalLegacy: 'N-to-1 retrieval will be officially deprecated from September. It is recommended to use the latest Multi-path retrieval to obtain better results. ',
nTo1RetrievalLegacyLink: 'Learn more', nTo1RetrievalLegacyLink: 'Learn more',
nTo1RetrievalLegacyLinkText: ' N-to-1 retrieval will be officially deprecated in September.', nTo1RetrievalLegacyLinkText: ' N-to-1 retrieval will be officially deprecated in September.',
batchAction: {
selected: 'Selected',
enable: 'Enable',
disable: 'Disable',
archive: 'Archive',
delete: 'Delete',
cancel: 'Cancel',
},
} }
export default translation export default translation

@ -150,6 +150,14 @@ const translation = {
nTo1RetrievalLegacy: '9 月 1 日起我们将不再提供此能力,推荐使用最新的多路召回获得更好的检索效果。', nTo1RetrievalLegacy: '9 月 1 日起我们将不再提供此能力,推荐使用最新的多路召回获得更好的检索效果。',
nTo1RetrievalLegacyLink: '了解更多', nTo1RetrievalLegacyLink: '了解更多',
nTo1RetrievalLegacyLinkText: '9 月 1 日起我们将不再提供此能力。', nTo1RetrievalLegacyLinkText: '9 月 1 日起我们将不再提供此能力。',
batchAction: {
selected: '已选择',
enable: '启用',
disable: '禁用',
archive: '归档',
delete: '删除',
cancel: '取消',
},
} }
export default translation export default translation

Loading…
Cancel
Save