feat: get the operator type from id #918 (#1323)

### What problem does this PR solve?

feat: get the operator type from id #918

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-07-01 10:27:32 +08:00
committed by GitHub
parent fc7cc1d36c
commit 4542346f18
6 changed files with 521 additions and 15 deletions

View File

@ -27,7 +27,7 @@ import { humanId } from 'human-id';
import { useParams } from 'umi';
import { NodeMap, Operator, RestrictedUpstreamMap } from './constant';
import useGraphStore, { RFState } from './store';
import { buildDslComponentsByGraph, getOperatorTypeFromId } from './utils';
import { buildDslComponentsByGraph } from './utils';
const selector = (state: RFState) => ({
nodes: state.nodes,
@ -249,7 +249,7 @@ export const useSetLlmSetting = (form?: FormInstance) => {
};
export const useValidateConnection = () => {
const edges = useGraphStore((state) => state.edges);
const { edges, getOperatorTypeFromId } = useGraphStore((state) => state);
// restricted lines cannot be connected successfully.
const isValidConnection = useCallback(
(connection: Connection) => {
@ -265,7 +265,7 @@ export const useValidateConnection = () => {
]?.every((x) => x !== getOperatorTypeFromId(connection.target));
return ret;
},
[edges],
[edges, getOperatorTypeFromId],
);
return isValidConnection;