Skip to content

Commit e16d4a8

Browse files
author
Nico Sammito
authored
Merge pull request #94 from code0-tech/feat/#74
The flow creation menu shows regardless of no flow type is set
2 parents 3ad4a3e + 856574d commit e16d4a8

3 files changed

Lines changed: 50 additions & 29 deletions

File tree

src/app/(flow)/namespace/[namespaceId]/project/[projectId]/flow/page.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ export default function Page() {
4343
Go back to project overview
4444
</Button>
4545
</Link>
46-
<Button color={"success"}>
47-
Create new flow
48-
</Button>
4946
</Flex>
5047
<Spacing spacing={"xl"}/>
5148
<Text size={"xl"} hierarchy={"primary"}>Or start from a template</Text>

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

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {startTransition} from "react";
2-
import {FlowType, NamespaceProject} from "@code0-tech/sagittarius-graphql-types";
2+
import {FlowType, Namespace, NamespaceProject} from "@code0-tech/sagittarius-graphql-types";
33
import {IconArrowDown, IconArrowUp, IconCornerDownLeft, IconFile} from "@tabler/icons-react";
44
import {
55
Badge,
@@ -10,7 +10,8 @@ import {
1010
DialogContent,
1111
DialogOverlay,
1212
DialogPortal,
13-
Flex, hashToColor,
13+
Flex,
14+
hashToColor,
1415
InputDescription,
1516
InputLabel,
1617
InputMessage,
@@ -34,6 +35,7 @@ import {useParams, useRouter} from "next/navigation";
3435
import {ProjectService} from "@edition/project/services/Project.service";
3536
import {RuntimeService} from "@edition/runtime/services/Runtime.service";
3637
import {FlowService} from "@edition/flow/services/Flow.service";
38+
import Link from "next/link";
3739

3840
export interface FlowCreateDialogComponentProps {
3941
open?: boolean
@@ -55,6 +57,8 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
5557
const runtimeService = useService(RuntimeService)
5658
const runtimeStore = useStore(RuntimeService)
5759

60+
const namespaceIndex = params.namespaceId as any as number
61+
const namespaceId: Namespace['id'] = `gid://sagittarius/Namespace/${namespaceIndex}`
5862
const projectIndex = params.projectId as any as number
5963
const projectId: NamespaceProject['id'] = `gid://sagittarius/NamespaceProject/${projectIndex}`
6064

@@ -76,7 +80,7 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
7680
)
7781

7882
const primaryRuntime = React.useMemo(
79-
() => runtimeService.values({namespaceId: project?.namespace?.id}).find(runtime => runtime.id == project?.primaryRuntime?.id),
83+
() => [...runtimeService.values(), ...runtimeService.values({namespaceId: project?.namespace?.id})].find(runtime => runtime.id == project?.primaryRuntime?.id),
8084
[project, runtimeStore]
8185
)
8286

@@ -152,15 +156,44 @@ export const FlowCreateDialogComponent: React.FC<FlowCreateDialogComponentProps>
152156
<Button color={"tertiary"}>No, go back!</Button>
153157
</DialogClose>
154158
<ButtonGroup color={"tertiary"}>
155-
<Button color={"tertiary"} variant={"filled"}>
156-
<Text>Assign</Text>
157-
</Button>
158-
<Button color={"tertiary"} variant={"filled"}>
159-
<Text>Create</Text>
160-
</Button>
159+
<Link href={`/namespace/${namespaceIndex}/project/${projectIndex}/settings`}>
160+
<Button color={"info"} variant={"none"}>
161+
<Text>Assign</Text>
162+
</Button>
163+
</Link>
164+
<Link href={`/namespace/${namespaceIndex}/runtimes/create`}>
165+
<Button color={"success"} variant={"none"}>
166+
<Text>Create</Text>
167+
</Button>
168+
</Link>
161169
</ButtonGroup>
162170
</Flex>
163-
</> : (
171+
</> : flowTypes.length <= 0 ? (
172+
<>
173+
<Text size={"md"}>
174+
Their is no flow type available for the primary runtime, assign and/or create another
175+
runtime to be able to create flows.
176+
</Text>
177+
<Spacing spacing={"xl"}/>
178+
<Flex justify={"space-between"} align={"center"}>
179+
<DialogClose asChild>
180+
<Button color={"tertiary"}>No, go back!</Button>
181+
</DialogClose>
182+
<ButtonGroup color={"tertiary"}>
183+
<Link href={`/namespace/${namespaceIndex}/project/${projectIndex}/settings`}>
184+
<Button color={"info"} variant={"none"}>
185+
<Text>Assign</Text>
186+
</Button>
187+
</Link>
188+
<Link href={`/namespace/${namespaceIndex}/runtimes/create`}>
189+
<Button color={"success"} variant={"none"}>
190+
<Text>Create</Text>
191+
</Button>
192+
</Link>
193+
</ButtonGroup>
194+
</Flex>
195+
</>
196+
) : (
164197
<>
165198
<InputLabel>Type of flow</InputLabel>
166199
<InputDescription>You can choose a flow type here</InputDescription>

src/packages/ce/src/flow/views/FlowFolderView.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,13 @@ export const FlowFolderView: React.FC = () => {
8989
</Button>
9090
</Flex>
9191
<Flex style={{gap: "0.35rem"}} align={"center"} justify={"space-between"}>
92-
<Tooltip>
93-
<TooltipTrigger asChild>
94-
<Button color={"tertiary"} paddingSize={"xxs"} onClick={() => {
95-
setCreateDialogOpen(true)
96-
setFlowTypeId(undefined)
97-
}}>
98-
<IconPlus size={13}/>
99-
</Button>
100-
</TooltipTrigger>
101-
<TooltipPortal>
102-
<TooltipContent side={"bottom"}>
103-
<Text>Add new flow</Text>
104-
<TooltipArrow/>
105-
</TooltipContent>
106-
</TooltipPortal>
107-
</Tooltip>
92+
<Button color={"tertiary"} paddingSize={"xxs"} style={{textWrap: "nowrap"}} onClick={() => {
93+
setCreateDialogOpen(true)
94+
setFlowTypeId(undefined)
95+
}}>
96+
<IconPlus size={13}/>
97+
Create flow
98+
</Button>
10899
<ButtonGroup color={"secondary"} style={{boxShadow: "none"}} p={0}>
109100
<Tooltip>
110101
<TooltipTrigger asChild>

0 commit comments

Comments
 (0)