mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-25 06:14:06 +00:00
4.8.11 test (#2850)
* fix: variables check * remove log * fix: variables refresh * perf: team select button * perf: remove change fn
This commit is contained in:
@@ -7,6 +7,7 @@ import dynamic from 'next/dynamic';
|
|||||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||||
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
|
|
||||||
const TeamManageModal = dynamic(() => import('../TeamManageModal'));
|
const TeamManageModal = dynamic(() => import('../TeamManageModal'));
|
||||||
|
|
||||||
@@ -19,12 +20,13 @@ const TeamMenu = () => {
|
|||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<Button
|
<Button
|
||||||
variant={'whitePrimary'}
|
variant={'whitePrimary'}
|
||||||
userSelect={'none'}
|
userSelect={'none'}
|
||||||
w={'100%'}
|
w={'100%'}
|
||||||
display={'block'}
|
|
||||||
h={'34px'}
|
h={'34px'}
|
||||||
|
justifyContent={'space-between'}
|
||||||
px={3}
|
px={3}
|
||||||
css={{
|
css={{
|
||||||
'& span': {
|
'& span': {
|
||||||
@@ -32,6 +34,7 @@ const TeamMenu = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
transform={'none !important'}
|
transform={'none !important'}
|
||||||
|
rightIcon={<MyIcon w={'1rem'} name={'common/select'} />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (feConfigs.isPlus) {
|
if (feConfigs.isPlus) {
|
||||||
onOpen();
|
onOpen();
|
||||||
@@ -58,8 +61,9 @@ const TeamMenu = () => {
|
|||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</MyTooltip>
|
</MyTooltip>
|
||||||
{isOpen && <TeamManageModal onClose={onClose} />}
|
|
||||||
</Button>
|
</Button>
|
||||||
|
{isOpen && <TeamManageModal onClose={onClose} />}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -3,8 +3,6 @@ import { Box, Button, Flex, useTheme } from '@chakra-ui/react';
|
|||||||
import { getInforms, readInform } from '@/web/support/user/inform/api';
|
import { getInforms, readInform } from '@/web/support/user/inform/api';
|
||||||
import type { UserInformSchema } from '@fastgpt/global/support/user/inform/type';
|
import type { UserInformSchema } from '@fastgpt/global/support/user/inform/type';
|
||||||
import { formatTimeToChatTime } from '@fastgpt/global/common/string/time';
|
import { formatTimeToChatTime } from '@fastgpt/global/common/string/time';
|
||||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
|
||||||
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
||||||
import { useLoading } from '@fastgpt/web/hooks/useLoading';
|
import { useLoading } from '@fastgpt/web/hooks/useLoading';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
@@ -15,7 +13,6 @@ const InformTable = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { Loading } = useLoading();
|
const { Loading } = useLoading();
|
||||||
const { isPc } = useSystem();
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: informs,
|
data: informs,
|
||||||
|
@@ -8,7 +8,7 @@ import { WorkflowContext } from '../../context';
|
|||||||
import { useThrottleEffect } from 'ahooks';
|
import { useThrottleEffect } from 'ahooks';
|
||||||
|
|
||||||
const ButtonEdge = (props: EdgeProps) => {
|
const ButtonEdge = (props: EdgeProps) => {
|
||||||
const { nodes, nodeList, setEdges, workflowDebugData, hoverEdgeId } = useContextSelector(
|
const { nodes, nodeList, onEdgesChange, workflowDebugData, hoverEdgeId } = useContextSelector(
|
||||||
WorkflowContext,
|
WorkflowContext,
|
||||||
(v) => v
|
(v) => v
|
||||||
);
|
);
|
||||||
@@ -43,12 +43,14 @@ const ButtonEdge = (props: EdgeProps) => {
|
|||||||
|
|
||||||
const onDelConnect = useCallback(
|
const onDelConnect = useCallback(
|
||||||
(id: string) => {
|
(id: string) => {
|
||||||
setEdges((state) => {
|
onEdgesChange([
|
||||||
const newState = state.filter((item) => item.id !== id);
|
{
|
||||||
return newState;
|
type: 'remove',
|
||||||
});
|
id
|
||||||
|
}
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
[setEdges]
|
[onEdgesChange]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Selected edge or source/target node selected
|
// Selected edge or source/target node selected
|
||||||
|
@@ -14,7 +14,7 @@ import {
|
|||||||
Rect,
|
Rect,
|
||||||
NodeRemoveChange,
|
NodeRemoveChange,
|
||||||
NodeSelectionChange,
|
NodeSelectionChange,
|
||||||
Position
|
EdgeRemoveChange
|
||||||
} from 'reactflow';
|
} from 'reactflow';
|
||||||
import { EDGE_TYPE, FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
import { EDGE_TYPE, FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
||||||
import 'reactflow/dist/style.css';
|
import 'reactflow/dist/style.css';
|
||||||
@@ -276,6 +276,7 @@ export const useWorkflow = () => {
|
|||||||
const { isDowningCtrl } = useKeyboard();
|
const { isDowningCtrl } = useKeyboard();
|
||||||
const {
|
const {
|
||||||
setConnectingEdge,
|
setConnectingEdge,
|
||||||
|
edges,
|
||||||
nodes,
|
nodes,
|
||||||
nodeList,
|
nodeList,
|
||||||
onNodesChange,
|
onNodesChange,
|
||||||
@@ -413,38 +414,29 @@ export const useWorkflow = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* node */
|
/* node */
|
||||||
const handleRemoveNode = useMemoizedFn((change: NodeRemoveChange, node: Node) => {
|
const handleRemoveNode = useMemoizedFn((change: NodeRemoveChange, nodeId: string) => {
|
||||||
if (node.data.forbidDelete) {
|
|
||||||
toast({
|
|
||||||
status: 'warning',
|
|
||||||
title: t('common:core.workflow.Can not delete node')
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the node has child nodes, remove the child nodes
|
// If the node has child nodes, remove the child nodes
|
||||||
const childNodes = nodes.filter((n) => n.data.parentNodeId === node.id);
|
const childNodes = nodes.filter((n) => n.data.parentNodeId === nodeId);
|
||||||
if (childNodes.length > 0) {
|
if (childNodes.length > 0) {
|
||||||
const childNodeIds = childNodes.map((n) => n.id);
|
const childNodeIds = childNodes.map((node) => node.id);
|
||||||
const childNodesChange = childNodes.map((node) => ({
|
const childEdges = edges.filter(
|
||||||
...change,
|
(edge) => childNodeIds.includes(edge.source) || childNodeIds.includes(edge.target)
|
||||||
|
);
|
||||||
|
|
||||||
|
onNodesChange(
|
||||||
|
childNodes.map<NodeRemoveChange>((node) => ({
|
||||||
|
type: 'remove',
|
||||||
id: node.id
|
id: node.id
|
||||||
}));
|
}))
|
||||||
onNodesChange(childNodesChange);
|
);
|
||||||
setEdges((state) =>
|
onEdgesChange(
|
||||||
state.filter(
|
childEdges.map<EdgeRemoveChange>((edge) => ({
|
||||||
(edge) =>
|
type: 'remove',
|
||||||
edge.source !== change.id &&
|
id: edge.id
|
||||||
edge.target !== change.id &&
|
}))
|
||||||
!childNodeIds.includes(edge.source) &&
|
|
||||||
!childNodeIds.includes(edge.target)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEdges((state) =>
|
|
||||||
state.filter((edge) => edge.source !== change.id && edge.target !== change.id)
|
|
||||||
);
|
|
||||||
onNodesChange([change]);
|
onNodesChange([change]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -516,9 +508,20 @@ export const useWorkflow = () => {
|
|||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
if (change.type === 'remove') {
|
if (change.type === 'remove') {
|
||||||
const node = nodes.find((n) => n.id === change.id);
|
const node = nodes.find((n) => n.id === change.id);
|
||||||
// 如果删除失败,则不继续执行
|
if (!node) continue;
|
||||||
node && handleRemoveNode(change, node);
|
|
||||||
return;
|
const parentNodeDeleted = changes.find(
|
||||||
|
(c) => c.type === 'remove' && c.id === node?.data.parentNodeId
|
||||||
|
);
|
||||||
|
// Forbidden delete && Parents are not deleted together
|
||||||
|
if (node.data.forbidDelete && !parentNodeDeleted) {
|
||||||
|
toast({
|
||||||
|
status: 'warning',
|
||||||
|
title: t('common:core.workflow.Can not delete node')
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
handleRemoveNode(change, node.id);
|
||||||
} else if (change.type === 'select') {
|
} else if (change.type === 'select') {
|
||||||
handleSelectNode(change);
|
handleSelectNode(change);
|
||||||
} else if (change.type === 'position') {
|
} else if (change.type === 'position') {
|
||||||
@@ -529,8 +532,8 @@ export const useWorkflow = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// default changes
|
// Remove separately
|
||||||
onNodesChange(changes);
|
onNodesChange(changes.filter((c) => c.type !== 'remove'));
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleEdgeChange = useCallback(
|
const handleEdgeChange = useCallback(
|
||||||
|
@@ -257,7 +257,7 @@ export function RenderHttpProps({
|
|||||||
appDetail,
|
appDetail,
|
||||||
t
|
t
|
||||||
});
|
});
|
||||||
}, [nodeList, edges, inputs, t]);
|
}, [nodeId, nodeList, edges, appDetail, t]);
|
||||||
|
|
||||||
const variableText = useMemo(() => {
|
const variableText = useMemo(() => {
|
||||||
return variables
|
return variables
|
||||||
|
@@ -65,7 +65,7 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
|
|||||||
appDetail,
|
appDetail,
|
||||||
t
|
t
|
||||||
});
|
});
|
||||||
}, [nodeList, edges, inputs, t]);
|
}, [nodeId, nodeList, edges, appDetail, t]);
|
||||||
|
|
||||||
const updateList = useMemo(
|
const updateList = useMemo(
|
||||||
() =>
|
() =>
|
||||||
|
@@ -25,7 +25,7 @@ const TextareaRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
|
|||||||
appDetail,
|
appDetail,
|
||||||
t
|
t
|
||||||
});
|
});
|
||||||
}, [nodeList, edges, inputs, t]);
|
}, [nodeId, nodeList, edges, appDetail, t]);
|
||||||
|
|
||||||
const onChange = useCallback(
|
const onChange = useCallback(
|
||||||
(e: string) => {
|
(e: string) => {
|
||||||
|
Reference in New Issue
Block a user