perf: disabled change version when change version name (#2497)
* perf: disabled change version when change version name * fix * fix * toast condition
This commit is contained in:
parent
ad63210f45
commit
bb7adc96ed
@ -123,7 +123,7 @@ const NodeTemplatesModal = ({ isOpen, onClose }: ModuleTemplateListProps) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
manual: false,
|
manual: false,
|
||||||
refreshDeps: [members, basicNodeTemplates, nodeList, hasToolNode, templateType]
|
refreshDeps: [basicNodeTemplates, nodeList, hasToolNode, templateType]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const {
|
const {
|
||||||
@ -168,7 +168,7 @@ const NodeTemplatesModal = ({ isOpen, onClose }: ModuleTemplateListProps) => {
|
|||||||
setParentId(parentId);
|
setParentId(parentId);
|
||||||
setTemplateType(type);
|
setTemplateType(type);
|
||||||
},
|
},
|
||||||
refreshDeps: [searchKey, templateType]
|
refreshDeps: [members, searchKey, templateType]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useMemo } from 'react';
|
import React, { useEffect, useMemo } from 'react';
|
||||||
import { Background, ControlButton, MiniMap, Panel, useReactFlow } from 'reactflow';
|
import { Background, ControlButton, MiniMap, Panel, useReactFlow, useViewport } from 'reactflow';
|
||||||
import { useContextSelector } from 'use-context-selector';
|
import { useContextSelector } from 'use-context-selector';
|
||||||
import { WorkflowContext } from '../../context';
|
import { WorkflowContext } from '../../context';
|
||||||
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
||||||
@ -7,9 +7,11 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
|||||||
import { Box } from '@chakra-ui/react';
|
import { Box } from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import styles from './index.module.scss';
|
import styles from './index.module.scss';
|
||||||
|
import { maxZoom, minZoom } from '..';
|
||||||
|
|
||||||
const FlowController = React.memo(function FlowController() {
|
const FlowController = React.memo(function FlowController() {
|
||||||
const { fitView, zoomIn, zoomOut } = useReactFlow();
|
const { fitView, zoomIn, zoomOut } = useReactFlow();
|
||||||
|
const { zoom } = useViewport();
|
||||||
const { undo, redo, canRedo, canUndo } = useContextSelector(WorkflowContext, (v) => v);
|
const { undo, redo, canRedo, canUndo } = useContextSelector(WorkflowContext, (v) => v);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@ -111,6 +113,7 @@ const FlowController = React.memo(function FlowController() {
|
|||||||
onClick={() => zoomOut()}
|
onClick={() => zoomOut()}
|
||||||
style={buttonStyle}
|
style={buttonStyle}
|
||||||
className={`${styles.customControlButton}`}
|
className={`${styles.customControlButton}`}
|
||||||
|
disabled={zoom <= minZoom}
|
||||||
>
|
>
|
||||||
<MyIcon name={'common/subtract'} />
|
<MyIcon name={'common/subtract'} />
|
||||||
</ControlButton>
|
</ControlButton>
|
||||||
@ -124,6 +127,7 @@ const FlowController = React.memo(function FlowController() {
|
|||||||
onClick={() => zoomIn()}
|
onClick={() => zoomIn()}
|
||||||
style={buttonStyle}
|
style={buttonStyle}
|
||||||
className={`${styles.customControlButton}`}
|
className={`${styles.customControlButton}`}
|
||||||
|
disabled={zoom >= maxZoom}
|
||||||
>
|
>
|
||||||
<MyIcon name={'common/addLight'} />
|
<MyIcon name={'common/addLight'} />
|
||||||
</ControlButton>
|
</ControlButton>
|
||||||
@ -145,7 +149,7 @@ const FlowController = React.memo(function FlowController() {
|
|||||||
<Background />
|
<Background />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}, [isMac, t, undo, buttonStyle, canUndo, redo, canRedo, zoomOut, zoomIn, fitView]);
|
}, [isMac, t, undo, buttonStyle, canUndo, redo, canRedo, zoom, zoomOut, zoomIn, fitView]);
|
||||||
|
|
||||||
return Render;
|
return Render;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -259,15 +259,8 @@ export const useWorkflow = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { isDowningCtrl } = useKeyboard();
|
const { isDowningCtrl } = useKeyboard();
|
||||||
const {
|
const { setConnectingEdge, nodes, onNodesChange, setEdges, onEdgesChange, setHoverEdgeId } =
|
||||||
setConnectingEdge,
|
useContextSelector(WorkflowContext, (v) => v);
|
||||||
nodes,
|
|
||||||
setNodes,
|
|
||||||
onNodesChange,
|
|
||||||
setEdges,
|
|
||||||
onEdgesChange,
|
|
||||||
setHoverEdgeId
|
|
||||||
} = useContextSelector(WorkflowContext, (v) => v);
|
|
||||||
|
|
||||||
/* helper line */
|
/* helper line */
|
||||||
const [helperLineHorizontal, setHelperLineHorizontal] = useState<THelperLine>();
|
const [helperLineHorizontal, setHelperLineHorizontal] = useState<THelperLine>();
|
||||||
|
|||||||
@ -18,6 +18,9 @@ import { useWorkflow } from './hooks/useWorkflow';
|
|||||||
import HelperLines from './components/HelperLines';
|
import HelperLines from './components/HelperLines';
|
||||||
import FlowController from './components/FlowController';
|
import FlowController from './components/FlowController';
|
||||||
|
|
||||||
|
export const minZoom = 0.1;
|
||||||
|
export const maxZoom = 1.5;
|
||||||
|
|
||||||
const NodeSimple = dynamic(() => import('./nodes/NodeSimple'));
|
const NodeSimple = dynamic(() => import('./nodes/NodeSimple'));
|
||||||
const nodeTypes: Record<FlowNodeTypeEnum, any> = {
|
const nodeTypes: Record<FlowNodeTypeEnum, any> = {
|
||||||
[FlowNodeTypeEnum.emptyNode]: NodeSimple,
|
[FlowNodeTypeEnum.emptyNode]: NodeSimple,
|
||||||
@ -112,8 +115,8 @@ const Workflow = () => {
|
|||||||
fitView
|
fitView
|
||||||
nodes={nodes}
|
nodes={nodes}
|
||||||
edges={edges}
|
edges={edges}
|
||||||
minZoom={0.1}
|
minZoom={minZoom}
|
||||||
maxZoom={1.5}
|
maxZoom={maxZoom}
|
||||||
defaultEdgeOptions={defaultEdgeOptions}
|
defaultEdgeOptions={defaultEdgeOptions}
|
||||||
elevateEdgesOnSelect
|
elevateEdgesOnSelect
|
||||||
connectionLineStyle={connectionLineStyle}
|
connectionLineStyle={connectionLineStyle}
|
||||||
|
|||||||
@ -86,6 +86,7 @@ const MyEdit = () => {
|
|||||||
chatConfig: initialSnapshot.chatConfig,
|
chatConfig: initialSnapshot.chatConfig,
|
||||||
customTitle: t(`app:app.version_initial_copy`)
|
customTitle: t(`app:app.version_initial_copy`)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
resetSnapshot(initialSnapshot);
|
resetSnapshot(initialSnapshot);
|
||||||
}
|
}
|
||||||
@ -124,6 +125,7 @@ const MyEdit = () => {
|
|||||||
if (res) {
|
if (res) {
|
||||||
resetSnapshot(item);
|
resetSnapshot(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: t('workflow:workflow.Switch_success'),
|
title: t('workflow:workflow.Switch_success'),
|
||||||
status: 'success'
|
status: 'success'
|
||||||
@ -245,7 +247,7 @@ const TeamCloud = () => {
|
|||||||
_hover={{
|
_hover={{
|
||||||
bg: 'primary.50'
|
bg: 'primary.50'
|
||||||
}}
|
}}
|
||||||
onClick={() => onChangeVersion(item)}
|
onClick={() => editIndex === undefined && onChangeVersion(item)}
|
||||||
>
|
>
|
||||||
<MyPopover
|
<MyPopover
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user