feat: Build options for the component id field of the Switch operator #1739 (#2037)

### What problem does this PR solve?

feat: Build options for the component id field of the Switch operator
#1739

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-08-21 17:15:24 +08:00
committed by GitHub
parent 6c26872799
commit 9b3f5fd38b
10 changed files with 59 additions and 47 deletions

View File

@ -563,3 +563,26 @@ export const useWatchNodeFormDataChange = () => {
buildSwitchEdgesByFormData,
]);
};
// exclude nodes with branches
const ExcludedNodes = [
Operator.Categorize,
Operator.Relevant,
Operator.Begin,
Operator.Answer,
];
export const useBuildComponentIdSelectOptions = (nodeId?: string) => {
const nodes = useGraphStore((state) => state.nodes);
const options = useMemo(() => {
return nodes
.filter(
(x) =>
x.id !== nodeId && !ExcludedNodes.some((y) => y === x.data.label),
)
.map((x) => ({ label: x.data.name, value: x.id }));
}, [nodes, nodeId]);
return options;
};