mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 09:58:04 +08:00
chore(web): new lint setup (#30020)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import type { MetadataItemWithEdit } from '../types'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import Label from './label'
|
||||
import InputCombined from './input-combined'
|
||||
import { RiIndeterminateCircleLine } from '@remixicon/react'
|
||||
import React from 'react'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import InputCombined from './input-combined'
|
||||
import Label from './label'
|
||||
|
||||
type Props = {
|
||||
className?: string
|
||||
@ -36,7 +36,7 @@ const AddRow: FC<Props> = ({
|
||||
}
|
||||
onClick={onRemove}
|
||||
>
|
||||
<RiIndeterminateCircleLine className='size-4' />
|
||||
<RiIndeterminateCircleLine className="size-4" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { type MetadataItemWithEdit, UpdateType } from '../types'
|
||||
import Label from './label'
|
||||
import type { MetadataItemWithEdit } from '../types'
|
||||
import { RiDeleteBinLine } from '@remixicon/react'
|
||||
import React from 'react'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import InputHasSetMultipleValue from './input-has-set-multiple-value'
|
||||
import InputCombined from './input-combined'
|
||||
import { UpdateType } from '../types'
|
||||
import EditedBeacon from './edited-beacon'
|
||||
import InputCombined from './input-combined'
|
||||
import InputHasSetMultipleValue from './input-has-set-multiple-value'
|
||||
import Label from './label'
|
||||
|
||||
type Props = {
|
||||
payload: MetadataItemWithEdit
|
||||
@ -25,30 +26,35 @@ const EditMetadatabatchItem: FC<Props> = ({
|
||||
const isUpdated = payload.isUpdated
|
||||
const isDeleted = payload.updateType === UpdateType.delete
|
||||
return (
|
||||
<div className='flex h-6 items-center space-x-0.5'>
|
||||
{isUpdated ? <EditedBeacon onReset={() => onReset(payload.id)} /> : <div className='size-4 shrink-0' />}
|
||||
<div className="flex h-6 items-center space-x-0.5">
|
||||
{isUpdated ? <EditedBeacon onReset={() => onReset(payload.id)} /> : <div className="size-4 shrink-0" />}
|
||||
<Label text={payload.name} isDeleted={isDeleted} />
|
||||
{payload.isMultipleValue
|
||||
? <InputHasSetMultipleValue
|
||||
onClear={() => onChange({ ...payload, value: null, isMultipleValue: false })}
|
||||
readOnly={isDeleted}
|
||||
/>
|
||||
: <InputCombined
|
||||
type={payload.type}
|
||||
value={payload.value}
|
||||
onChange={v => onChange({ ...payload, value: v as string })}
|
||||
readOnly={isDeleted}
|
||||
/>}
|
||||
? (
|
||||
<InputHasSetMultipleValue
|
||||
onClear={() => onChange({ ...payload, value: null, isMultipleValue: false })}
|
||||
readOnly={isDeleted}
|
||||
/>
|
||||
)
|
||||
: (
|
||||
<InputCombined
|
||||
type={payload.type}
|
||||
value={payload.value}
|
||||
onChange={v => onChange({ ...payload, value: v as string })}
|
||||
readOnly={isDeleted}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div
|
||||
className={
|
||||
cn(
|
||||
'cursor-pointer rounded-md p-1 text-text-tertiary hover:bg-state-destructive-hover hover:text-text-destructive',
|
||||
isDeleted && 'cursor-default bg-state-destructive-hover text-text-destructive')
|
||||
isDeleted && 'cursor-default bg-state-destructive-hover text-text-destructive',
|
||||
)
|
||||
}
|
||||
onClick={() => onRemove(payload.id)}
|
||||
>
|
||||
<RiDeleteBinLine className='size-4' />
|
||||
<RiDeleteBinLine className="size-4" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React, { useRef } from 'react'
|
||||
import { useHover } from 'ahooks'
|
||||
import { RiResetLeftLine } from '@remixicon/react'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import { useHover } from 'ahooks'
|
||||
import React, { useRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
|
||||
type Props = {
|
||||
onReset: () => void
|
||||
@ -18,18 +18,20 @@ const EditedBeacon: FC<Props> = ({
|
||||
const isHovering = useHover(ref)
|
||||
|
||||
return (
|
||||
<div ref={ref} className='size-4 cursor-pointer'>
|
||||
{isHovering ? (
|
||||
<Tooltip popupContent={t('common.operation.reset')}>
|
||||
<div className='flex size-4 items-center justify-center rounded-full bg-text-accent-secondary' onClick={onReset}>
|
||||
<RiResetLeftLine className='size-[10px] text-text-primary-on-surface' />
|
||||
</div>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<div className='flex size-4 items-center justify-center'>
|
||||
<div className='size-1 rounded-full bg-text-accent-secondary'></div>
|
||||
</div>
|
||||
)}
|
||||
<div ref={ref} className="size-4 cursor-pointer">
|
||||
{isHovering
|
||||
? (
|
||||
<Tooltip popupContent={t('common.operation.reset')}>
|
||||
<div className="flex size-4 items-center justify-center rounded-full bg-text-accent-secondary" onClick={onReset}>
|
||||
<RiResetLeftLine className="size-[10px] text-text-primary-on-surface" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
)
|
||||
: (
|
||||
<div className="flex size-4 items-center justify-center">
|
||||
<div className="size-1 rounded-full bg-text-accent-secondary"></div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { DataType } from '../types'
|
||||
import Input from '@/app/components/base/input'
|
||||
import { InputNumber } from '@/app/components/base/input-number'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import Datepicker from '../base/date-picker'
|
||||
import { DataType } from '../types'
|
||||
|
||||
type Props = {
|
||||
className?: string
|
||||
@ -35,14 +35,14 @@ const InputCombined: FC<Props> = ({
|
||||
|
||||
if (type === DataType.number) {
|
||||
return (
|
||||
<div className='grow text-[0]'>
|
||||
<div className="grow text-[0]">
|
||||
<InputNumber
|
||||
className={cn(className, 'rounded-l-md')}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
size='regular'
|
||||
controlWrapClassName='overflow-hidden'
|
||||
controlClassName='pt-0 pb-0'
|
||||
size="regular"
|
||||
controlWrapClassName="overflow-hidden"
|
||||
controlClassName="pt-0 pb-0"
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
import { RiCloseLine } from '@remixicon/react'
|
||||
import type { FC } from 'react'
|
||||
import { RiCloseLine } from '@remixicon/react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { cn } from '@/utils/classnames'
|
||||
@ -16,13 +16,13 @@ const InputHasSetMultipleValue: FC<Props> = ({
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<div className='h-6 grow rounded-md bg-components-input-bg-normal p-0.5 text-[0]'>
|
||||
<div className="h-6 grow rounded-md bg-components-input-bg-normal p-0.5 text-[0]">
|
||||
<div className={cn('inline-flex h-5 items-center space-x-0.5 rounded-[5px] border-[0.5px] border-components-panel-border bg-components-badge-white-to-dark pl-1.5 pr-0.5 shadow-xs', readOnly && 'pr-1.5')}>
|
||||
<div className='system-xs-regular text-text-secondary'>{t('dataset.metadata.batchEditMetadata.multipleValue')}</div>
|
||||
<div className="system-xs-regular text-text-secondary">{t('dataset.metadata.batchEditMetadata.multipleValue')}</div>
|
||||
{!readOnly && (
|
||||
<div className='cursor-pointer rounded-[4px] p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary'>
|
||||
<div className="cursor-pointer rounded-[4px] p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary">
|
||||
<RiCloseLine
|
||||
className='size-3.5 '
|
||||
className="size-3.5 "
|
||||
onClick={onClear}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -4,8 +4,8 @@ import React from 'react'
|
||||
import { cn } from '@/utils/classnames'
|
||||
|
||||
type Props = {
|
||||
isDeleted?: boolean,
|
||||
className?: string,
|
||||
isDeleted?: boolean
|
||||
className?: string
|
||||
text: string
|
||||
}
|
||||
|
||||
@ -19,7 +19,8 @@ const Label: FC<Props> = ({
|
||||
'system-xs-medium w-[136px] shrink-0 truncate text-text-tertiary',
|
||||
isDeleted && 'text-text-quaternary line-through',
|
||||
className,
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
{text}
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import Modal from '../../../base/modal'
|
||||
import type { BuiltInMetadataItem, MetadataItemInBatchEdit } from '../types'
|
||||
import { type MetadataItemWithEdit, UpdateType } from '../types'
|
||||
import EditMetadataBatchItem from './edit-row'
|
||||
import AddedMetadataItem from './add-row'
|
||||
import Button from '../../../base/button'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Checkbox from '../../../base/checkbox'
|
||||
import Tooltip from '../../../base/tooltip'
|
||||
import SelectMetadataModal from '../metadata-dataset/select-metadata-modal'
|
||||
import type { BuiltInMetadataItem, MetadataItemInBatchEdit, MetadataItemWithEdit } from '../types'
|
||||
import { RiQuestionLine } from '@remixicon/react'
|
||||
import Divider from '@/app/components/base/divider'
|
||||
import AddMetadataButton from '../add-metadata-button'
|
||||
import { produce } from 'immer'
|
||||
import useCheckMetadataName from '../hooks/use-check-metadata-name'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Divider from '@/app/components/base/divider'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { useCreateMetaData } from '@/service/knowledge/use-metadata'
|
||||
import Button from '../../../base/button'
|
||||
import Checkbox from '../../../base/checkbox'
|
||||
import Modal from '../../../base/modal'
|
||||
import Tooltip from '../../../base/tooltip'
|
||||
import AddMetadataButton from '../add-metadata-button'
|
||||
import useCheckMetadataName from '../hooks/use-check-metadata-name'
|
||||
import SelectMetadataModal from '../metadata-dataset/select-metadata-modal'
|
||||
import { UpdateType } from '../types'
|
||||
import AddedMetadataItem from './add-row'
|
||||
import EditMetadataBatchItem from './edit-row'
|
||||
|
||||
const i18nPrefix = 'dataset.metadata.batchEditMetadata'
|
||||
|
||||
type Props = {
|
||||
datasetId: string,
|
||||
datasetId: string
|
||||
documentNum: number
|
||||
list: MetadataItemInBatchEdit[]
|
||||
onSave: (editedList: MetadataItemInBatchEdit[], addedList: MetadataItemInBatchEdit[], isApplyToAllSelectDocument: boolean) => void
|
||||
@ -48,8 +48,7 @@ const EditMetadataBatchModal: FC<Props> = ({
|
||||
draft[index].isUpdated = true
|
||||
draft[index].updateType = UpdateType.changeValue
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
setTempleList(newTempleList)
|
||||
}, [templeList])
|
||||
const handleTempleItemRemove = useCallback((id: string) => {
|
||||
@ -116,11 +115,11 @@ const EditMetadataBatchModal: FC<Props> = ({
|
||||
isShow
|
||||
closable
|
||||
onClose={onHide}
|
||||
className='!max-w-[640px]'
|
||||
className="!max-w-[640px]"
|
||||
>
|
||||
<div className='system-xs-medium mt-1 text-text-accent'>{t(`${i18nPrefix}.editDocumentsNum`, { num: documentNum })}</div>
|
||||
<div className='max-h-[305px] overflow-y-auto overflow-x-hidden'>
|
||||
<div className='mt-4 space-y-2'>
|
||||
<div className="system-xs-medium mt-1 text-text-accent">{t(`${i18nPrefix}.editDocumentsNum`, { num: documentNum })}</div>
|
||||
<div className="max-h-[305px] overflow-y-auto overflow-x-hidden">
|
||||
<div className="mt-4 space-y-2">
|
||||
{templeList.map(item => (
|
||||
<EditMetadataBatchItem
|
||||
key={item.id}
|
||||
@ -131,12 +130,12 @@ const EditMetadataBatchModal: FC<Props> = ({
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className='mt-4 pl-[18px]'>
|
||||
<div className='flex items-center'>
|
||||
<div className='system-xs-medium-uppercase mr-2 shrink-0 text-text-tertiary'>{t('dataset.metadata.createMetadata.title')}</div>
|
||||
<Divider bgStyle='gradient' />
|
||||
<div className="mt-4 pl-[18px]">
|
||||
<div className="flex items-center">
|
||||
<div className="system-xs-medium-uppercase mr-2 shrink-0 text-text-tertiary">{t('dataset.metadata.createMetadata.title')}</div>
|
||||
<Divider bgStyle="gradient" />
|
||||
</div>
|
||||
<div className='mt-2 space-y-2'>
|
||||
<div className="mt-2 space-y-2">
|
||||
{addedList.map((item, i) => (
|
||||
<AddedMetadataItem
|
||||
key={i}
|
||||
@ -146,10 +145,10 @@ const EditMetadataBatchModal: FC<Props> = ({
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className='mt-3'>
|
||||
<div className="mt-3">
|
||||
<SelectMetadataModal
|
||||
datasetId={datasetId}
|
||||
popupPlacement='top-start'
|
||||
popupPlacement="top-start"
|
||||
popupOffset={{ mainAxis: 4, crossAxis: 0 }}
|
||||
trigger={
|
||||
<AddMetadataButton />
|
||||
@ -162,25 +161,31 @@ const EditMetadataBatchModal: FC<Props> = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='mt-4 flex items-center justify-between'>
|
||||
<div className='flex select-none items-center'>
|
||||
<div className="mt-4 flex items-center justify-between">
|
||||
<div className="flex select-none items-center">
|
||||
<Checkbox checked={isApplyToAllSelectDocument} onCheck={() => setIsApplyToAllSelectDocument(!isApplyToAllSelectDocument)} />
|
||||
<div className='system-xs-medium ml-2 mr-1 text-text-secondary'>{t(`${i18nPrefix}.applyToAllSelectDocument`)}</div>
|
||||
<div className="system-xs-medium ml-2 mr-1 text-text-secondary">{t(`${i18nPrefix}.applyToAllSelectDocument`)}</div>
|
||||
<Tooltip popupContent={
|
||||
<div className='max-w-[240px]'>{t(`${i18nPrefix}.applyToAllSelectDocumentTip`)}</div>
|
||||
} >
|
||||
<div className='cursor-pointer p-px'>
|
||||
<RiQuestionLine className='size-3.5 text-text-tertiary' />
|
||||
<div className="max-w-[240px]">{t(`${i18nPrefix}.applyToAllSelectDocumentTip`)}</div>
|
||||
}
|
||||
>
|
||||
<div className="cursor-pointer p-px">
|
||||
<RiQuestionLine className="size-3.5 text-text-tertiary" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div className='flex items-center space-x-2'>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Button
|
||||
onClick={onHide}>{t('common.operation.cancel')}</Button>
|
||||
onClick={onHide}
|
||||
>
|
||||
{t('common.operation.cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
variant='primary'
|
||||
>{t('common.operation.save')}</Button>
|
||||
variant="primary"
|
||||
>
|
||||
{t('common.operation.save')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user