Skip to content

Commit 69981f0

Browse files
authored
Merge pull request #245 from code0-tech/feat/#244
SubFlowValue from NodeFunction doesn't save
2 parents 368f018 + 016101d commit 69981f0

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/packages/ce/src/datatype/components/inputs/sub-flow/DataTypeSubFlowInputComponent.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import lodash from "lodash"
66
import {useFunctionSuggestions} from "@edition/function/hooks/Function.suggestion.hook";
77
import {DataTypeInputValueComponent} from "@edition/datatype/components/inputs/DataTypeInputValueComponent";
88
import {SuggestionDialogComponent} from "@edition/function/components/suggestion/SuggestionDialogComponent";
9-
import {Flow, LiteralValue, NodeFunction, ReferenceValue, SubFlowValue} from "@code0-tech/sagittarius-graphql-types";
9+
import {Flow, LiteralValue, ReferenceValue, SubFlowValue} from "@code0-tech/sagittarius-graphql-types";
1010
import {FlowService} from "@edition/flow/services/Flow.service";
1111
import {useParams} from "next/navigation";
1212

@@ -31,11 +31,11 @@ export const DataTypeSubFlowInputComponent: React.FC<DataTypeSubFlowInputCompone
3131
const [suggestionDialogOpen, setSuggestionDialogOpen] = React.useState(false)
3232
const result = useFunctionSuggestions()
3333

34-
const onChangeDebounced = useDebouncedCallback((value: LiteralValue | SubFlowValue | ReferenceValue | NodeFunction | null) => {
34+
const onChangeDebounced = useDebouncedCallback((value: LiteralValue | SubFlowValue | ReferenceValue | null) => {
3535
onChange?.(value ?? null)
3636
}, 200)
3737

38-
return React.useMemo(() => <>
38+
return <>
3939
<SuggestionDialogComponent suggestions={[...suggestions!, ...result]}
4040
open={suggestionDialogOpen}
4141
onSuggestionSelect={value => {
@@ -47,7 +47,7 @@ export const DataTypeSubFlowInputComponent: React.FC<DataTypeSubFlowInputCompone
4747
}
4848
}
4949
formValidation?.setValue?.(value ?? null)
50-
onChangeDebounced(value as NodeFunction)
50+
onChangeDebounced(value as SubFlowValue)
5151
}}
5252
onOpenChange={setSuggestionDialogOpen}/>
5353
<InputLabel>{title}</InputLabel>
@@ -69,11 +69,11 @@ export const DataTypeSubFlowInputComponent: React.FC<DataTypeSubFlowInputCompone
6969
}
7070
}
7171
formValidation?.setValue?.(value ?? null)
72-
onChangeDebounced(value ?? null)
72+
onChangeDebounced(value as SubFlowValue)
7373
}}
7474
suggestions={suggestions}
7575
formValidation={formValidation}>
7676
<Text>Select next node</Text>
7777
</DataTypeInputValueComponent>
78-
</>, [formValidation, defaultValue, suggestionDialogOpen])
78+
</>
7979
}

src/packages/ce/src/function/components/files/FunctionFileDefaultComponent.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import {Alert, Spacing, Text, useForm, useService} from "@code0-tech/pictor";
2+
import {Alert, Spacing, Text, useForm, useService, useStore} from "@code0-tech/pictor";
33
import {
44
Flow,
55
LiteralValue,
@@ -10,6 +10,7 @@ import {
1010
} from "@code0-tech/sagittarius-graphql-types";
1111
import {useFlowValidation} from "@edition/flow/hooks/Flow.validation.hook";
1212
import {FlowService} from "@edition/flow/services/Flow.service";
13+
import {FunctionService} from "@edition/function/services/Function.service";
1314
import {DataTypeInputComponent} from "@edition/datatype/components/inputs/DataTypeInputComponent";
1415
import {
1516
FALLBACK_FUNCTION_DESCRIPTION,
@@ -21,21 +22,29 @@ import {useNodes} from "@xyflow/react";
2122
import {NodeSchema} from "@code0-tech/triangulum";
2223

2324
export interface FunctionFileDefaultComponentProps {
24-
node: NodeFunction
25+
nodeId: NodeFunction['id']
2526
flowId: Flow['id']
2627
}
2728

2829
export const FunctionFileDefaultComponent: React.FC<FunctionFileDefaultComponentProps> = (props) => {
2930

30-
const {node, flowId} = props
31+
const {nodeId, flowId} = props
3132

3233
const flowService = useService(FlowService)
34+
const flowStore = useStore(FlowService)
35+
const functionService = useService(FunctionService)
36+
const functionStore = useStore(FunctionService)
3337
const validation = useFlowValidation(flowId)
3438
const changedParameter = React.useRef<Set<string>>(new Set())
3539

40+
const node = React.useMemo(
41+
() => flowService.getNodeById(flowId, nodeId)!,
42+
[flowService, flowStore, flowId, nodeId]
43+
)
44+
3645
const definition = React.useMemo(
37-
() => node.functionDefinition!,
38-
[node.functionDefinition]
46+
() => functionService.getById(node?.functionDefinition?.id!)!,
47+
[functionService, functionStore, node?.functionDefinition?.id]
3948
)
4049

4150
const initialValues = React.useMemo(() => {

src/packages/ce/src/function/components/files/FunctionFilesComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const FunctionFilesComponent: React.FC<FunctionFilesComponentProps> = (pr
184184
h={"100%"}
185185
value={node?.id!}
186186
key={node?.id!}>
187-
<FunctionFileDefaultComponent node={node!} flowId={flowId}/>
187+
<FunctionFileDefaultComponent nodeId={node?.id!} flowId={flowId}/>
188188
</FileTabsContent>
189189
})
190190
}

0 commit comments

Comments
 (0)