-
Notifications
You must be signed in to change notification settings - Fork 0
Action Node Selection Done #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"root":["./src/index.ts","./src/routes/nodes.routes.ts","./src/routes/userroutes/usermiddleware.ts","./src/routes/userroutes/userroutes.ts"],"version":"5.7.3"} | ||
| {"root":["./src/index.ts","./src/routes/nodes.routes.ts","./src/routes/userRoutes/userMiddleware.ts","./src/routes/userRoutes/userRoutes.ts"],"version":"5.7.3"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { Handle, Position } from "@xyflow/react"; | ||
|
|
||
| interface ActionNodeProps { | ||
| data: { | ||
| label: string; | ||
| name?: string; | ||
| icon?: string; | ||
| type?: string; | ||
| }; | ||
| } | ||
|
|
||
| export const ActionNode = ({ data }: ActionNodeProps) => { | ||
| return ( | ||
| <div className="flex flex-col items-center justify-center p-4 bg-gray-800 border-2 border-blue-500 rounded-lg min-w-[150px]"> | ||
| <Handle type="target" position={Position.Left} /> | ||
|
|
||
| <span className="text-3xl mb-2">{data.icon || "⚙️"}</span> | ||
| <span className="text-white font-semibold">{data.name}</span> | ||
| <span className="text-gray-400 text-sm">{data.type}</span> | ||
|
|
||
| <Handle type="source" position={Position.Right} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ActionNode; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { | ||
| Sheet, | ||
| SheetContent, | ||
| SheetHeader, | ||
| SheetTitle, | ||
| } from "@workspace/ui/components/sheet"; | ||
| import { | ||
| Select, | ||
| SelectContent, | ||
| SelectItem, | ||
| SelectTrigger, | ||
| SelectValue, | ||
| } from "@workspace/ui/components/select"; | ||
| import { useActions } from "@/app/hooks/useActions"; | ||
|
|
||
| interface SideBarProps { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| onSelectAction: (action: { id: string; name: string; type: string; icon?: string }) => void; | ||
| } | ||
|
|
||
| const getAvailableActions = (actions: any): Array<any> => { | ||
| if (Array.isArray(actions)) return actions; | ||
| if (actions && Array.isArray(actions.Data)) return actions.Data; | ||
| return []; | ||
| }; | ||
|
|
||
| export const ActionSideBar = ({ isOpen, onClose, onSelectAction }: SideBarProps) => { | ||
| const { actions, loading, error } = useActions({ shouldFetch: true }); | ||
| const availableActions = getAvailableActions(actions); | ||
|
|
||
| return ( | ||
| <Sheet open={isOpen} onOpenChange={(open) => !open && onClose()}> | ||
| <SheetContent className="w-[400px] sm:w-[540px]"> | ||
| <SheetHeader> | ||
| <SheetTitle>Select an Action</SheetTitle> | ||
| </SheetHeader> | ||
|
|
||
| {loading ? ( | ||
| <p>Loading...</p> | ||
| ) : error ? ( | ||
| <p className="text-red-500">Error fetching actions</p> | ||
| ) : ( | ||
| <Select onValueChange={(value) => { | ||
| const selected = availableActions.find((a: any) => String(a.id) === value); | ||
|
||
| if (selected) { | ||
| onSelectAction({ | ||
| id: selected.id, | ||
| name: selected.name, | ||
| type: selected.type, | ||
| icon: 'icon' in selected && selected.icon ? selected.icon : '⚡', | ||
|
||
| }); | ||
| onClose(); | ||
| } | ||
| }}> | ||
| <SelectTrigger className="w-full mt-4"> | ||
| <SelectValue placeholder="Select Action" /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| {availableActions.length ? ( | ||
| availableActions.map((action: any) => ( | ||
|
||
| <SelectItem key={action.id} value={String(action.id)}> | ||
| {'icon' in action && action.icon ? action.icon : '⚡'} {action.name} | ||
|
||
| </SelectItem> | ||
| )) | ||
| ) : ( | ||
| <div className="px-4 py-2 text-muted-foreground"> | ||
| No actions available | ||
| </div> | ||
| )} | ||
| </SelectContent> | ||
| </Select> | ||
| )} | ||
| </SheetContent> | ||
| </Sheet> | ||
| ); | ||
| }; | ||
|
|
||
| export default ActionSideBar; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using 'any' type defeats the purpose of TypeScript's type safety. Since the 'AvailabeAction' type is already defined in workflow.types.ts, use that type instead of 'any' for proper type checking.