'use client'; import { Suspense, useState } from 'react'; import { useRouter, useSearchParams } from 'next/navigation'; import { IconCloud, IconServer } from '@tabler/icons-react'; import { Button } from '@kandev/ui/button'; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@kandev/ui/card'; import { Input } from '@kandev/ui/input'; import { Label } from '@kandev/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@kandev/ui/select'; import { Separator } from '@kandev/ui/separator'; import { createExecutorAction } from '@/app/actions/executors'; import { getWebSocketClient } from '@/lib/ws/connection'; import { useAppStore } from '@/components/state-provider'; import type { Executor } from '@/lib/types/http'; const EXECUTOR_TYPES = ['local_docker'] as const; type ExecutorType = (typeof EXECUTOR_TYPES)[number]; export default function ExecutorCreatePage() { return ( Loading...}> ); } function ExecutorCreatePageContent() { const router = useRouter(); const searchParams = useSearchParams(); const initialType = searchParams.get('type'); const [type, setType] = useState(() => { if (EXECUTOR_TYPES.includes(initialType as ExecutorType)) { return initialType as ExecutorType; } return 'local_docker'; }); const [name, setName] = useState('Local Docker'); const [dockerHost, setDockerHost] = useState('unix:///var/run/docker.sock'); const [isCreating, setIsCreating] = useState(false); const executors = useAppStore((state) => state.executors.items); const setExecutors = useAppStore((state) => state.setExecutors); const handleCreate = async () => { if (type !== 'local_docker') { return; } setIsCreating(true); try { const payload = { name, type, status: 'active', config: { docker_host: dockerHost }, }; const client = getWebSocketClient(); const created = client ? await client.request('executor.create', payload) : await createExecutorAction(payload); setExecutors([...executors.filter((item) => item.id !== created.id), created]); router.push('/settings/executors'); } finally { setIsCreating(false); } }; return ( Create Executor Choose an executor type to run environments on your infrastructure. {type === 'local_docker' ? : } {type === 'local_docker' ? 'Local Docker Executor' : 'Remote Docker Executor'} {type === 'local_docker' ? 'Uses the local Docker daemon on this machine.' : 'Connects to a remote Docker host (coming soon).'} Executor type setType(value as ExecutorType)}> Local Docker Executor name setName(event.target.value)} /> Docker host env value setDockerHost(event.target.value)} placeholder="unix:///var/run/docker.sock" disabled={type !== 'local_docker'} /> Repositories will be mounted as volumes at runtime. router.push('/settings/executors')}> Cancel {isCreating ? 'Creating...' : 'Create Executor'} ); }
Choose an executor type to run environments on your infrastructure.
Repositories will be mounted as volumes at runtime.