mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
feat: batch action ui
This commit is contained in:
@ -1,14 +1,15 @@
|
|||||||
import React, { type FC } from 'react'
|
import React, { type FC } from 'react'
|
||||||
import { RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react'
|
import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react'
|
||||||
import Divider from '@/app/components/base/divider'
|
import Divider from '@/app/components/base/divider'
|
||||||
import classNames from '@/utils/classnames'
|
import classNames from '@/utils/classnames'
|
||||||
|
|
||||||
type IBatchActionProps = {
|
type IBatchActionProps = {
|
||||||
className?: string
|
className?: string
|
||||||
selectedIds: string[]
|
selectedIds: string[]
|
||||||
onBatchEnable: () => Promise<void>
|
onBatchEnable: () => void
|
||||||
onBatchDisable: () => Promise<void>
|
onBatchDisable: () => void
|
||||||
onBatchDelete: () => Promise<void>
|
onBatchDelete: () => void
|
||||||
|
onArchive?: () => void
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ const BatchAction: FC<IBatchActionProps> = ({
|
|||||||
selectedIds,
|
selectedIds,
|
||||||
onBatchEnable,
|
onBatchEnable,
|
||||||
onBatchDisable,
|
onBatchDisable,
|
||||||
|
onArchive,
|
||||||
onBatchDelete,
|
onBatchDelete,
|
||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
@ -42,15 +44,24 @@ const BatchAction: FC<IBatchActionProps> = ({
|
|||||||
Disable
|
Disable
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{onArchive && (
|
||||||
|
<div className='flex items-center gap-x-0.5 px-3 py-2'>
|
||||||
|
<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}>
|
||||||
|
Archive
|
||||||
|
</button>
|
||||||
|
</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={onBatchDelete}>
|
||||||
Delete
|
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
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel'
|
|||||||
import ChunkingModeLabel from '../common/chunking-mode-label'
|
import ChunkingModeLabel from '../common/chunking-mode-label'
|
||||||
import s from './style.module.css'
|
import s from './style.module.css'
|
||||||
import RenameModal from './rename-modal'
|
import RenameModal from './rename-modal'
|
||||||
|
import BatchAction from './detail/completed/batch-action'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import Switch from '@/app/components/base/switch'
|
import Switch from '@/app/components/base/switch'
|
||||||
import Divider from '@/app/components/base/divider'
|
import Divider from '@/app/components/base/divider'
|
||||||
@ -576,6 +577,25 @@ const DocumentList: FC<IDocumentListProps> = ({
|
|||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{(selectedIds.length > 0) && (
|
||||||
|
<BatchAction
|
||||||
|
className='absolute left-0 bottom-16 z-20'
|
||||||
|
selectedIds={selectedIds}
|
||||||
|
onArchive={() => { }}
|
||||||
|
onBatchEnable={() => {
|
||||||
|
|
||||||
|
}}
|
||||||
|
onBatchDisable={() => {
|
||||||
|
|
||||||
|
}}
|
||||||
|
onBatchDelete={() => {
|
||||||
|
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user