mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
feat: document and tech params
This commit is contained in:
parent
15f80a72b8
commit
e862ab0def
@ -20,7 +20,6 @@ import Button from '@/app/components/base/button'
|
|||||||
import Input from '@/app/components/base/input'
|
import Input from '@/app/components/base/input'
|
||||||
import { ApiConnectionMod } from '@/app/components/base/icons/src/vender/solid/development'
|
import { ApiConnectionMod } from '@/app/components/base/icons/src/vender/solid/development'
|
||||||
import CheckboxWithLabel from '@/app/components/datasets/create/website/base/checkbox-with-label'
|
import CheckboxWithLabel from '@/app/components/datasets/create/website/base/checkbox-with-label'
|
||||||
import EditMetadataBatchModal from '@/app/components/datasets/metadata/edit-metadata-batch/modal'
|
|
||||||
// import DatasetMetadataDrawer from '@/app/components/datasets/metadata/dataset-metadata-drawer'
|
// import DatasetMetadataDrawer from '@/app/components/datasets/metadata/dataset-metadata-drawer'
|
||||||
import MetaDataDocument from '@/app/components/datasets/metadata/metadata-document'
|
import MetaDataDocument from '@/app/components/datasets/metadata/metadata-document'
|
||||||
// Services
|
// Services
|
||||||
@ -112,7 +111,7 @@ const Container = () => {
|
|||||||
onIsBuiltInEnabledChange={setIsBuiltInEnabled}
|
onIsBuiltInEnabledChange={setIsBuiltInEnabled}
|
||||||
onClose={() => { }}
|
onClose={() => { }}
|
||||||
/> */}
|
/> */}
|
||||||
<EditMetadataBatchModal
|
{/* <EditMetadataBatchModal
|
||||||
documentNum={20}
|
documentNum={20}
|
||||||
list={[
|
list={[
|
||||||
{
|
{
|
||||||
@ -130,7 +129,7 @@ const Container = () => {
|
|||||||
]}
|
]}
|
||||||
onHide={() => { }}
|
onHide={() => { }}
|
||||||
onChange={(list, newList, isApplyToAllSelectDocument) => { console.log(list, newList, isApplyToAllSelectDocument) }}
|
onChange={(list, newList, isApplyToAllSelectDocument) => { console.log(list, newList, isApplyToAllSelectDocument) }}
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
<div className='sticky top-0 flex justify-between pt-4 px-12 pb-2 leading-[56px] bg-background-body z-10 flex-wrap gap-y-2'>
|
<div className='sticky top-0 flex justify-between pt-4 px-12 pb-2 leading-[56px] bg-background-body z-10 flex-wrap gap-y-2'>
|
||||||
<TabSliderNew
|
<TabSliderNew
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import NoData from './no-data'
|
|||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import { RiEditLine } from '@remixicon/react'
|
import { RiEditLine } from '@remixicon/react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import Divider from '@/app/components/base/divider'
|
||||||
|
|
||||||
const MetadataDocument: FC = () => {
|
const MetadataDocument: FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -27,55 +28,94 @@ const MetadataDocument: FC = () => {
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
const [tempList, setTempList] = useState<MetadataItemWithValue[]>(list)
|
const [tempList, setTempList] = useState<MetadataItemWithValue[]>(list)
|
||||||
|
const builtInEnabled = true
|
||||||
|
const builtList = [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
name: 'OriginalfileNmae',
|
||||||
|
value: 'Steve Jobs The Man Who Thought Different.pdf',
|
||||||
|
type: DataType.string,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
name: 'Title',
|
||||||
|
value: 'PDF',
|
||||||
|
type: DataType.string,
|
||||||
|
},
|
||||||
|
]
|
||||||
const hasData = list.length > 0
|
const hasData = list.length > 0
|
||||||
|
|
||||||
|
const documentInfoList = builtList
|
||||||
|
const technicalParams = builtList
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className='space-y-4'>
|
||||||
{hasData ? (
|
{hasData ? (
|
||||||
<InfoGroup
|
<div>
|
||||||
title='Metadata'
|
<InfoGroup
|
||||||
titleTooltip='Metadata serves as a critical filter that enhances the accuracy and relevance of information retrieval. You can modify and add metadata for this document here.'
|
title='Metadata'
|
||||||
list={isEdit ? tempList : list}
|
uppercaseTitle={false}
|
||||||
headerRight={isEdit ? (
|
titleTooltip='Metadata serves as a critical filter that enhances the accuracy and relevance of information retrieval. You can modify and add metadata for this document here.'
|
||||||
<div className='flex space-x-1'>
|
list={isEdit ? tempList : list}
|
||||||
|
headerRight={isEdit ? (
|
||||||
|
<div className='flex space-x-1'>
|
||||||
|
<Button variant='ghost' size='small' onClick={() => {
|
||||||
|
setTempList(list)
|
||||||
|
setIsEdit(false)
|
||||||
|
}}>
|
||||||
|
<div>{t('common.operation.cancel')}</div>
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary' size='small' onClick={() => {
|
||||||
|
setIsEdit(false)
|
||||||
|
setList(tempList)
|
||||||
|
}}>
|
||||||
|
<div>{t('common.operation.save')}</div>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<Button variant='ghost' size='small' onClick={() => {
|
<Button variant='ghost' size='small' onClick={() => {
|
||||||
setTempList(list)
|
setTempList(list)
|
||||||
setIsEdit(false)
|
setIsEdit(true)
|
||||||
}}>
|
}}>
|
||||||
<div>{t('common.operation.cancel')}</div>
|
<RiEditLine className='mr-1 size-3.5 text-text-tertiary cursor-pointer' />
|
||||||
|
<div>{t('common.operation.edit')}</div>
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant='primary' size='small' onClick={() => {
|
)}
|
||||||
setIsEdit(false)
|
isEdit={isEdit}
|
||||||
setList(tempList)
|
contentClassName='mt-5'
|
||||||
}}>
|
onChange={(item) => {
|
||||||
<div>{t('common.operation.save')}</div>
|
const newList = tempList.map(i => (i.name === item.name ? item : i))
|
||||||
</Button>
|
setList(newList)
|
||||||
</div>
|
}}
|
||||||
) : (
|
onDelete={(item) => {
|
||||||
<Button variant='ghost' size='small' onClick={() => {
|
const newList = tempList.filter(i => i.name !== item.name)
|
||||||
setTempList(list)
|
setList(newList)
|
||||||
setIsEdit(true)
|
}}
|
||||||
}}>
|
onAdd={() => {
|
||||||
<RiEditLine className='mr-1 size-3.5 text-text-tertiary cursor-pointer' />
|
}}
|
||||||
<div>{t('common.operation.edit')}</div>
|
/>
|
||||||
</Button>
|
{builtInEnabled && (
|
||||||
|
<>
|
||||||
|
<Divider className='my-3' bgStyle='gradient' />
|
||||||
|
<InfoGroup
|
||||||
|
noHeader
|
||||||
|
titleTooltip='Built-in metadata is system-generated metadata that is automatically added to the document. You can enable or disable built-in metadata here.'
|
||||||
|
list={builtList}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
isEdit={isEdit}
|
</div>
|
||||||
contentClassName='mt-5'
|
|
||||||
onChange={(item) => {
|
|
||||||
const newList = tempList.map(i => (i.name === item.name ? item : i))
|
|
||||||
setList(newList)
|
|
||||||
}}
|
|
||||||
onDelete={(item) => {
|
|
||||||
const newList = tempList.filter(i => i.name !== item.name)
|
|
||||||
setList(newList)
|
|
||||||
}}
|
|
||||||
onAdd={() => {
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
) : (
|
) : (
|
||||||
<NoData onStart={() => { }} />
|
<NoData onStart={() => { }} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<InfoGroup
|
||||||
|
title='Document Information'
|
||||||
|
list={builtList}
|
||||||
|
/>
|
||||||
|
<InfoGroup
|
||||||
|
title='Technical Parameters'
|
||||||
|
list={builtList}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import React from 'react'
|
|||||||
import type { MetadataItemWithValue } from '../types'
|
import type { MetadataItemWithValue } from '../types'
|
||||||
import Field from './field'
|
import Field from './field'
|
||||||
import InputCombined from '../edit-metadata-batch/input-combined'
|
import InputCombined from '../edit-metadata-batch/input-combined'
|
||||||
import { RiDeleteBinLine } from '@remixicon/react'
|
import { RiDeleteBinLine, RiQuestionLine } from '@remixicon/react'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import Divider from '@/app/components/base/divider'
|
import Divider from '@/app/components/base/divider'
|
||||||
@ -12,7 +12,9 @@ import SelectMetadataModal from '../select-metadata-modal'
|
|||||||
import AddMetadataButton from '../add-metadata-button'
|
import AddMetadataButton from '../add-metadata-button'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string
|
noHeader?: boolean
|
||||||
|
title?: string
|
||||||
|
uppercaseTitle?: boolean
|
||||||
titleTooltip?: string
|
titleTooltip?: string
|
||||||
headerRight?: React.ReactNode
|
headerRight?: React.ReactNode
|
||||||
contentClassName?: string
|
contentClassName?: string
|
||||||
@ -24,7 +26,9 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const InfoGroup: FC<Props> = ({
|
const InfoGroup: FC<Props> = ({
|
||||||
|
noHeader,
|
||||||
title,
|
title,
|
||||||
|
uppercaseTitle = true,
|
||||||
titleTooltip,
|
titleTooltip,
|
||||||
headerRight,
|
headerRight,
|
||||||
contentClassName,
|
contentClassName,
|
||||||
@ -36,18 +40,23 @@ const InfoGroup: FC<Props> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className='bg-white'>
|
<div className='bg-white'>
|
||||||
<div className='flex items-center justify-between'>
|
{!noHeader && (
|
||||||
<div className='flex items-center space-x-1'>
|
<div className='flex items-center justify-between'>
|
||||||
<div className='system-xs-medium text-text-secondary'>{title}</div>
|
<div className='flex items-center space-x-1'>
|
||||||
{titleTooltip && (
|
<div className={cn('text-text-secondary', uppercaseTitle ? 'system-xs-semibold-uppercase' : 'system-md-semibold')}>{title}</div>
|
||||||
<Tooltip popupContent={titleTooltip} />
|
{titleTooltip && (
|
||||||
)}
|
<Tooltip popupContent={<div className='max-w-[240px]'>{titleTooltip}</div>}>
|
||||||
</div>
|
<RiQuestionLine className='size-3.5 text-text-tertiary' />
|
||||||
{headerRight}
|
</Tooltip>
|
||||||
{/* <div className='flex px-1.5 rounded-md hover:bg-components-button-tertiary-bg-hover items-center h-6 space-x-1 cursor-pointer' onClick={() => setIsEdit(true)}>
|
)}
|
||||||
|
</div>
|
||||||
|
{headerRight}
|
||||||
|
{/* <div className='flex px-1.5 rounded-md hover:bg-components-button-tertiary-bg-hover items-center h-6 space-x-1 cursor-pointer' onClick={() => setIsEdit(true)}>
|
||||||
</div> */}
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
<div className={cn('mt-3 space-y-1', contentClassName)}>
|
)}
|
||||||
|
|
||||||
|
<div className={cn('mt-3 space-y-1', !noHeader && 'mt-0', contentClassName)}>
|
||||||
{isEdit && (
|
{isEdit && (
|
||||||
<div>
|
<div>
|
||||||
<SelectMetadataModal
|
<SelectMetadataModal
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user