From a984549f017c9311778f95f62993dba9d177ee1d Mon Sep 17 00:00:00 2001 From: twwu Date: Thu, 18 Sep 2025 12:10:17 +0800 Subject: [PATCH] refactor: simplify array spread usage in various components --- web/app/components/base/portal-to-follow-elem/index.tsx | 2 +- .../data-source/online-documents/page-selector/index.tsx | 6 +++--- .../hooks/use-marketplace-all-plugins.ts | 2 +- web/app/components/workflow/hooks/use-nodes-interactions.ts | 6 +++--- .../components/workflow/nodes/data-source-empty/hooks.ts | 2 +- web/app/components/workflow/operator/add-block.tsx | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/app/components/base/portal-to-follow-elem/index.tsx b/web/app/components/base/portal-to-follow-elem/index.tsx index abecaf62a2..ddba0b6545 100644 --- a/web/app/components/base/portal-to-follow-elem/index.tsx +++ b/web/app/components/base/portal-to-follow-elem/index.tsx @@ -149,7 +149,7 @@ export const PortalToFollowElemTrigger = ( context.getReferenceProps({ ref, ...props, - ...(children.props || {}), + ...children.props, 'data-state': context.open ? 'open' : 'closed', } as React.HTMLProps), ) diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/index.tsx index 36be578a87..e3fc6e2571 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/index.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/online-documents/page-selector/index.tsx @@ -91,7 +91,7 @@ const PageSelector = ({ if (current.expand) { current.expand = false - newDataList = [...dataList.filter(item => !descendantsIds.includes(item.page_id))] + newDataList = dataList.filter(item => !descendantsIds.includes(item.page_id)) } else { current.expand = true @@ -110,7 +110,7 @@ const PageSelector = ({ }, [dataList, listMapWithChildrenAndDescendants, pagesMap]) const handleCheck = useCallback((index: number) => { - const copyValue = new Set([...checkedIds]) + const copyValue = new Set(checkedIds) const current = currentDataList[index] const pageId = current.page_id const currentWithChildrenAndDescendants = listMapWithChildrenAndDescendants[pageId] @@ -138,7 +138,7 @@ const PageSelector = ({ } } - onSelect(new Set([...copyValue])) + onSelect(new Set(copyValue)) }, [currentDataList, isMultipleChoice, listMapWithChildrenAndDescendants, onSelect, searchValue, checkedIds]) const handlePreview = useCallback((index: number) => { diff --git a/web/app/components/header/account-setting/data-source-page-new/hooks/use-marketplace-all-plugins.ts b/web/app/components/header/account-setting/data-source-page-new/hooks/use-marketplace-all-plugins.ts index 2dd98ccf03..4156e62c4b 100644 --- a/web/app/components/header/account-setting/data-source-page-new/hooks/use-marketplace-all-plugins.ts +++ b/web/app/components/header/account-setting/data-source-page-new/hooks/use-marketplace-all-plugins.ts @@ -59,7 +59,7 @@ export const useMarketplaceAllPlugins = (providers: any[], searchText: string) = }, [queryPlugins, queryPluginsWithDebounced, searchText, exclude]) const allPlugins = useMemo(() => { - const allPlugins = [...collectionPlugins.filter(plugin => !exclude.includes(plugin.plugin_id))] + const allPlugins = collectionPlugins.filter(plugin => !exclude.includes(plugin.plugin_id)) if (plugins?.length) { for (let i = 0; i < plugins.length; i++) { diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts index 3053100be4..4000ce5c7b 100644 --- a/web/app/components/workflow/hooks/use-nodes-interactions.ts +++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts @@ -765,7 +765,7 @@ export const useNodesInteractions = () => { nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title, - ...(toolDefaultValue || {}), + ...toolDefaultValue, selected: true, _showAddVariablePopup: (nodeType === BlockEnum.VariableAssigner @@ -866,7 +866,7 @@ export const useNodesInteractions = () => { const nodesConnectedSourceOrTargetHandleIdsMap = getNodesConnectedSourceOrTargetHandleIdsMap( - [...(newEdge ? [{ type: 'add', edge: newEdge }] : [])], + (newEdge ? [{ type: 'add', edge: newEdge }] : []), nodes, ) const newNodes = produce(nodes, (draft: Node[]) => { @@ -1331,7 +1331,7 @@ export const useNodesInteractions = () => { nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title, - ...(toolDefaultValue || {}), + ...toolDefaultValue, _connectedSourceHandleIds: [], _connectedTargetHandleIds: [], selected: currentNode.data.selected, diff --git a/web/app/components/workflow/nodes/data-source-empty/hooks.ts b/web/app/components/workflow/nodes/data-source-empty/hooks.ts index 13c4c8b56b..e22e87485c 100644 --- a/web/app/components/workflow/nodes/data-source-empty/hooks.ts +++ b/web/app/components/workflow/nodes/data-source-empty/hooks.ts @@ -28,7 +28,7 @@ export const useReplaceDataSourceNode = (id: string) => { const { newNode } = generateNewNode({ data: { ...(defaultValue as any), - ...(toolDefaultValue || {}), + ...toolDefaultValue, }, position: { x: emptyNode.position.x, diff --git a/web/app/components/workflow/operator/add-block.tsx b/web/app/components/workflow/operator/add-block.tsx index 38a0a30a64..3c11dbac32 100644 --- a/web/app/components/workflow/operator/add-block.tsx +++ b/web/app/components/workflow/operator/add-block.tsx @@ -65,7 +65,7 @@ const AddBlock = ({ data: { ...(defaultValue as any), title: nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title, - ...(toolDefaultValue || {}), + ...toolDefaultValue, _isCandidate: true, }, position: {