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

@@ -11,6 +11,7 @@ import Toast from '@/app/components/base/toast'
import { annotationBatchImport, checkAnnotationBatchImportProgress } from '@/service/annotation'
import { useProviderContext } from '@/context/provider-context'
import AnnotationFull from '@/app/components/billing/annotation-full'
import { noop } from 'lodash-es'
export enum ProcessStatus {
WAITING = 'waiting',
@@ -87,7 +88,7 @@ const BatchModal: FC<IBatchModalProps> = ({
}
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='system-xl-medium relative pb-1 text-text-primary'>{t('appAnnotation.batchModal.title')}</div>
<div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onCancel}>
<RiCloseLine className='h-4 w-4 text-text-tertiary' />

View File

@@ -7,6 +7,7 @@ import {
RiEditLine,
} from '@remixicon/react'
import cn from '@/utils/classnames'
import { noop } from 'lodash-es'
export type IOperationBtnProps = {
className?: string
@@ -24,7 +25,7 @@ const OperationBtn: FC<IOperationBtnProps> = ({
className,
type,
actionName,
onClick = () => { },
onClick = noop,
}) => {
const { t } = useTranslation()
return (

View File

@@ -27,6 +27,7 @@ import { INSERT_VARIABLE_VALUE_BLOCK_COMMAND } from '@/app/components/base/promp
import { PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER } from '@/app/components/base/prompt-editor/plugins/update-block'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import { useFeaturesStore } from '@/app/components/base/features/hooks'
import { noop } from 'lodash-es'
export type ISimplePromptInput = {
mode: AppType
@@ -233,7 +234,7 @@ const Prompt: FC<ISimplePromptInput> = ({
user: '',
assistant: '',
},
onEditRole: () => { },
onEditRole: noop,
}}
queryBlock={{
show: false,

View File

@@ -14,8 +14,9 @@ import type { ExternalDataTool } from '@/models/common'
import ConfigContext from '@/context/debug-configuration'
import { useModalContext } from '@/context/modal-context'
import { useToastContext } from '@/app/components/base/toast'
import s from '@/app/components/app/configuration/config-prompt/style.module.css'
import { noop } from 'lodash-es'
type Props = {
className?: string
type: 'first-prompt' | 'next-iteration'
@@ -128,14 +129,14 @@ const Editor: FC<Props> = ({
user: '',
assistant: '',
},
onEditRole: () => { },
onEditRole: noop,
}}
queryBlock={{
show: false,
selectable: false,
}}
onChange={onChange}
onBlur={() => { }}
onBlur={noop}
/>
</div>
<div className='flex pb-2 pl-4'>

View File

@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'
import './weighted-score.css'
import Slider from '@/app/components/base/slider'
import cn from '@/utils/classnames'
import { noop } from 'lodash-es'
const formatNumber = (value: number) => {
if (value > 0 && value < 1)
@@ -23,7 +24,7 @@ type WeightedScoreProps = {
}
const WeightedScore = ({
value,
onChange = () => {},
onChange = noop,
}: WeightedScoreProps) => {
const { t } = useTranslation()

View File

@@ -2,6 +2,7 @@
import { createContext, useContext } from 'use-context-selector'
import type { ModelAndParameter } from '../types'
import { noop } from 'lodash-es'
export type DebugWithMultipleModelContextType = {
multipleModelConfigs: ModelAndParameter[]
@@ -11,8 +12,8 @@ export type DebugWithMultipleModelContextType = {
}
const DebugWithMultipleModelContext = createContext<DebugWithMultipleModelContextType>({
multipleModelConfigs: [],
onMultipleModelConfigsChange: () => {},
onDebugWithMultipleModelChange: () => {},
onMultipleModelConfigsChange: noop,
onDebugWithMultipleModelChange: noop,
})
export const useDebugWithMultipleModelContext = () => useContext(DebugWithMultipleModelContext)

View File

@@ -14,6 +14,7 @@ import { TransferMethod } from '@/app/components/base/chat/types'
import { useEventEmitterContextContext } from '@/context/event-emitter'
import { useProviderContext } from '@/context/provider-context'
import { useFeatures } from '@/app/components/base/features/hooks'
import { noop } from 'lodash-es'
type TextGenerationItemProps = {
modelAndParameter: ModelAndParameter
@@ -134,7 +135,7 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
siteInfo={null}
messageId={messageId}
isError={false}
onRetry={() => { }}
onRetry={noop}
inSidePanel
/>
)

View File

@@ -47,6 +47,7 @@ import AgentLogModal from '@/app/components/base/agent-log-modal'
import PromptLogModal from '@/app/components/base/prompt-log-modal'
import { useStore as useAppStore } from '@/app/components/app/store'
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
import { noop } from 'lodash-es'
type IDebug = {
isAPIKeySet: boolean
@@ -515,7 +516,7 @@ const Debug: FC<IDebug> = ({
isInstalledApp={false}
messageId={messageId}
isError={false}
onRetry={() => { }}
onRetry={noop}
siteInfo={null}
/>
</div>

View File

@@ -19,6 +19,7 @@ import type {
} from '@/models/common'
import { useToastContext } from '@/app/components/base/toast'
import AppIcon from '@/app/components/base/app-icon'
import { noop } from 'lodash-es'
const systemTypes = ['api']
type ExternalDataToolModalProps = {
@@ -185,7 +186,7 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
return (
<Modal
isShow
onClose={() => { }}
onClose={noop}
className='!w-[640px] !max-w-none !p-8 !pb-6'
>
<div className='mb-2 text-xl font-semibold text-gray-900'>

View File

@@ -26,6 +26,7 @@ import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { getRedirection } from '@/utils/app-redirection'
import cn from '@/utils/classnames'
import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'
import { noop } from 'lodash-es'
type CreateFromDSLModalProps = {
show: boolean
@@ -203,7 +204,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
<Modal
className='w-[520px] rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg p-0 shadow-xl'
isShow={show}
onClose={() => { }}
onClose={noop}
>
<div className='title-2xl-semi-bold flex items-center justify-between pb-3 pl-6 pr-5 pt-6 text-text-primary'>
{t('app.importFromDSL')}

View File

@@ -12,6 +12,7 @@ import AppIcon from '@/app/components/base/app-icon'
import { useProviderContext } from '@/context/provider-context'
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
import type { AppIconType } from '@/types/app'
import { noop } from 'lodash-es'
export type DuplicateAppModalProps = {
appName: string
@@ -71,7 +72,7 @@ const DuplicateAppModal = ({
<>
<Modal
isShow={show}
onClose={() => { }}
onClose={noop}
className={cn('relative !max-w-[480px]', 'px-8')}
>
<div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onHide}>

View File

@@ -41,6 +41,7 @@ import { CopyIcon } from '@/app/components/base/copy-icon'
import { buildChatItemTree, getThreadMessages } from '@/app/components/base/chat/utils'
import { getProcessedFilesFromResponse } from '@/app/components/base/file-uploader/utils'
import cn from '@/utils/classnames'
import { noop } from 'lodash-es'
dayjs.extend(utc)
dayjs.extend(timezone)
@@ -411,7 +412,7 @@ function DetailPanel({ detail, onFeedback }: IDetailPanel) {
content={detail.message.answer}
messageId={detail.message.id}
isError={false}
onRetry={() => { }}
onRetry={noop}
isInstalledApp={false}
supportFeedback
feedback={detail.message.feedbacks.find((item: any) => item.from_source === 'admin')}

View File

@@ -23,6 +23,7 @@ import type { App } from '@/types/app'
import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
import AppIcon from '@/app/components/base/app-icon'
import { useStore as useAppStore } from '@/app/components/app/store'
import { noop } from 'lodash-es'
type SwitchAppModalProps = {
show: boolean
@@ -96,7 +97,7 @@ const SwitchAppModal = ({ show, appDetail, inAppDetail = false, onSuccess, onClo
<Modal
className={cn('w-[600px] max-w-[600px] p-8')}
isShow={show}
onClose={() => { }}
onClose={noop}
>
<div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onClose}>
<RiCloseLine className='h-4 w-4 text-text-tertiary' />