refactor & perf: import { noop } from 'lodash-es' across web (#17439)

This commit is contained in:
yusheng chen
2025-04-06 17:56:08 +08:00
committed by GitHub
parent 7016ccef10
commit c05e03fc09
87 changed files with 271 additions and 184 deletions

View File

@@ -6,6 +6,7 @@ import useSWR from 'swr'
import StatusWithAction from './status-with-action'
import { getErrorDocs, retryErrorDocs } from '@/service/datasets'
import type { IndexingStatusResponse } from '@/models/datasets'
import { noop } from 'lodash-es'
type Props = {
datasetId: string
@@ -62,7 +63,7 @@ const RetryButton: FC<Props> = ({ datasetId }) => {
description={`${errorDocs?.total} ${t('dataset.docsFailedNotice')}`}
actionText={t('dataset.retry')}
disabled={indexState.value === 'retry'}
onAction={indexState.value === 'error' ? onRetryErrorDocs : () => { }}
onAction={indexState.value === 'error' ? onRetryErrorDocs : noop}
/>
)
}

View File

@@ -8,6 +8,7 @@ import CSVDownloader from './csv-downloader'
import Button from '@/app/components/base/button'
import Modal from '@/app/components/base/modal'
import type { ChunkingMode } from '@/models/datasets'
import { noop } from 'lodash-es'
export type IBatchModalProps = {
isShow: boolean
@@ -39,7 +40,7 @@ const BatchModal: FC<IBatchModalProps> = ({
}, [isShow])
return (
<Modal isShow={isShow} onClose={() => { }} className='!max-w-[520px] !rounded-xl px-8 py-6'>
<Modal isShow={isShow} onClose={noop} className='!max-w-[520px] !rounded-xl px-8 py-6'>
<div className='relative pb-1 text-xl font-medium leading-[30px] text-gray-900'>{t('datasetDocuments.list.batchModal.title')}</div>
<div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onCancel}>
<RiCloseLine className='h-4 w-4 text-gray-500' />

View File

@@ -1,6 +1,7 @@
import React, { type FC } from 'react'
import Drawer from '@/app/components/base/drawer'
import classNames from '@/utils/classnames'
import { noop } from 'lodash-es'
type IFullScreenDrawerProps = {
isOpen: boolean
@@ -11,7 +12,7 @@ type IFullScreenDrawerProps = {
const FullScreenDrawer: FC<IFullScreenDrawerProps> = ({
isOpen,
onClose = () => {},
onClose = noop,
fullScreen,
children,
}) => {

View File

@@ -5,6 +5,7 @@ import { useCountDown } from 'ahooks'
import Modal from '@/app/components/base/modal'
import Button from '@/app/components/base/button'
import { useEventEmitterContextContext } from '@/context/event-emitter'
import { noop } from 'lodash-es'
type IDefaultContentProps = {
onCancel: () => void
@@ -120,7 +121,7 @@ const RegenerationModal: FC<IRegenerationModalProps> = ({
})
return (
<Modal isShow={isShow} onClose={() => {}} className='!max-w-[480px] !rounded-2xl'>
<Modal isShow={isShow} onClose={noop} className='!max-w-[480px] !rounded-2xl'>
{!loading && !updateSucceeded && <DefaultContent onCancel={onCancel} onConfirm={onConfirm} />}
{loading && !updateSucceeded && <RegeneratingContent />}
{!loading && updateSucceeded && <RegenerationCompletedContent onClose={onClose} />}

View File

@@ -46,6 +46,7 @@ import {
useUpdateSegment,
} from '@/service/knowledge/use-segment'
import { useInvalid } from '@/service/use-base'
import { noop } from 'lodash-es'
const DEFAULT_LIMIT = 10
@@ -71,7 +72,7 @@ type SegmentListContextValue = {
const SegmentListContext = createContext<SegmentListContextValue>({
isCollapsed: true,
fullScreen: false,
toggleFullScreen: () => {},
toggleFullScreen: noop,
currSegment: { showModal: false },
currChildChunk: { showModal: false },
})

View File

@@ -8,6 +8,7 @@ import OptionCard from '../../../workflow/nodes/_base/components/option-card'
import Input from '@/app/components/base/input'
import { RiArrowLeftLine } from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import { noop } from 'lodash-es'
const i18nPrefix = 'dataset.metadata.createMetadata'
@@ -19,7 +20,7 @@ export type Props = {
}
const CreateContent: FC<Props> = ({
onClose = () => { },
onClose = noop,
hasBack,
onBack,
onSave,

View File

@@ -13,6 +13,7 @@ import Modal from '@/app/components/base/modal'
import { ToastContext } from '@/app/components/base/toast'
import type { DataSet } from '@/models/datasets'
import { updateDatasetSetting } from '@/service/datasets'
import { noop } from 'lodash-es'
type RenameDatasetModalProps = {
show: boolean
@@ -66,7 +67,7 @@ const RenameDatasetModal = ({ show, dataset, onSuccess, onClose }: RenameDataset
<Modal
className='w-[520px] max-w-[520px] rounded-xl px-8 py-6'
isShow={show}
onClose={() => { }}
onClose={noop}
>
<div className='relative pb-2 text-xl font-medium leading-[30px] text-text-primary'>{t('datasetSettings.title')}</div>
<div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onClose}>