mirror of https://github.com/langgenius/dify.git
refactor: simplify array spread usage in various components
This commit is contained in:
parent
afe61c486b
commit
a984549f01
|
|
@ -149,7 +149,7 @@ export const PortalToFollowElemTrigger = (
|
|||
context.getReferenceProps({
|
||||
ref,
|
||||
...props,
|
||||
...(children.props || {}),
|
||||
...children.props,
|
||||
'data-state': context.open ? 'open' : 'closed',
|
||||
} as React.HTMLProps<HTMLElement>),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export const useReplaceDataSourceNode = (id: string) => {
|
|||
const { newNode } = generateNewNode({
|
||||
data: {
|
||||
...(defaultValue as any),
|
||||
...(toolDefaultValue || {}),
|
||||
...toolDefaultValue,
|
||||
},
|
||||
position: {
|
||||
x: emptyNode.position.x,
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue