mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-11 03:46:52 +08:00
refactor & perf: import { noop } from 'lodash-es' across web (#17439)
This commit is contained in:
@@ -8,6 +8,7 @@ import Modal from '@/app/components/base/modal'
|
||||
import Checkbox from '@/app/components/base/checkbox'
|
||||
import Button from '@/app/components/base/button'
|
||||
import type { EnvironmentVariable } from '@/app/components/workflow/types'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
export type DSLExportConfirmModalProps = {
|
||||
envList: EnvironmentVariable[]
|
||||
@@ -32,7 +33,7 @@ const DSLExportConfirmModal = ({
|
||||
return (
|
||||
<Modal
|
||||
isShow={true}
|
||||
onClose={() => { }}
|
||||
onClose={noop}
|
||||
className={cn('w-[480px] max-w-[480px]')}
|
||||
>
|
||||
<div className='title-2xl-semi-bold relative pb-6 text-text-primary'>{t('workflow.env.export.title')}</div>
|
||||
|
||||
@@ -8,8 +8,8 @@ import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||
import {
|
||||
getFilesInLogs,
|
||||
} from '@/app/components/base/file-uploader/utils'
|
||||
|
||||
import './style.css'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
// load file from local instead of cdn https://github.com/suren-atoyan/monaco-react/issues/482
|
||||
loader.config({ paths: { vs: '/vs' } })
|
||||
@@ -55,7 +55,7 @@ const DEFAULT_THEME = {
|
||||
const CodeEditor: FC<Props> = ({
|
||||
value = '',
|
||||
placeholder = '',
|
||||
onChange = () => { },
|
||||
onChange = noop,
|
||||
title = '',
|
||||
headerRight,
|
||||
language,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||
import TagInput from '@/app/components/base/tag-input'
|
||||
import Checkbox from '@/app/components/base/checkbox'
|
||||
import { FileTypeIcon } from '@/app/components/base/file-uploader'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type Props = {
|
||||
type: SupportUploadFileTypes.image | SupportUploadFileTypes.document | SupportUploadFileTypes.audio | SupportUploadFileTypes.video | SupportUploadFileTypes.custom
|
||||
@@ -22,7 +23,7 @@ const FileTypeItem: FC<Props> = ({
|
||||
selected,
|
||||
onToggle,
|
||||
customFileTypes = [],
|
||||
onCustomFileTypesChange = () => { },
|
||||
onCustomFileTypesChange = noop,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import PromptEditor from '@/app/components/base/prompt-editor'
|
||||
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type Props = {
|
||||
instanceId?: string
|
||||
@@ -68,7 +69,7 @@ const Editor: FC<Props> = ({
|
||||
show: false,
|
||||
selectable: false,
|
||||
datasets: [],
|
||||
onAddContext: () => { },
|
||||
onAddContext: noop,
|
||||
}}
|
||||
historyBlock={{
|
||||
show: false,
|
||||
@@ -77,7 +78,7 @@ const Editor: FC<Props> = ({
|
||||
user: 'Human',
|
||||
assistant: 'Assistant',
|
||||
},
|
||||
onEditRole: () => { },
|
||||
onEditRole: noop,
|
||||
}}
|
||||
queryBlock={{
|
||||
show: false,
|
||||
|
||||
@@ -37,6 +37,7 @@ import AddButton from '@/app/components/base/button/add-button'
|
||||
import Badge from '@/app/components/base/badge'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import { isExceptionVariable } from '@/app/components/workflow/utils'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
const TRIGGER_DEFAULT_WIDTH = 227
|
||||
|
||||
@@ -73,7 +74,7 @@ const VarReferencePicker: FC<Props> = ({
|
||||
className,
|
||||
isShowNodeName = true,
|
||||
value = [],
|
||||
onOpen = () => { },
|
||||
onOpen = noop,
|
||||
onChange,
|
||||
isSupportConstantValue,
|
||||
defaultVarKindType = VarKindType.constant,
|
||||
@@ -283,7 +284,7 @@ const VarReferencePicker: FC<Props> = ({
|
||||
{isAddBtnTrigger
|
||||
? (
|
||||
<div>
|
||||
<AddButton onClick={() => { }}></AddButton>
|
||||
<AddButton onClick={noop}></AddButton>
|
||||
</div>
|
||||
)
|
||||
: (<div ref={!isSupportConstantValue ? triggerRef : null} className={cn((open || isFocus) ? 'border-gray-300' : 'border-gray-100', 'group/wrap relative flex h-8 w-full items-center', !isSupportConstantValue && 'rounded-lg bg-components-input-bg-normal p-1', isInTable && 'border-none bg-transparent', readonly && 'bg-components-input-bg-disabled')}>
|
||||
|
||||
@@ -15,6 +15,7 @@ import ActionButton from '@/app/components/base/action-button'
|
||||
import Input from '@/app/components/base/input'
|
||||
import Textarea from '@/app/components/base/textarea'
|
||||
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type Props = {
|
||||
readonly: boolean
|
||||
@@ -36,7 +37,7 @@ const VarList: FC<Props> = ({
|
||||
nodeId,
|
||||
list,
|
||||
onChange,
|
||||
onOpen = () => { },
|
||||
onOpen = noop,
|
||||
filterVar,
|
||||
filterToAssignedVar,
|
||||
getAssignedVarType,
|
||||
|
||||
@@ -18,6 +18,7 @@ import ConditionAdd from './condition-add'
|
||||
import cn from '@/utils/classnames'
|
||||
import Button from '@/app/components/base/button'
|
||||
import { PortalSelect as Select } from '@/app/components/base/select'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type Props = {
|
||||
isSubVariable?: boolean
|
||||
@@ -49,7 +50,7 @@ const ConditionWrap: FC<Props> = ({
|
||||
nodeId: id = '',
|
||||
cases = [],
|
||||
readOnly,
|
||||
handleSortCase = () => { },
|
||||
handleSortCase = noop,
|
||||
handleRemoveCase,
|
||||
handleUpdateCondition,
|
||||
handleAddCondition,
|
||||
|
||||
@@ -10,6 +10,7 @@ import Tooltip from '@/app/components/base/tooltip'
|
||||
import type { MetadataShape } from '@/app/components/workflow/nodes/knowledge-retrieval/types'
|
||||
import { MetadataFilteringModeEnum } from '@/app/components/workflow/nodes/knowledge-retrieval/types'
|
||||
import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type MetadataFilterProps = {
|
||||
metadataFilterMode?: MetadataFilteringModeEnum
|
||||
@@ -85,8 +86,8 @@ const MetadataFilter = ({
|
||||
provider={metadataModelConfig?.provider || ''}
|
||||
completionParams={metadataModelConfig?.completion_params || { temperature: 0.7 }}
|
||||
modelId={metadataModelConfig?.name || ''}
|
||||
setModel={handleMetadataModelChange || (() => {})}
|
||||
onCompletionParamsChange={handleMetadataCompletionParamsChange || (() => {})}
|
||||
setModel={handleMetadataModelChange || noop}
|
||||
onCompletionParamsChange={handleMetadataCompletionParamsChange || noop}
|
||||
hideDebugWithMultipleModel
|
||||
debugWithMultipleModel={false}
|
||||
/>
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Variable02 } from '@/app/components/base/icons/src/vender/solid/develop
|
||||
import { Edit03 } from '@/app/components/base/icons/src/vender/solid/general'
|
||||
import Badge from '@/app/components/base/badge'
|
||||
import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type Props = {
|
||||
readonly: boolean
|
||||
@@ -26,8 +27,8 @@ type Props = {
|
||||
const VarItem: FC<Props> = ({
|
||||
readonly,
|
||||
payload,
|
||||
onChange = () => { },
|
||||
onRemove = () => { },
|
||||
onChange = noop,
|
||||
onRemove = noop,
|
||||
rightContent,
|
||||
varKeys = [],
|
||||
showLegacyBadge = false,
|
||||
|
||||
@@ -16,6 +16,7 @@ import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use
|
||||
import { VarType } from '@/app/components/workflow/types'
|
||||
import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector'
|
||||
import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type Props = {
|
||||
readOnly: boolean
|
||||
@@ -34,7 +35,7 @@ const InputVarList: FC<Props> = ({
|
||||
schema,
|
||||
value,
|
||||
onChange,
|
||||
onOpen = () => { },
|
||||
onOpen = noop,
|
||||
isSupportConstantValue,
|
||||
filterVar,
|
||||
}) => {
|
||||
|
||||
@@ -8,6 +8,7 @@ import ListNoDataPlaceholder from '../../../_base/components/list-no-data-placeh
|
||||
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
|
||||
import type { ValueSelector, Var } from '@/app/components/workflow/types'
|
||||
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
type Props = {
|
||||
readonly: boolean
|
||||
@@ -23,7 +24,7 @@ const VarList: FC<Props> = ({
|
||||
nodeId,
|
||||
list,
|
||||
onChange,
|
||||
onOpen = () => { },
|
||||
onOpen = noop,
|
||||
filterVar,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@@ -21,6 +21,7 @@ import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||
import useTimestamp from '@/hooks/use-timestamp'
|
||||
import { fetchCurrentValueOfConversationVariable } from '@/service/workflow'
|
||||
import cn from '@/utils/classnames'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
export type Props = {
|
||||
conversationID: string
|
||||
@@ -76,7 +77,7 @@ const ConversationVariableModal = ({
|
||||
return (
|
||||
<Modal
|
||||
isShow
|
||||
onClose={() => { }}
|
||||
onClose={noop}
|
||||
className={cn('h-[640px] w-[920px] max-w-[920px] p-0')}
|
||||
>
|
||||
<div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onHide}>
|
||||
|
||||
@@ -23,13 +23,14 @@ import { BubbleX } from '@/app/components/base/icons/src/vender/line/others'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
export type ChatWrapperRefType = {
|
||||
handleRestart: () => void
|
||||
}
|
||||
const DebugAndPreview = () => {
|
||||
const { t } = useTranslation()
|
||||
const chatRef = useRef({ handleRestart: () => { } })
|
||||
const chatRef = useRef({ handleRestart: noop })
|
||||
const { handleCancelDebugAndPreviewPanel } = useWorkflowInteractions()
|
||||
const { handleNodeCancelRunningStatus } = useNodesInteractions()
|
||||
const { handleEdgeCancelRunningStatus } = useEdgesInteractions()
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import format from '.'
|
||||
import graphToLogStruct from '../graph-to-log-struct'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
describe('iteration', () => {
|
||||
const list = graphToLogStruct('start -> (iteration, iterationNode, plainNode1 -> plainNode2)')
|
||||
// const [startNode, iterationNode, ...iterations] = list
|
||||
const result = format(list as any, () => { })
|
||||
const result = format(list as any, noop)
|
||||
test('result should have no nodes in iteration node', () => {
|
||||
expect((result as any).find((item: any) => !!item.execution_metadata?.iteration_id)).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import format from '.'
|
||||
import graphToLogStruct from '../graph-to-log-struct'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
describe('loop', () => {
|
||||
const list = graphToLogStruct('start -> (loop, loopNode, plainNode1 -> plainNode2)')
|
||||
const [startNode, loopNode, ...loops] = list
|
||||
const result = format(list as any, () => { })
|
||||
const result = format(list as any, noop)
|
||||
test('result should have no nodes in loop node', () => {
|
||||
expect((result as any).find((item: any) => !!item.execution_metadata?.loop_id)).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -4,8 +4,9 @@ import { type TemporalState, temporal } from 'zundo'
|
||||
import isDeepEqual from 'fast-deep-equal'
|
||||
import type { Edge, Node } from './types'
|
||||
import type { WorkflowHistoryEvent } from './hooks'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
export const WorkflowHistoryStoreContext = createContext<WorkflowHistoryStoreContextType>({ store: null, shortcutsEnabled: true, setShortcutsEnabled: () => {} })
|
||||
export const WorkflowHistoryStoreContext = createContext<WorkflowHistoryStoreContextType>({ store: null, shortcutsEnabled: true, setShortcutsEnabled: noop })
|
||||
export const Provider = WorkflowHistoryStoreContext.Provider
|
||||
|
||||
export function WorkflowHistoryProvider({
|
||||
|
||||
Reference in New Issue
Block a user