-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): handle threads (#763)
* feat(dashboard): handle StartThread, StartMultipleThreads and WaitForThreads * test(dashboard): add test to concatWfRunIds util
- Loading branch information
Showing
19 changed files
with
303 additions
and
90 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
dashboard-new/src/app/(authenticated)/wfRun/[...ids]/components/Details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...w/src/app/(authenticated)/wfSpec/[...props]/components/NodeTypes/StartMultipleThreads.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { getVariable } from '@/app/utils' | ||
import { PlusIcon } from '@heroicons/react/16/solid' | ||
import { FC, memo } from 'react' | ||
import { Handle, Position } from 'reactflow' | ||
import { NodeProps } from '.' | ||
import { useThread } from '../../hooks/useThread' | ||
import { Fade } from './Fade' | ||
import { NodeDetails } from './NodeDetails' | ||
|
||
const Node: FC<NodeProps> = ({ data }) => { | ||
const { fade } = data | ||
const { setThread } = useThread() | ||
if (data.startMultipleThreads === undefined) return | ||
const variables = Object.entries(data.startMultipleThreads.variables) | ||
return ( | ||
<> | ||
<NodeDetails> | ||
<div className="flex items-center items-center gap-1 text-nowrap"> | ||
<h3 className="font-bold">StartMultipleThread</h3> | ||
{data.nodeRun === undefined ? ( | ||
<button | ||
className="block whitespace-nowrap text-blue-500 hover:underline" | ||
onClick={() => setThread({ name: data.startMultipleThreads?.threadSpecName || '', number: 0 })} | ||
> | ||
{data.startMultipleThreads?.threadSpecName} | ||
</button> | ||
) : ( | ||
<div>{data.startMultipleThreads?.threadSpecName}</div> | ||
)} | ||
</div> | ||
<div className=""> | ||
<span className="font-bold">Iterable:</span> {getVariable(data.startMultipleThreads.iterable)} | ||
</div> | ||
{variables.length > 0 && ( | ||
<div className="mt-2"> | ||
<h2 className="font-bold">Variables</h2> | ||
<ul> | ||
{variables.map(([name, value]) => ( | ||
<li key={name}> | ||
{`{${name}}`} {getVariable(value)} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
)} | ||
|
||
{data.nodeRun && ( | ||
<div className="mt-2"> | ||
<h2 className="font-bold">Thread Runs</h2> | ||
<ul> | ||
{data.nodeRun.startMultipleThreads?.childThreadIds.map(number => ( | ||
<li | ||
className="cursor-pointer text-blue-500 hover:underline" | ||
onClick={() => { | ||
setThread({ name: data.startMultipleThreads?.threadSpecName || '', number }) | ||
}} | ||
key={number} | ||
> | ||
{data.nodeRun?.startMultipleThreads?.threadSpecName}-{number} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
)} | ||
</NodeDetails> | ||
<Fade fade={fade} status={data.nodeRun?.status}> | ||
<div className="relative cursor-pointer"> | ||
<div className="ml-1 flex h-6 w-6 rotate-45 items-center justify-center border-[2px] border-gray-500 bg-gray-200"> | ||
<PlusIcon className="h-5 w-5 rotate-45 fill-gray-500" /> | ||
</div> | ||
</div> | ||
<Handle type="source" position={Position.Right} className="bg-transparent" /> | ||
<Handle type="target" position={Position.Left} className="bg-transparent" /> | ||
</Fade> | ||
</> | ||
) | ||
} | ||
|
||
export const StartMultipleThreads = memo(Node) |
51 changes: 38 additions & 13 deletions
51
dashboard-new/src/app/(authenticated)/wfSpec/[...props]/components/NodeTypes/StartThread.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
dashboard-new/src/app/(authenticated)/wfSpec/[...props]/components/NodeTypes/Task.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
dashboard-new/src/app/(authenticated)/wfSpec/[...props]/components/NodeTypes/UserTask.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.