Skip to content

Commit 0abcc8b

Browse files
authored
Merge pull request #137 from code0-tech/feat/#136
Flow creation dialog does not differentiate between no active runtime and no flow types available
2 parents 8bbeb80 + 2ae04f3 commit 0abcc8b

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

src/packages/ce/src/flow/components/FlowCreateDialogComponent.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {startTransition} from "react";
2-
import {FlowType, Namespace, NamespaceProject} from "@code0-tech/sagittarius-graphql-types";
3-
import {IconArrowDown, IconArrowUp, IconCornerDownLeft, IconFile} from "@tabler/icons-react";
2+
import {FlowType, NamespaceProject} from "@code0-tech/sagittarius-graphql-types";
3+
import {IconArrowDown, IconArrowUp, IconCornerDownLeft} from "@tabler/icons-react";
44
import {
55
Badge,
66
Button,
@@ -31,11 +31,12 @@ import {
3131
import {FlowTypeService} from "@edition/flowtype/services/FlowType.service";
3232
import {FlowNameInputComponent} from "@edition/flow/components/FlowNameInputComponent";
3333
import {ButtonGroup} from "@code0-tech/pictor/dist/components/button-group/ButtonGroup";
34-
import {useParams, useRouter} from "next/navigation";
34+
import {useParams} from "next/navigation";
3535
import {ProjectService} from "@edition/project/services/Project.service";
3636
import {RuntimeService} from "@edition/runtime/services/Runtime.service";
3737
import {FlowService} from "@edition/flow/services/Flow.service";
3838
import Link from "next/link";
39+
import {icon, IconString} from "@core/util/icons";
3940

4041
export interface FlowCreateDialogComponentProps {
4142
open?: boolean
@@ -48,7 +49,6 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
4849
const {open, onOpenChange, flowTypeId} = props
4950

5051
const params = useParams()
51-
const router = useRouter()
5252
const flowService = useService(FlowService)
5353
const flowTypeService = useService(FlowTypeService)
5454
const flowTypeStore = useStore(FlowTypeService)
@@ -58,7 +58,6 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
5858
const runtimeStore = useStore(RuntimeService)
5959

6060
const namespaceIndex = params.namespaceId as any as number
61-
const namespaceId: Namespace['id'] = `gid://sagittarius/Namespace/${namespaceIndex}`
6261
const projectIndex = params.projectId as any as number
6362
const projectId: NamespaceProject['id'] = `gid://sagittarius/NamespaceProject/${projectIndex}`
6463

@@ -130,7 +129,7 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
130129
return null
131130
},
132131
flowTypeId: (value) => {
133-
if (!value) return "Flow type is required"
132+
if (!value) return "Trigger is required"
134133
return null
135134
}
136135
},
@@ -140,11 +139,13 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
140139
}
141140
})
142141

142+
const SelectedFlowTypeDisplayIcon = icon(flowTypes.find(flowType => flowType.id == selectedFlowTypeId)?.displayIcon as IconString)
143+
143144
return <Dialog open={createDialogOpen} onOpenChange={(open) => onOpenChange?.(open)}>
144145
<DialogPortal>
145146
<DialogOverlay/>
146147
<DialogContent autoFocus showCloseButton
147-
title={"Create new flow"}>
148+
title={!primaryRuntime ? "Missing primary runtime" : flowTypes.length <= 0 ? "No triggers available" : "Create new flow"}>
148149
<Spacing spacing={"xl"}/>
149150
{!primaryRuntime ? <>
150151
<Text size={"md"}>
@@ -170,8 +171,9 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
170171
</Flex>
171172
</> : flowTypes.length <= 0 ? (
172173
<>
174+
<Spacing spacing={"xl"}/>
173175
<Text size={"md"}>
174-
Their is no flow type available for the primary runtime, assign and/or create another
176+
Their is no trigger available for the primary runtime, assign and/or create another
175177
runtime to be able to create flows.
176178
</Text>
177179
<Spacing spacing={"xl"}/>
@@ -195,31 +197,36 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
195197
</>
196198
) : (
197199
<>
198-
<InputLabel>Type of flow</InputLabel>
199-
<InputDescription>You can choose a flow type here</InputDescription>
200+
<InputLabel>Trigger</InputLabel>
201+
<InputDescription>You can choose a trigger here</InputDescription>
200202
<Menu>
201203
<MenuTrigger asChild>
202204
<Button w={"100%"}
203205
color={inputs.getInputProps("flowTypeId").formValidation?.valid ? "tertiary" : "error"}
204206
style={{justifyContent: "start"}}>
205207
{selectedFlowTypeId ?
206-
<IconFile size={13} color={hashToColor(selectedFlowTypeId)}/> : null}
207-
{selectedFlowType ? selectedFlowType?.names?.[0]?.content ?? "Missing name" : "Select flow type"}
208+
<SelectedFlowTypeDisplayIcon size={12}
209+
color={hashToColor(selectedFlowTypeId)}/> : null}
210+
{selectedFlowType ? selectedFlowType?.names?.[0]?.content ?? "Missing name" : "Select trigger"}
208211
</Button>
209212
</MenuTrigger>
210213
<MenuPortal>
211214
<MenuContent align={"start"}
212215
color={"secondary"}
213216
sideOffset={8}>
214217
<Card paddingSize={"xxs"} mt={-0.2} mx={-0.2}>
215-
{flowTypes.map((flowType) => (
216-
<MenuItem key={flowType.id} onSelect={() => {
218+
{flowTypes.map((flowType) => {
219+
220+
const DisplayIcon = icon(flowType?.displayIcon as IconString)
221+
222+
return <MenuItem key={flowType.id} onSelect={() => {
217223
inputs.getInputProps("flowTypeId").formValidation?.setValue(flowType.id)
218224
setSelectedFlowTypeId(flowType.id)
219225
}}>
226+
<DisplayIcon size={16}/>
220227
{flowType.names?.[0]?.content ?? "Missing name"}
221228
</MenuItem>
222-
))}
229+
})}
223230
</Card>
224231
<MenuLabel>
225232
<Flex style={{gap: ".35rem"}}>

0 commit comments

Comments
 (0)