feat: batch edit modal open
This commit is contained in:
parent
6a02b44e17
commit
b36ef4d97b
@ -1,5 +1,5 @@
|
|||||||
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, RiDraftLine } from '@remixicon/react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useBoolean } from 'ahooks'
|
import { useBoolean } from 'ahooks'
|
||||||
import Divider from '@/app/components/base/divider'
|
import Divider from '@/app/components/base/divider'
|
||||||
@ -14,6 +14,7 @@ type IBatchActionProps = {
|
|||||||
onBatchDisable: () => void
|
onBatchDisable: () => void
|
||||||
onBatchDelete: () => Promise<void>
|
onBatchDelete: () => Promise<void>
|
||||||
onArchive?: () => void
|
onArchive?: () => void
|
||||||
|
onEditMetadata?: () => void
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ const BatchAction: FC<IBatchActionProps> = ({
|
|||||||
onBatchDisable,
|
onBatchDisable,
|
||||||
onArchive,
|
onArchive,
|
||||||
onBatchDelete,
|
onBatchDelete,
|
||||||
|
onEditMetadata,
|
||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -62,6 +64,15 @@ const BatchAction: FC<IBatchActionProps> = ({
|
|||||||
{t(`${i18nPrefix}.disable`)}
|
{t(`${i18nPrefix}.disable`)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{onEditMetadata && (
|
||||||
|
<div className='flex items-center gap-x-0.5 px-3 py-2'>
|
||||||
|
<RiDraftLine className='w-4 h-4 text-components-button-ghost-text' />
|
||||||
|
<button type='button' className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onEditMetadata}>
|
||||||
|
{t('dataset.metadata.metadata')}
|
||||||
|
</button>
|
||||||
|
</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' />
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import cn from '@/utils/classnames'
|
|||||||
import { useInvalidDocumentDetailKey } from '@/service/knowledge/use-document'
|
import { useInvalidDocumentDetailKey } from '@/service/knowledge/use-document'
|
||||||
import { useInvalid } from '@/service/use-base'
|
import { useInvalid } from '@/service/use-base'
|
||||||
import { useChildSegmentListKey, useSegmentListKey } from '@/service/knowledge/use-segment'
|
import { useChildSegmentListKey, useSegmentListKey } from '@/service/knowledge/use-segment'
|
||||||
import useEditDocumentMetadata from '../metadata/hooks/use-edit-document-metadata'
|
import useEditDocumentMetadata from '../metadata/hooks/use-edit-dataset-metadata'
|
||||||
import DatasetMetadataDrawer from '../metadata/metadata-dataset/dataset-metadata-drawer'
|
import DatasetMetadataDrawer from '../metadata/metadata-dataset/dataset-metadata-drawer'
|
||||||
|
|
||||||
const FolderPlusIcon = ({ className }: React.SVGProps<SVGElement>) => {
|
const FolderPlusIcon = ({ className }: React.SVGProps<SVGElement>) => {
|
||||||
|
|||||||
@ -45,6 +45,8 @@ import Pagination from '@/app/components/base/pagination'
|
|||||||
import Checkbox from '@/app/components/base/checkbox'
|
import Checkbox from '@/app/components/base/checkbox'
|
||||||
import { useDocumentArchive, useDocumentDelete, useDocumentDisable, useDocumentEnable, useDocumentUnArchive, useSyncDocument, useSyncWebsite } from '@/service/knowledge/use-document'
|
import { useDocumentArchive, useDocumentDelete, useDocumentDisable, useDocumentEnable, useDocumentUnArchive, useSyncDocument, useSyncWebsite } from '@/service/knowledge/use-document'
|
||||||
import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type'
|
import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type'
|
||||||
|
import useBatchEditDocumentMetadata from '../metadata/hooks/use-batch-edit-document-metadata'
|
||||||
|
import EditMetadataBatchModal from '@/app/components/datasets/metadata/edit-metadata-batch/modal'
|
||||||
|
|
||||||
export const useIndexStatus = () => {
|
export const useIndexStatus = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -424,6 +426,7 @@ const DocumentList: FC<IDocumentListProps> = ({
|
|||||||
const isQAMode = chunkingMode === ChunkingMode.qa
|
const isQAMode = chunkingMode === ChunkingMode.qa
|
||||||
const [localDocs, setLocalDocs] = useState<LocalDoc[]>(documents)
|
const [localDocs, setLocalDocs] = useState<LocalDoc[]>(documents)
|
||||||
const [enableSort, setEnableSort] = useState(true)
|
const [enableSort, setEnableSort] = useState(true)
|
||||||
|
const { isShowEditModal, showEditModal, hideEditModal } = useBatchEditDocumentMetadata()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLocalDocs(documents)
|
setLocalDocs(documents)
|
||||||
@ -615,7 +618,7 @@ const DocumentList: FC<IDocumentListProps> = ({
|
|||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{(selectedIds.length > 0) && (
|
{/* {(selectedIds.length > 0) && ( */}
|
||||||
<BatchAction
|
<BatchAction
|
||||||
className='absolute left-0 bottom-16 z-20'
|
className='absolute left-0 bottom-16 z-20'
|
||||||
selectedIds={selectedIds}
|
selectedIds={selectedIds}
|
||||||
@ -623,11 +626,12 @@ const DocumentList: FC<IDocumentListProps> = ({
|
|||||||
onBatchEnable={handleAction(DocumentActionType.enable)}
|
onBatchEnable={handleAction(DocumentActionType.enable)}
|
||||||
onBatchDisable={handleAction(DocumentActionType.disable)}
|
onBatchDisable={handleAction(DocumentActionType.disable)}
|
||||||
onBatchDelete={handleAction(DocumentActionType.delete)}
|
onBatchDelete={handleAction(DocumentActionType.delete)}
|
||||||
|
onEditMetadata={showEditModal}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
onSelectedIdChange([])
|
onSelectedIdChange([])
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
{/* )} */}
|
||||||
{/* Show Pagination only if the total is more than the limit */}
|
{/* Show Pagination only if the total is more than the limit */}
|
||||||
{pagination.total && pagination.total > (pagination.limit || 10) && (
|
{pagination.total && pagination.total > (pagination.limit || 10) && (
|
||||||
<Pagination
|
<Pagination
|
||||||
@ -645,6 +649,15 @@ const DocumentList: FC<IDocumentListProps> = ({
|
|||||||
onSaved={handleRenamed}
|
onSaved={handleRenamed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{isShowEditModal && (
|
||||||
|
<EditMetadataBatchModal
|
||||||
|
documentNum={selectedIds.length}
|
||||||
|
list={[]}
|
||||||
|
onChange={() => { }}
|
||||||
|
onHide={hideEditModal}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
import { useBoolean } from 'ahooks'
|
||||||
|
|
||||||
|
const useBatchEditDocumentMetadata = () => {
|
||||||
|
const [isShowEditModal, {
|
||||||
|
setTrue: showEditModal,
|
||||||
|
setFalse: hideEditModal,
|
||||||
|
}] = useBoolean(false)
|
||||||
|
|
||||||
|
return {
|
||||||
|
isShowEditModal,
|
||||||
|
showEditModal,
|
||||||
|
hideEditModal,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useBatchEditDocumentMetadata
|
||||||
@ -4,7 +4,7 @@ import type { DataSet } from '@/models/datasets'
|
|||||||
import { useCallback, useState } from 'react'
|
import { useCallback, useState } from 'react'
|
||||||
import type { BuiltInMetadataItem, MetadataItemWithValueLength } from '../types'
|
import type { BuiltInMetadataItem, MetadataItemWithValueLength } from '../types'
|
||||||
|
|
||||||
const useEditDocumentMetadata = ({
|
const useEditDatasetMetadata = ({
|
||||||
datasetId,
|
datasetId,
|
||||||
dataset,
|
dataset,
|
||||||
}: {
|
}: {
|
||||||
@ -53,4 +53,4 @@ const useEditDocumentMetadata = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useEditDocumentMetadata
|
export default useEditDatasetMetadata
|
||||||
Loading…
x
Reference in New Issue
Block a user