Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(new-service): a real three-step wizard, not a form-wall

Juan Denisbd87b06a60e7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 410c3c48..1a370fb1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,22 @@ awaiting a stable release:
### Added
+- **New Service is a real three-step wizard, and Templates is one catalog** —
+ `/services/new` was a form-wall that rendered everything at once (a "Ready to
+ Import" rail of placeholder rows, a decorative Connect→Detect→Deploy strip,
+ two boilerplate note boxes). It is now a slim stepper — **Source → Connect →
+ Review** — in one centered column; nothing renders until it has real data, and
+ the `?template=`/`?source=` deep links land preloaded on Connect. Deploy
+ templates are no longer a hardcoded frontend constant: they live in the backend
+ catalog as `kind: repo` YAML entries (starting with AgentSite) that blend into
+ the one Templates grid alongside the 105 one-click templates, each badged
+ **Git repo** vs **One-click**. The Templates page adopts the Marketplace
+ treatment — topbar search + a filter drawer (category, type, sort) with a row
+ of quick category chips — replacing the stacked "Deploy templates" section and
+ the "More +95" chip wall. A new `GET /api/v1/templates/<id>/manifest` inspects
+ a repo template's **public** repository (no clone, no OAuth) for deploy
+ manifests and falls back to the template's declared hints, clearly labeled.
+ The old `#deploy-templates` anchor redirects to the repo-filtered grid.
- **`serverkit.yaml` — build services from a Dockerfile (`dockerfilePath`)** —
a manifest service can now declare `dockerfilePath: services/api/Dockerfile`
as a third image source next to buildpacks and BYO `image:`. This is the
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 0f534d2b..572a95fc 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -25,7 +25,7 @@ import FileManager from './pages/FileManager';
import CronJobs from './pages/CronJobs';
import Security from './pages/Security';
import Services from './pages/Services';
-import NewService from './pages/NewService';
+import NewService from './pages/new-service/NewService';
import ImportWizard from './pages/ImportWizard';
import Coexistence from './pages/Coexistence';
import ServiceDetail from './pages/ServiceDetail';
diff --git a/frontend/src/data/deployTemplates.js b/frontend/src/data/deployTemplates.js
deleted file mode 100644
index c47eff18..00000000
--- a/frontend/src/data/deployTemplates.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// Shared deploy-template catalog. One source of truth consumed by both the
-// New Service wizard ("Deploy Template" source) and the Templates tab
-// ("Deploy templates" section), so there is one list with two entry points.
-//
-// `example: true` marks a demonstration entry (badged "Example" in the UI).
-// Real curated templates can be appended here as they are added.
-
-export const DEPLOY_TEMPLATES = [
- {
- id: 'agentsite',
- name: 'AgentSite',
- serviceName: 'agentsite',
- description: 'AI-powered website builder with multi-agent orchestration.',
- repoUrl: 'https://github.com/jhd3197/AgentSite.git',
- branch: 'main',
- appType: 'docker',
- buildMethod: 'dockerfile',
- port: 6391,
- example: true,
- badges: ['Render', 'Railway', 'Compose', 'Dockerfile'],
- manifest: {
- strategy: 'docker_compose',
- recommended: {
- app_type: 'docker',
- build_method: 'dockerfile',
- port: 6391,
- dockerfile_path: 'Dockerfile',
- healthcheck_path: '/api/health',
- },
- manifests: [
- { type: 'docker_compose', file: 'docker-compose.yml', label: 'Docker Compose', summary: 'agentsite service on port 6391' },
- { type: 'render', file: 'render.yaml', label: 'Render blueprint', summary: 'agentsite web service using docker' },
- { type: 'railway', file: 'railway.json', label: 'Railway config', summary: 'Dockerfile build with health check' },
- { type: 'app_json', file: 'app.json', label: 'App manifest', summary: 'AI-powered website builder using multi-agent orchestration' },
- ],
- env: [
- { key: 'OPENAI_API_KEY', required: true, secret: true, source: 'render.yaml' },
- { key: 'CLAUDE_API_KEY', required: true, secret: true, source: 'render.yaml' },
- { key: 'GOOGLE_API_KEY', required: true, secret: true, source: 'render.yaml' },
- { key: 'GROQ_API_KEY', required: true, secret: true, source: 'render.yaml' },
- { key: 'GROK_API_KEY', required: true, secret: true, source: 'render.yaml' },
- { key: 'OPENROUTER_API_KEY', required: true, secret: true, source: 'render.yaml' },
- ],
- ports: [6391],
- },
- },
-];
-
-export function getDeployTemplate(id) {
- return DEPLOY_TEMPLATES.find((t) => t.id === id) || null;
-}
-
-export default DEPLOY_TEMPLATES;
diff --git a/frontend/src/pages/NewService.jsx b/frontend/src/pages/NewService.jsx
deleted file mode 100644
index 3b32dad0..00000000
--- a/frontend/src/pages/NewService.jsx
+++ /dev/null
@@ -1,1326 +0,0 @@
-import { useCallback, useEffect, useMemo, useState } from 'react';
-import { Link, useNavigate, useSearchParams } from 'react-router-dom';
-import {
- ArrowRight,
- CheckCircle2,
- ChevronDown,
- Database,
- FileArchive,
- FolderOpen,
- GitBranch,
- Globe,
- Link2,
- Lock,
- Network,
- Package,
- RefreshCw,
- Rocket,
- Search,
- Server,
- Settings2,
- ShieldCheck,
- Zap,
-} from 'lucide-react';
-import { SiGithub } from 'react-icons/si';
-import api from '../services/api';
-import { useToast } from '../contexts/ToastContext';
-import { useTopbarActions } from '@/hooks/useTopbarActions';
-import { Button } from '@/components/ui/button';
-import { Input } from '@/components/ui/input';
-import { Label } from '@/components/ui/label';
-import { Switch } from '@/components/ui/switch';
-import BuildpackPreview from '@/components/buildpack/BuildpackPreview';
-import DocsLink from '@/components/DocsLink';
-import { DEPLOY_TEMPLATES as SERVICE_TEMPLATES, getDeployTemplate } from '@/data/deployTemplates';
-
-const APP_TYPE_OPTIONS = [
- { value: 'auto', label: 'Auto-detect' },
- { value: 'docker', label: 'Docker / Compose' },
- { value: 'flask', label: 'Python' },
- { value: 'django', label: 'Django' },
- { value: 'php', label: 'PHP' },
- { value: 'static', label: 'Static site' },
-];
-
-const BUILD_METHOD_OPTIONS = [
- { value: 'auto', label: 'Auto build' },
- { value: 'nixpacks', label: 'Nixpacks' },
- { value: 'dockerfile', label: 'Dockerfile' },
- { value: 'custom', label: 'Custom command' },
-];
-
-const APP_TYPE_LABELS = Object.fromEntries(APP_TYPE_OPTIONS.map(option => [option.value, option.label]));
-const BUILD_METHOD_LABELS = Object.fromEntries(BUILD_METHOD_OPTIONS.map(option => [option.value, option.label]));
-
-// Per-source guidance shown as an explainer strip above the selected source's
-// form: what this path does, what to have ready, and the steps that follow.
-const SOURCE_GUIDES = {
- github: {
- what: 'Deploy from a GitHub repository you own or can access.',
- need: 'A GitHub account connected via OAuth (Settings → Connections).',
- steps: ['Connect with OAuth', 'Pick a repository and branch', 'ServerKit detects the runtime and build'],
- },
- manual: {
- what: 'Deploy from any other Git remote (GitLab, Bitbucket, Gitea, or an SSH URL).',
- need: 'The repository URL, and a deploy key or credentials if it is private.',
- steps: ['Paste the remote URL', 'Choose a branch', 'ServerKit clones and detects the build'],
- },
- local: {
- what: 'Register an application that already lives on this server — no clone, no build.',
- need: 'The path on the server, and its compose file or systemd unit if any.',
- steps: ['Point at the directory or unit', 'Tell ServerKit how it is managed', 'It starts tracking the service'],
- },
- upload: {
- what: 'Deploy or update from a project zip archive uploaded from your machine.',
- need: 'A .zip of the project (with a Dockerfile/compose or a detectable runtime).',
- steps: ['Upload the archive', 'ServerKit extracts and detects the runtime', 'It builds and deploys'],
- },
- template: {
- what: 'Fast import from a manifest-ready repository — the form is prefilled for you.',
- need: 'A repo with a serverkit.yaml, Docker Compose, or another supported manifest.',
- steps: ['Pick a template', 'ServerKit reads its manifests and prefills everything', 'Review and deploy'],
- },
-};
-
-function slugify(value) {
- return value.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
-}
-
-function repoNameFromUrl(value) {
- if (!value) return '';
- const cleaned = value.trim().replace(/\.git$/, '');
- const parts = cleaned.split(/[/:]/).filter(Boolean);
- return slugify(parts[parts.length - 1] || '');
-}
-
-function normalizeManualRepo(value) {
- const trimmed = value.trim();
- if (!trimmed) return '';
- if (/^[\w.-]+\/[\w.-]+$/.test(trimmed)) return `https://github.com/${trimmed}.git`;
- if (/^github\.com\//i.test(trimmed)) return `https://${trimmed.replace(/\.git$/, '')}.git`;
- return trimmed;
-}
-
-function formatAppType(value) {
- return APP_TYPE_LABELS[value] || value || 'Auto-detect';
-}
-
-function formatBuildMethod(value) {
- return BUILD_METHOD_LABELS[value] || value || 'Auto build';
-}
-
-const NewService = () => {
- const navigate = useNavigate();
- const toast = useToast();
- const [searchParams] = useSearchParams();
- const [sourceMode, setSourceMode] = useState('github');
- const [githubStatus, setGithubStatus] = useState(null);
- const [repos, setRepos] = useState([]);
- const [reposLoading, setReposLoading] = useState(false);
- const [repoSearch, setRepoSearch] = useState('');
- const [selectedRepo, setSelectedRepo] = useState(null);
- const [selectedTemplate, setSelectedTemplate] = useState(null);
- const [branches, setBranches] = useState([]);
- const [branchesLoading, setBranchesLoading] = useState(false);
- const [repoManifest, setRepoManifest] = useState(null);
- const [repoManifestLoading, setRepoManifestLoading] = useState(false);
- const [manualRepoUrl, setManualRepoUrl] = useState('');
- const [name, setName] = useState('');
- const [nameTouched, setNameTouched] = useState(false);
- const [branch, setBranch] = useState('main');
- const [appType, setAppType] = useState('auto');
- const [buildMethod, setBuildMethod] = useState('auto');
- const [port, setPort] = useState('');
- // Ingress plane: 'nginx' (host Nginx, the default) or 'proxy_stack' (a
- // Dockerized Traefik/Caddy stack). Only honored by the backend for
- // container-eligible app types; everything else is forced to host Nginx.
- const [ingressPlane, setIngressPlane] = useState('nginx');
- const [autoDeploy, setAutoDeploy] = useState(true);
- const [advancedOpen, setAdvancedOpen] = useState(false);
- const [submitting, setSubmitting] = useState(false);
-
- // Build-pack detection (zero-Dockerfile). Runs when a repo is selected and
- // the build method routes through the build pack (auto / nixpacks).
- const [buildpack, setBuildpack] = useState(null);
- const [buildpackLoading, setBuildpackLoading] = useState(false);
- const [buildpackOverrides, setBuildpackOverrides] = useState({});
-
- // Manual / local service fields
- const [localPath, setLocalPath] = useState('');
- const [composeFile, setComposeFile] = useState('');
- const [systemdUnit, setSystemdUnit] = useState('');
- const [managedBy, setManagedBy] = useState('auto');
-
- // Upload fields
- const [uploadFile, setUploadFile] = useState(null);
- const [uploadDragOver, setUploadDragOver] = useState(false);
-
- // Optional Project / Environment assignment (opt-in hierarchy).
- const [projects, setProjects] = useState([]);
- const [selectedProjectId, setSelectedProjectId] = useState('');
- const [selectedEnvironmentId, setSelectedEnvironmentId] = useState('');
- const [projectEnvironments, setProjectEnvironments] = useState([]);
-
- const githubConnection = githubStatus?.connection;
- const githubConfigured = githubStatus?.configured;
- const normalizedManualRepo = useMemo(() => normalizeManualRepo(manualRepoUrl), [manualRepoUrl]);
- const activeManifest = sourceMode === 'template' ? selectedTemplate?.manifest : repoManifest;
- const recommended = activeManifest?.recommended || {};
- const detectedServiceName = useMemo(() => {
- if (sourceMode === 'template' && selectedTemplate) return slugify(selectedTemplate.serviceName || selectedTemplate.name || '');
- if (sourceMode === 'github' && selectedRepo) return slugify(selectedRepo.name || '');
- return repoNameFromUrl(normalizedManualRepo);
- }, [normalizedManualRepo, selectedRepo, selectedTemplate, sourceMode]);
- const serviceName = nameTouched ? name : detectedServiceName;
- const canSubmit = sourceMode === 'github'
- ? Boolean(githubConnection && selectedRepo && serviceName?.length >= 2)
- : sourceMode === 'template'
- ? Boolean(selectedTemplate && serviceName?.length >= 2)
- : sourceMode === 'local'
- ? Boolean(serviceName?.length >= 2 && localPath?.length >= 1)
- : sourceMode === 'upload'
- ? Boolean(serviceName?.length >= 2 && uploadFile)
- : Boolean(normalizedManualRepo && serviceName?.length >= 2);
- const buildSummary = buildMethod === 'auto' && recommended.build_method
- ? `Auto -> ${formatBuildMethod(recommended.build_method)}`
- : formatBuildMethod(buildMethod);
-
- // A managed proxy stack only routes container-based services. The "Proxy
- // stack" ingress option is offered when the selected type resolves to a
- // container: Docker explicitly, Auto-detect (which may resolve to a
- // container), or a Compose-managed local service. Every other type
- // (PHP/Python/static) is served by host Nginx and the backend forces it.
- const ingressProxyEligible = appType === 'docker'
- || appType === 'auto'
- || (sourceMode === 'local' && managedBy === 'docker_compose');
-
- const loadGithubStatus = useCallback(async () => {
- try {
- const data = await api.getGithubSourceStatus();
- setGithubStatus(data);
- } catch (err) {
- toast.error(err.message || 'Failed to load GitHub connection');
- }
- }, [toast]);
-
- const loadGithubRepos = useCallback(async (search = '') => {
- setReposLoading(true);
- try {
- const data = await api.listGithubRepositories({ search, perPage: 80 });
- setRepos(data.repos || []);
- } catch (err) {
- toast.error(err.message || 'Failed to load GitHub repositories');
- } finally {
- setReposLoading(false);
- }
- }, [toast]);
-
- const loadBranches = useCallback(async (fullName) => {
- setBranchesLoading(true);
- try {
- const data = await api.listGithubBranches(fullName);
- setBranches(data.branches || []);
- } catch (err) {
- setBranches([]);
- toast.error(err.message || 'Failed to load branches');
- } finally {
- setBranchesLoading(false);
- }
- }, [toast]);
-
- useEffect(() => {
- loadGithubStatus();
- }, [loadGithubStatus]);
-
- // Keep the ingress choice valid: if the selected type is no longer
- // proxy-eligible, snap back to host Nginx (the forced default).
- useEffect(() => {
- if (!ingressProxyEligible && ingressPlane !== 'nginx') {
- setIngressPlane('nginx');
- }
- }, [ingressProxyEligible, ingressPlane]);
-
- // Load projects for the optional Project / Environment selector. Best-effort:
- // if it fails the selector simply stays empty and creation is unaffected.
- useEffect(() => {
- let cancelled = false;
- api.getProjects()
- .then(data => {
- if (cancelled) return;
- setProjects(Array.isArray(data?.projects) ? data.projects : []);
- })
- .catch(() => { if (!cancelled) setProjects([]); });
- return () => { cancelled = true; };
- }, []);
-
- // When a project is picked, load its environments and default-select the
- // default one. Clearing the project clears the environment.
- useEffect(() => {
- if (!selectedProjectId) {
- setProjectEnvironments([]);
- setSelectedEnvironmentId('');
- return undefined;
- }
- let cancelled = false;
- api.getProject(selectedProjectId)
- .then(data => {
- if (cancelled) return;
- const envs = Array.isArray(data?.project?.environments) ? data.project.environments : [];
- setProjectEnvironments(envs);
- const def = envs.find(e => e.is_default) || envs[0];
- setSelectedEnvironmentId(def ? String(def.id) : '');
- })
- .catch(() => {
- if (!cancelled) {
- setProjectEnvironments([]);
- setSelectedEnvironmentId('');
- }
- });
- return () => { cancelled = true; };
- }, [selectedProjectId]);
-
- useEffect(() => {
- if (sourceMode === 'github' && githubConnection) {
- loadGithubRepos();
- }
- }, [sourceMode, githubConnection, loadGithubRepos]);
-
- useEffect(() => {
- if (selectedRepo) {
- setBranch(selectedRepo.default_branch || 'main');
- loadBranches(selectedRepo.full_name);
- }
- }, [selectedRepo, loadBranches]);
-
- useEffect(() => {
- if (sourceMode !== 'github' || !selectedRepo) {
- if (sourceMode !== 'template') setRepoManifest(null);
- setRepoManifestLoading(false);
- return undefined;
- }
-
- let cancelled = false;
- setRepoManifestLoading(true);
- api.inspectGithubRepositoryManifest(selectedRepo.full_name, branch || selectedRepo.default_branch || 'main')
- .then((data) => {
- if (cancelled) return;
- const manifest = data.manifest || null;
- setRepoManifest(manifest);
- const detectedPort = manifest?.recommended?.port;
- if (!port && detectedPort) {
- setPort(String(detectedPort));
- }
- })
- .catch((err) => {
- if (!cancelled) {
- setRepoManifest(null);
- toast.error(err.message || 'Failed to inspect repository manifests');
- }
- })
- .finally(() => {
- if (!cancelled) setRepoManifestLoading(false);
- });
-
- return () => {
- cancelled = true;
- };
- }, [branch, port, selectedRepo, sourceMode, toast]);
-
- useEffect(() => {
- if (selectedRepo) {
- if (!nameTouched) {
- setName(slugify(selectedRepo.name || ''));
- }
- }
- }, [selectedRepo, nameTouched]);
-
- // Build-pack detection. Only repo-based sources (github/manual/template) and
- // only when the build method routes through the build pack. Resets overrides
- // whenever the underlying repository changes.
- const buildpackEligible = (buildMethod === 'auto' || buildMethod === 'nixpacks')
- && (sourceMode === 'github' || sourceMode === 'manual' || sourceMode === 'template');
-
- useEffect(() => {
- if (!buildpackEligible) {
- setBuildpack(null);
- setBuildpackLoading(false);
- return undefined;
- }
-
- const body = { branch: branch || 'main', name: detectedServiceName || 'app' };
- if (sourceMode === 'github' && selectedRepo && githubConnection) {
- body.source_connection_id = githubConnection.id;
- body.repository_full_name = selectedRepo.full_name;
- body.repo_url = `https://github.com/${selectedRepo.full_name}.git`;
- } else if (sourceMode === 'template' && selectedTemplate) {
- body.repo_url = selectedTemplate.repoUrl;
- } else if (sourceMode === 'manual' && normalizedManualRepo) {
- body.repo_url = normalizedManualRepo;
- } else {
- setBuildpack(null);
- return undefined;
- }
-
- let cancelled = false;
- setBuildpackLoading(true);
- setBuildpackOverrides({});
- api.detectBuildpack(body)
- .then((data) => {
- if (!cancelled) setBuildpack(data);
- })
- .catch(() => {
- // Detection is best-effort; the user can still pick a method.
- if (!cancelled) setBuildpack(null);
- })
- .finally(() => {
- if (!cancelled) setBuildpackLoading(false);
- });
-
- return () => { cancelled = true; };
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [buildpackEligible, sourceMode, selectedRepo, selectedTemplate, normalizedManualRepo, branch, githubConnection]);
-
- async function handleConnectGithub() {
- try {
- const redirectUri = `${window.location.origin}/connections/callback/github`;
- sessionStorage.setItem('sourceConnectionReturnTo', '/services/new');
- const { auth_url } = await api.startSourceConnection('github', redirectUri);
- window.location.href = auth_url;
- } catch (err) {
- toast.error(err.message || 'Failed to start GitHub connection');
- }
- }
-
- function handleSourceModeChange(mode) {
- setSourceMode(mode);
- if (mode === 'template' && !selectedTemplate) {
- handleSelectTemplate(SERVICE_TEMPLATES[0]);
- }
- if (mode === 'local') {
- setAppType('docker');
- }
- if (mode === 'upload') {
- setAppType('auto');
- }
- }
-
- function handleSelectTemplate(template) {
- setSelectedTemplate(template);
- setSelectedRepo(null);
- setRepoManifest(template.manifest || null);
- setManualRepoUrl(template.repoUrl);
- setName(slugify(template.serviceName || template.name || ''));
- setNameTouched(false);
- setBranch(template.branch || 'main');
- setAppType(template.appType || 'auto');
- setBuildMethod(template.buildMethod || 'auto');
- setPort(template.port ? String(template.port) : '');
- setAutoDeploy(template.autoDeploy ?? true);
- }
-
- function handleManualRepoChange(value) {
- setManualRepoUrl(value);
- if (!nameTouched) {
- setName(repoNameFromUrl(normalizeManualRepo(value)));
- }
- }
-
- // Deep-link from the Templates tab: /services/new?template=<id> lands here
- // with the Deploy Template source preselected. Runs once on mount.
- useEffect(() => {
- const templateId = searchParams.get('template');
- if (!templateId) return;
- const template = getDeployTemplate(templateId);
- if (template) {
- setSourceMode('template');
- handleSelectTemplate(template);
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
-
- async function handleSubmit(e) {
- e.preventDefault();
- if (!canSubmit) {
- const msg = sourceMode === 'github'
- ? 'Select a GitHub repository'
- : sourceMode === 'template'
- ? 'Select a service template'
- : sourceMode === 'local'
- ? 'Service name and server path are required'
- : sourceMode === 'upload'
- ? 'Service name and a zip file are required'
- : 'Repository URL is required';
- toast.error(msg);
- return;
- }
-
- setSubmitting(true);
- // Optional Project / Environment assignment, included only when picked.
- const projectEnvPayload = {};
- if (selectedProjectId) {
- projectEnvPayload.project_id = Number(selectedProjectId);
- if (selectedEnvironmentId) projectEnvPayload.environment_id = Number(selectedEnvironmentId);
- }
- try {
- if (sourceMode === 'local') {
- const payload = {
- name: serviceName,
- app_type: appType,
- root_path: localPath.trim(),
- compose_file: composeFile.trim() || undefined,
- systemd_unit: systemdUnit.trim() || undefined,
- managed_by: managedBy === 'auto' ? undefined : managedBy,
- ingress_plane: ingressProxyEligible ? ingressPlane : 'nginx',
- ...projectEnvPayload,
- };
- const result = await api.createManualApp(payload);
- toast.success('Manual service registered');
- navigate(`/services/${result.app.id}`);
- } else if (sourceMode === 'upload') {
- const formData = new FormData();
- formData.append('file', uploadFile);
- formData.append('name', serviceName);
- formData.append('app_type', appType);
- formData.append('auto_deploy', autoDeploy ? 'true' : 'false');
- formData.append('ingress_plane', ingressProxyEligible ? ingressPlane : 'nginx');
- if (projectEnvPayload.project_id) formData.append('project_id', projectEnvPayload.project_id);
- if (projectEnvPayload.environment_id) formData.append('environment_id', projectEnvPayload.environment_id);
- const result = await api.uploadAppZip(formData);
- toast.success('Upload service created');
- navigate(`/services/${result.app.id}`);
- } else {
- const payload = {
- name: serviceName,
- branch: branch.trim() || null,
- app_type: appType,
- build_method: buildMethod,
- port: port ? Number(port) : null,
- auto_deploy: autoDeploy,
- ingress_plane: ingressProxyEligible ? ingressPlane : 'nginx',
- ...projectEnvPayload,
- };
- if (recommended.dockerfile_path) payload.dockerfile_path = recommended.dockerfile_path;
- if (recommended.custom_build_cmd) payload.custom_build_cmd = recommended.custom_build_cmd;
- if (recommended.custom_start_cmd) payload.custom_start_cmd = recommended.custom_start_cmd;
- if (buildpackEligible && buildpack?.plan) {
- payload.buildpack_plan = buildpack.plan;
- if (Object.keys(buildpackOverrides).length > 0) {
- payload.buildpack_overrides = buildpackOverrides;
- }
- }
-
- if (sourceMode === 'github') {
- payload.source_connection_id = githubConnection.id;
- payload.repository_full_name = selectedRepo.full_name;
- payload.repo_url = `https://github.com/${selectedRepo.full_name}.git`;
- } else if (sourceMode === 'template') {
- payload.template_id = selectedTemplate.id;
- payload.repo_url = selectedTemplate.repoUrl;
- } else {
- payload.repo_url = normalizedManualRepo;
- }
-
- const result = await api.createAppFromRepository(payload);
- toast.success('Repository service created');
- navigate(`/services/${result.app.id}`);
- }
- } catch (err) {
- toast.error(err.message || 'Failed to create service');
- } finally {
- setSubmitting(false);
- }
- }
-
- useTopbarActions(() =>
- <Button type="button" variant="outline" size="sm" asChild>
- <Link to="/settings/connections">
- <Link2 size={16} />
- Connections
- </Link>
- </Button>,
- []
- );
-
- return (
- <div className="sk-tabgroup__inner new-service-page">
- <div className="new-service-page__method-grid" aria-label="Service source options">
- <button
- className={`new-service-page__method-card ${sourceMode === 'github' ? 'new-service-page__method-card--on' : ''}`}
- type="button"
- onClick={() => handleSourceModeChange('github')}
- >
- <span className="new-service-page__method-icon">
- <SiGithub size={21} />
- </span>
- <span className="new-service-page__method-title">GitHub</span>
- <span className="new-service-page__method-sub">Connect with OAuth and choose a repository</span>
- </button>
- <button
- className={`new-service-page__method-card ${sourceMode === 'manual' ? 'new-service-page__method-card--on' : ''}`}
- type="button"
- onClick={() => handleSourceModeChange('manual')}
- >
- <span className="new-service-page__method-icon">
- <GitBranch size={21} />
- </span>
- <span className="new-service-page__method-title">Other Git Remote</span>
- <span className="new-service-page__method-sub">GitLab, Bitbucket, Gitea, or SSH</span>
- </button>
- <button
- className={`new-service-page__method-card ${sourceMode === 'local' ? 'new-service-page__method-card--on' : ''}`}
- type="button"
- onClick={() => handleSourceModeChange('local')}
- >
- <span className="new-service-page__method-icon">
- <FolderOpen size={21} />
- </span>
- <span className="new-service-page__method-title">Manual / Local</span>
- <span className="new-service-page__method-sub">Register an app that already exists on the server</span>
- </button>
- <button
- className={`new-service-page__method-card ${sourceMode === 'upload' ? 'new-service-page__method-card--on' : ''}`}
- type="button"
- onClick={() => handleSourceModeChange('upload')}
- >
- <span className="new-service-page__method-icon">
- <FileArchive size={21} />
- </span>
- <span className="new-service-page__method-title">Upload ZIP</span>
- <span className="new-service-page__method-sub">Deploy or update from a zip archive</span>
- </button>
- <button
- className={`new-service-page__method-card ${sourceMode === 'template' ? 'new-service-page__method-card--on' : ''}`}
- type="button"
- onClick={() => handleSourceModeChange('template')}
- >
- <span className="new-service-page__method-icon">
- <Package size={21} />
- </span>
- <span className="new-service-page__method-title">Deploy Template</span>
- <span className="new-service-page__method-sub">Fast import from manifest-ready repos</span>
- </button>
- </div>
-
- <form className="new-service-page__wizard" onSubmit={handleSubmit}>
- <section className="new-service-page__panel new-service-page__provider-panel">
- <div className="new-service-page__section-heading">
- <Link2 size={16} />
- <h2>
- {sourceMode === 'github'
- ? 'Pick Repository'
- : sourceMode === 'template'
- ? 'Choose Template'
- : sourceMode === 'local'
- ? 'Local Service'
- : sourceMode === 'upload'
- ? 'Upload Archive'
- : 'Connect Source'}
- </h2>
- <DocsLink
- to={sourceMode === 'template' ? 'manifest' : 'deploySources'}
- className="new-service-page__section-docs"
- />
- </div>
-
- {SOURCE_GUIDES[sourceMode] && (
- <div className="new-service-page__source-guide">
- <p className="new-service-page__source-guide-what">{SOURCE_GUIDES[sourceMode].what}</p>
- <p className="new-service-page__source-guide-need">
- <strong>Have ready:</strong> {SOURCE_GUIDES[sourceMode].need}
- </p>
- <ol className="new-service-page__source-guide-steps">
- {SOURCE_GUIDES[sourceMode].steps.map((step, i) => (
- <li key={i}>{step}</li>
- ))}
- </ol>
- </div>
- )}
-
- {sourceMode === 'github' ? (
- <div className="new-service-page__connect-box">
- {githubConnection ? (
- <>
- <div className="new-service-page__github-account">
- {githubConnection.avatar_url && <img src={githubConnection.avatar_url} alt="" />}
- <div>
- <strong>{githubConnection.display_name || githubConnection.provider_username}</strong>
- <span>@{githubConnection.provider_username}</span>
- </div>
- <Button type="button" variant="outline" onClick={() => loadGithubRepos()}>
- <RefreshCw size={16} className={reposLoading ? 'spinning' : ''} />
- Refresh
- </Button>
- </div>
-
- <div className="new-service-page__repo-search">
- <Search size={16} />
- <Input
- value={repoSearch}
- onChange={(e) => setRepoSearch(e.target.value)}
- placeholder="Search repositories"
- />
- <Button type="button" variant="outline" onClick={() => loadGithubRepos(repoSearch)}>
- Search
- </Button>
- </div>
-
- <div className="new-service-page__repo-list">
- {reposLoading && <div className="new-service-page__repo-state">Loading repositories...</div>}
- {!reposLoading && repos.length === 0 && (
- <div className="new-service-page__repo-state">No repositories found.</div>
- )}
- {!reposLoading && repos.map(repo => (
- <button
- key={repo.id}
- type="button"
- className={`new-service-page__repo-row ${selectedRepo?.id === repo.id ? 'new-service-page__repo-row--active' : ''}`}
- onClick={() => setSelectedRepo(repo)}
- >
- <span>
- <strong>{repo.full_name}</strong>
- <small>{repo.description || repo.language || 'No description'}</small>
- </span>
- <em>{repo.private ? 'Private' : 'Public'}</em>
- </button>
- ))}
- </div>
- </>
- ) : (
- <div className="new-service-page__connect-empty">
- <span className="new-service-page__connect-icon">
- <SiGithub size={20} />
- </span>
- <div>
- <h2>{githubConfigured ? 'Connect GitHub' : 'GitHub connection is not configured'}</h2>
- <p>
- {githubConfigured
- ? 'Authorize ServerKit once, then choose a repository from your GitHub account.'
- : 'Add the GitHub OAuth app credentials in Settings before connecting.'}
- </p>
- </div>
- <div className="new-service-page__connect-actions">
- <Button type="button" onClick={handleConnectGithub} disabled={!githubConfigured}>
- <SiGithub size={16} />
- Connect GitHub
- </Button>
- <Button type="button" variant="outline" asChild>
- <Link to="/settings/connections">
- <Settings2 size={16} />
- Settings
- </Link>
- </Button>
- </div>
- </div>
- )}
- </div>
- ) : sourceMode === 'template' ? (
- <div className="new-service-page__connect-box">
- <div className="new-service-page__connect-heading">
- <span className="new-service-page__connect-icon">
- <Package size={18} />
- </span>
- <div>
- <strong>Manifest-ready templates</strong>
- <span>Templates can ship Render, Railway, Docker Compose, app.json, or ServerKit manifest files.</span>
- </div>
- </div>
-
- <div className="new-service-page__template-list">
- {SERVICE_TEMPLATES.map(template => (
- <button
- key={template.id}
- type="button"
- className={`new-service-page__template-row ${selectedTemplate?.id === template.id ? 'new-service-page__template-row--active' : ''}`}
- onClick={() => handleSelectTemplate(template)}
- >
- <span className="new-service-page__template-main">
- <strong>
- {template.name}
- {template.example && (
- <span className="new-service-page__template-example">Example</span>
- )}
- </strong>
- <small>{template.description}</small>
- <em>{template.repoUrl}</em>
- </span>
- <span className="new-service-page__template-badges">
- {template.badges.map(badge => (
- <span key={badge}>{badge}</span>
- ))}
- </span>
- {selectedTemplate?.id === template.id ? <CheckCircle2 size={18} /> : <ArrowRight size={18} />}
- </button>
- ))}
- </div>
-
- <div className="new-service-page__connect-actions new-service-page__connect-actions--left">
- <Button type="button" variant="outline" asChild>
- <Link to="/templates#deploy-templates">
- <Package size={16} />
- Template Library
- </Link>
- </Button>
- </div>
- </div>
- ) : sourceMode === 'local' ? (
- <div className="new-service-page__connect-box">
- <div className="new-service-page__connect-heading">
- <span className="new-service-page__connect-icon">
- <FolderOpen size={18} />
- </span>
- <div>
- <strong>Register an existing service</strong>
- <span>Point ServerKit at a directory or systemd unit that is already on the server.</span>
- </div>
- </div>
- <div className="new-service-page__field">
- <Label htmlFor="local-path">Path on server</Label>
- <Input
- id="local-path"
- value={localPath}
- onChange={(e) => setLocalPath(e.target.value)}
- placeholder="/opt/my-service"
- autoComplete="off"
- required={sourceMode === 'local'}
- />
- </div>
- <div className="new-service-page__field">
- <Label htmlFor="compose-file">Compose file (optional)</Label>
- <Input
- id="compose-file"
- value={composeFile}
- onChange={(e) => setComposeFile(e.target.value)}
- placeholder="docker-compose.yml"
- autoComplete="off"
- />
- </div>
- <div className="new-service-page__field">
- <Label htmlFor="systemd-unit">systemd unit (optional)</Label>
- <Input
- id="systemd-unit"
- value={systemdUnit}
- onChange={(e) => setSystemdUnit(e.target.value)}
- placeholder="my-service"
- autoComplete="off"
- />
- </div>
- <div className="new-service-page__field">
- <Label htmlFor="managed-by">Managed by</Label>
- <select
- id="managed-by"
- value={managedBy}
- onChange={(e) => setManagedBy(e.target.value)}
- >
- <option value="auto">Auto-detect</option>
- <option value="docker_compose">Docker Compose</option>
- <option value="systemd">systemd</option>
- </select>
- </div>
- </div>
- ) : sourceMode === 'upload' ? (
- <div className="new-service-page__connect-box">
- <div className="new-service-page__connect-heading">
- <span className="new-service-page__connect-icon">
- <FileArchive size={18} />
- </span>
- <div>
- <strong>Upload a zip archive</strong>
- <span>ServerKit will extract the archive, detect the runtime, and deploy it for you.</span>
- </div>
- </div>
- <div
- className={`new-service-page__upload-drop ${uploadDragOver ? 'new-service-page__upload-drop--over' : ''}`}
- onDragOver={(e) => { e.preventDefault(); setUploadDragOver(true); }}
- onDragLeave={() => setUploadDragOver(false)}
- onDrop={(e) => {
- e.preventDefault();
- setUploadDragOver(false);
- const file = e.dataTransfer.files[0];
- if (file) {
- setUploadFile(file);
- if (!nameTouched) {
- setName(slugify(file.name.replace(/\.zip$/i, '')));
- }
- }
- }}
- onClick={() => document.getElementById('upload-zip')?.click()}
- >
- <FileArchive size={32} />
- <span>
- {uploadFile
- ? uploadFile.name
- : 'Drag a zip here or click to browse'}
- </span>
- <input
- id="upload-zip"
- type="file"
- accept=".zip,application/zip,application/x-zip-compressed"
- className="sr-only"
- onChange={(e) => {
- const file = e.target.files[0];
- if (file) {
- setUploadFile(file);
- if (!nameTouched) {
- setName(slugify(file.name.replace(/\.zip$/i, '')));
- }
- }
- }}
- />
- </div>
- </div>
- ) : (
- <div className="new-service-page__connect-box">
- <div className="new-service-page__connect-heading">
- <span className="new-service-page__connect-icon">
- <GitBranch size={18} />
- </span>
- <div>
- <strong>Git remote</strong>
- <span>Use this for providers that are not connected through the GitHub API.</span>
- </div>
- </div>
- <div className="new-service-page__field">
- <Label htmlFor="manual-repo-url">Repository URL</Label>
- <Input
- id="manual-repo-url"
- value={manualRepoUrl}
- onChange={(e) => handleManualRepoChange(e.target.value)}
- placeholder="[email protected]:owner/repo.git"
- autoComplete="off"
- required={sourceMode === 'manual'}
- />
- </div>
- </div>
- )}
-
- {(selectedRepo || sourceMode === 'manual' || sourceMode === 'local' || sourceMode === 'upload' || selectedTemplate) && (
- <div className="new-service-page__repo-preview">
- <div>
- <span>Service</span>
- <strong>{serviceName || 'Auto-named'}</strong>
- </div>
- {sourceMode !== 'local' && sourceMode !== 'upload' && (
- <div>
- <span>Branch</span>
- <strong>{branch || 'main'}</strong>
- </div>
- )}
- {sourceMode === 'local' && (
- <div>
- <span>Path</span>
- <strong>{localPath || '—'}</strong>
- </div>
- )}
- <div>
- <span>Type</span>
- <strong>{sourceMode === 'upload' && appType === 'auto' ? 'Auto-detect' : formatAppType(appType)}</strong>
- </div>
- </div>
- )}
- </section>
-
- <aside className="new-service-page__panel new-service-page__review-panel">
- <div className="new-service-page__deploy-card">
- <span className="new-service-page__deploy-icon">
- <Rocket size={18} />
- </span>
- <div>
- <h2>
- {sourceMode === 'local'
- ? 'Register Local Service'
- : sourceMode === 'upload'
- ? 'Deploy from Archive'
- : 'Ready to Import'}
- </h2>
- <p>
- {sourceMode === 'local'
- ? 'ServerKit will link to the existing path or systemd unit and poll its real status.'
- : sourceMode === 'upload'
- ? 'ServerKit will extract the archive, detect the runtime, and deploy the service.'
- : 'ServerKit clones the selected repository, detects the runtime, configures builds, and records deployment settings.'}
- </p>
- </div>
- </div>
-
- <div className="new-service-page__flow">
- <div>
- {sourceMode === 'local' ? <FolderOpen size={16} /> : sourceMode === 'upload' ? <FileArchive size={16} /> : <SiGithub size={16} />}
- <span>{sourceMode === 'local' ? 'Path' : sourceMode === 'upload' ? 'Upload' : 'Connect'}</span>
- </div>
- <ArrowRight size={14} />
- <div>
- <Zap size={16} />
- <span>Detect</span>
- </div>
- <ArrowRight size={14} />
- <div>
- <Server size={16} />
- <span>Deploy</span>
- </div>
- </div>
-
- {(repoManifestLoading || activeManifest) && (
- <div className="new-service-page__manifest-card">
- <div className="new-service-page__manifest-head">
- <span>
- <Zap size={16} />
- Manifest Detection
- </span>
- <strong>{repoManifestLoading ? 'Inspecting' : activeManifest?.strategy?.replace('_', ' ') || 'Detected'}</strong>
- </div>
- {!repoManifestLoading && activeManifest && (
- activeManifest.manifest_v1 ? (
- <div className="new-service-page__manifest-v1">
- <div className="new-service-page__manifest-services">
- {(activeManifest.manifest_v1.services || []).map(svc => (
- <div key={svc.name} className="new-service-page__manifest-service">
- <span className="new-service-page__manifest-service-name">{svc.name}</span>
- {(svc.type || svc.kind) && (
- <span className="new-service-page__manifest-badge">{svc.type || svc.kind}</span>
- )}
- {svc.port ? <span className="new-service-page__manifest-port">:{svc.port}</span> : null}
- {svc.auto_deploy && (
- <span className="new-service-page__manifest-chip">auto-deploy</span>
- )}
- </div>
- ))}
- </div>
- {(activeManifest.manifest_v1.databases || []).length > 0 && (
- <div className="new-service-page__manifest-row">
- <span className="new-service-page__manifest-row-label">
- <Database size={13} />
- Databases
- </span>
- <div className="new-service-page__manifest-tags">
- {activeManifest.manifest_v1.databases.map(db => (
- <span key={db}>{db}</span>
- ))}
- </div>
- </div>
- )}
- {(activeManifest.manifest_v1.domains || []).length > 0 && (
- <div className="new-service-page__manifest-row">
- <span className="new-service-page__manifest-row-label">
- <Globe size={13} />
- Domains
- </span>
- <div className="new-service-page__manifest-tags">
- {activeManifest.manifest_v1.domains.map(domain => (
- <span key={domain.host}>
- {domain.host}{domain.ssl ? ' · SSL' : ''}
- </span>
- ))}
- </div>
- </div>
- )}
- {(activeManifest.manifest_v1.env_required || []).length > 0 && (
- <div className="new-service-page__manifest-row">
- <span className="new-service-page__manifest-row-label">
- <Lock size={13} />
- Env requirements
- </span>
- <div className="new-service-page__env-preview">
- {activeManifest.manifest_v1.env_required.map(env => (
- <span
- key={`${env.service || ''}.${env.key}`}
- className={env.source === 'secret' ? 'new-service-page__env-preview-secret' : ''}
- >
- {env.service ? `${env.service}.` : ''}{env.key}
- </span>
- ))}
- </div>
- </div>
- )}
- </div>
- ) : (
- <>
- <div className="new-service-page__manifest-grid">
- <div>
- <span>Type</span>
- <strong>{formatAppType(recommended.app_type)}</strong>
- </div>
- <div>
- <span>Build</span>
- <strong>{formatBuildMethod(recommended.build_method)}</strong>
- </div>
- <div>
- <span>Port</span>
- <strong>{recommended.port || 'Auto'}</strong>
- </div>
- </div>
- <div className="new-service-page__manifest-files">
- {(activeManifest.manifests || []).slice(0, 5).map(manifest => (
- <span key={manifest.file}>
- <CheckCircle2 size={13} />
- {manifest.file}
- </span>
- ))}
- </div>
- {(activeManifest.env || []).length > 0 && (
- <div className="new-service-page__env-preview">
- {(activeManifest.env || []).slice(0, 6).map(env => (
- <span key={env.key} className={env.secret ? 'new-service-page__env-preview-secret' : ''}>
- {env.key}
- </span>
- ))}
- </div>
- )}
- </>
- )
- )}
- </div>
- )}
-
- {buildpackEligible && (buildpackLoading || buildpack?.plan) && (
- <BuildpackPreview
- plan={buildpack?.plan}
- dockerfile={buildpack?.dockerfile}
- overrides={buildpackOverrides}
- onChange={setBuildpackOverrides}
- loading={buildpackLoading}
- />
- )}
-
- <div className="new-service-page__summary">
- <div>
- <span>Source</span>
- <strong>
- {sourceMode === 'github'
- ? 'GitHub API'
- : sourceMode === 'template'
- ? 'Template'
- : sourceMode === 'local'
- ? 'Manual / Local'
- : sourceMode === 'upload'
- ? 'Upload'
- : 'Git remote'}
- </strong>
- </div>
- <div>
- <span>{sourceMode === 'local' ? 'Path' : sourceMode === 'upload' ? 'Archive' : 'Repository'}</span>
- <strong>
- {sourceMode === 'local'
- ? localPath || 'Not set'
- : sourceMode === 'upload'
- ? uploadFile?.name || 'Not selected'
- : selectedRepo?.full_name || selectedTemplate?.repoUrl || normalizedManualRepo || 'Not selected'}
- </strong>
- </div>
- <div>
- <span>{sourceMode === 'upload' ? 'Detection' : 'Build'}</span>
- <strong>{sourceMode === 'upload' ? (appType === 'auto' ? 'Auto-detect' : formatAppType(appType)) : buildSummary}</strong>
- </div>
- {sourceMode !== 'local' && (
- <div>
- <span>Auto-deploy</span>
- <strong>{autoDeploy ? 'On' : 'Off'}</strong>
- </div>
- )}
- <div>
- <span>Ingress</span>
- <strong>
- {ingressProxyEligible && ingressPlane === 'proxy_stack'
- ? 'Proxy stack'
- : 'Host Nginx'}
- </strong>
- </div>
- </div>
-
- <button
- className="new-service-page__advanced-toggle"
- type="button"
- onClick={() => setAdvancedOpen(open => !open)}
- aria-expanded={advancedOpen}
- >
- <span>
- <Settings2 size={16} />
- Advanced settings
- </span>
- <ChevronDown size={16} />
- </button>
-
- {advancedOpen && (
- <div className="new-service-page__advanced">
- <div className="new-service-page__two-col">
- {sourceMode !== 'local' && sourceMode !== 'upload' && (
- <div className="new-service-page__field">
- <Label htmlFor="branch">Branch</Label>
- {sourceMode === 'github' && branches.length > 0 ? (
- <select
- id="branch"
- value={branch}
- onChange={(e) => setBranch(e.target.value)}
- disabled={branchesLoading}
- >
- {branches.map(option => (
- <option key={option.name} value={option.name}>{option.name}</option>
- ))}
- </select>
- ) : (
- <Input
- id="branch"
- value={branch}
- onChange={(e) => setBranch(e.target.value)}
- placeholder="main"
- />
- )}
- </div>
- )}
- <div className="new-service-page__field">
- <Label htmlFor="service-name">Service name</Label>
- <Input
- id="service-name"
- value={serviceName}
- onChange={(e) => {
- setNameTouched(true);
- setName(slugify(e.target.value));
- }}
- placeholder="my-service"
- minLength={2}
- required
- />
- </div>
- </div>
-
- <div className="new-service-page__two-col">
- <div className="new-service-page__field">
- <Label htmlFor="app-type">Service type</Label>
- <select
- id="app-type"
- value={appType}
- onChange={(e) => setAppType(e.target.value)}
- >
- {sourceMode === 'upload' && <option value="auto">Auto-detect</option>}
- {APP_TYPE_OPTIONS.filter(o => o.value !== 'auto').map(option => (
- <option key={option.value} value={option.value}>{option.label}</option>
- ))}
- </select>
- </div>
- {sourceMode !== 'local' && sourceMode !== 'upload' && (
- <div className="new-service-page__field">
- <Label htmlFor="build-method">Build method</Label>
- <select
- id="build-method"
- value={buildMethod}
- onChange={(e) => setBuildMethod(e.target.value)}
- >
- {BUILD_METHOD_OPTIONS.map(option => (
- <option key={option.value} value={option.value}>{option.label}</option>
- ))}
- </select>
- </div>
- )}
- </div>
-
- <div className="new-service-page__two-col">
- <div className="new-service-page__field">
- <Label htmlFor="port">Runtime port</Label>
- <Input
- id="port"
- type="number"
- value={port}
- onChange={(e) => setPort(e.target.value)}
- placeholder="3000"
- min="1"
- max="65535"
- />
- </div>
- {sourceMode !== 'local' && (
- <div className="new-service-page__toggle">
- <div>
- <Label>Auto-deploy</Label>
- <span>{sourceMode === 'upload' ? 'Deploy immediately after upload.' : 'Webhook deployment for this branch.'}</span>
- </div>
- <Switch checked={autoDeploy} onCheckedChange={setAutoDeploy} />
- </div>
- )}
- </div>
-
- <div className="new-service-page__field">
- <Label htmlFor="ingress-plane">Ingress</Label>
- {ingressProxyEligible ? (
- <select
- id="ingress-plane"
- value={ingressPlane}
- onChange={(e) => setIngressPlane(e.target.value)}
- >
- <option value="nginx">Host Nginx (default)</option>
- <option value="proxy_stack">Proxy stack (Traefik / Caddy)</option>
- </select>
- ) : (
- <div className="new-service-page__note">
- <Network size={16} />
- <span>Served by host Nginx</span>
- </div>
- )}
- </div>
-
- {projects.length > 0 && (
- <div className="new-service-page__two-col">
- <div className="new-service-page__field">
- <Label htmlFor="project">Project <span className="new-service-page__optional">(optional)</span></Label>
- <select
- id="project"
- value={selectedProjectId}
- onChange={(e) => setSelectedProjectId(e.target.value)}
- >
- <option value="">No project</option>
- {projects.map(p => (
- <option key={p.id} value={p.id}>{p.name}</option>
- ))}
- </select>
- </div>
- {selectedProjectId && (
- <div className="new-service-page__field">
- <Label htmlFor="environment">Environment</Label>
- <select
- id="environment"
- value={selectedEnvironmentId}
- onChange={(e) => setSelectedEnvironmentId(e.target.value)}
- >
- {projectEnvironments.map(env => (
- <option key={env.id} value={env.id}>{env.name}</option>
- ))}
- </select>
- </div>
- )}
- </div>
- )}
- </div>
- )}
-
- <div className="new-service-page__notes">
- <div className="new-service-page__note">
- <ShieldCheck size={16} />
- <span>
- {sourceMode === 'local'
- ? 'ServerKit will read status from Docker Compose or systemd without modifying the original path.'
- : sourceMode === 'upload'
- ? 'Uploaded archives are versioned, so you can roll back to a previous release.'
- : 'ServerKit checks serverkit.json, Docker Compose, Render, Railway, app.json, Dockerfile, and Nixpacks signals.'}
- </span>
- </div>
- <div className="new-service-page__note">
- <Lock size={16} />
- <span>{sourceMode === 'upload' ? 'Existing .env files are preserved when uploading a new version.' : 'Secret values from manifests stay empty until you add them to the service environment.'}</span>
- </div>
- </div>
-
- <div className="new-service-page__actions">
- <Button type="button" variant="outline" asChild>
- <Link to="/services">Cancel</Link>
- </Button>
- <Button type="submit" disabled={!canSubmit || submitting}>
- <Rocket size={16} />
- {submitting
- ? (sourceMode === 'local' ? 'Registering...' : sourceMode === 'upload' ? 'Uploading...' : 'Importing...')
- : (sourceMode === 'local' ? 'Register Service' : sourceMode === 'upload' ? 'Upload & Deploy' : 'Import Repository')}
- </Button>
- </div>
- </aside>
- </form>
- </div>
- );
-};
-
-export default NewService;
diff --git a/frontend/src/pages/new-service/ConnectStep.jsx b/frontend/src/pages/new-service/ConnectStep.jsx
new file mode 100644
index 00000000..5a7bf7a3
--- /dev/null
+++ b/frontend/src/pages/new-service/ConnectStep.jsx
@@ -0,0 +1,281 @@
+import { Link } from 'react-router-dom';
+import {
+ ArrowRight, CheckCircle2, FileArchive, FolderOpen, GitBranch, Info,
+ Package, RefreshCw, Search, Settings2,
+} from 'lucide-react';
+import { SiGithub } from 'react-icons/si';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { SOURCE_NEEDS } from './useNewServiceForm';
+
+// Step 2 — Connect. Only the source-specific input, plus the editable detected
+// service name + branch shown inline (not buried in Advanced).
+const ConnectStep = ({ form }) => {
+ const {
+ sourceMode, githubConnection, githubConfigured, reposLoading, repos, repoSearch,
+ setRepoSearch, selectedRepo, setSelectedRepo, loadGithubRepos, handleConnectGithub,
+ templates, templatesLoading, selectedTemplate, selectTemplateById,
+ manualRepoUrl, handleManualRepoChange, localPath, setLocalPath, composeFile,
+ setComposeFile, systemdUnit, setSystemdUnit, managedBy, setManagedBy,
+ uploadFile, onUploadFile, uploadDragOver, setUploadDragOver,
+ serviceName, onNameChange, branch, setBranch, branches, branchesLoading,
+ } = form;
+
+ const showBranch = sourceMode !== 'local' && sourceMode !== 'upload';
+
+ return (
+ <div className="new-service-page__step">
+ <div className="new-service-page__step-head">
+ <h2>
+ {sourceMode === 'github' ? 'Pick a repository'
+ : sourceMode === 'template' ? 'Choose a template'
+ : sourceMode === 'local' ? 'Point at the service'
+ : sourceMode === 'upload' ? 'Upload the archive'
+ : 'Connect the remote'}
+ </h2>
+ {SOURCE_NEEDS[sourceMode] && (
+ <p className="new-service-page__need">
+ <Info size={14} />
+ {SOURCE_NEEDS[sourceMode]}
+ </p>
+ )}
+ </div>
+
+ {sourceMode === 'github' && (
+ <div className="new-service-page__pane">
+ {githubConnection ? (
+ <>
+ <div className="new-service-page__github-account">
+ {githubConnection.avatar_url && <img src={githubConnection.avatar_url} alt="" />}
+ <div>
+ <strong>{githubConnection.display_name || githubConnection.provider_username}</strong>
+ <span>@{githubConnection.provider_username}</span>
+ </div>
+ <Button type="button" variant="outline" onClick={() => loadGithubRepos()}>
+ <RefreshCw size={16} className={reposLoading ? 'spinning' : ''} />
+ Refresh
+ </Button>
+ </div>
+ <div className="new-service-page__repo-search">
+ <Search size={16} />
+ <Input
+ value={repoSearch}
+ onChange={(e) => setRepoSearch(e.target.value)}
+ placeholder="Search repositories"
+ />
+ <Button type="button" variant="outline" onClick={() => loadGithubRepos(repoSearch)}>
+ Search
+ </Button>
+ </div>
+ <div className="new-service-page__repo-list">
+ {reposLoading && <div className="new-service-page__repo-state">Loading repositories…</div>}
+ {!reposLoading && repos.length === 0 && (
+ <div className="new-service-page__repo-state">No repositories found.</div>
+ )}
+ {!reposLoading && repos.map(repo => (
+ <button
+ key={repo.id}
+ type="button"
+ className={`new-service-page__repo-row ${selectedRepo?.id === repo.id ? 'new-service-page__repo-row--active' : ''}`}
+ onClick={() => setSelectedRepo(repo)}
+ >
+ <span>
+ <strong>{repo.full_name}</strong>
+ <small>{repo.description || repo.language || 'No description'}</small>
+ </span>
+ <em>{repo.private ? 'Private' : 'Public'}</em>
+ </button>
+ ))}
+ </div>
+ </>
+ ) : (
+ <div className="new-service-page__connect-empty">
+ <span className="new-service-page__connect-icon">
+ <SiGithub size={20} />
+ </span>
+ <div>
+ <h3>{githubConfigured ? 'Connect GitHub' : 'GitHub connection is not configured'}</h3>
+ <p>
+ {githubConfigured
+ ? 'Authorize ServerKit once, then choose a repository from your GitHub account.'
+ : 'Add the GitHub OAuth app credentials in Settings before connecting.'}
+ </p>
+ </div>
+ <div className="new-service-page__connect-actions">
+ <Button type="button" onClick={handleConnectGithub} disabled={!githubConfigured}>
+ <SiGithub size={16} />
+ Connect GitHub
+ </Button>
+ <Button type="button" variant="outline" asChild>
+ <Link to="/settings/connections">
+ <Settings2 size={16} />
+ Settings
+ </Link>
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+
+ {sourceMode === 'template' && (
+ <div className="new-service-page__pane">
+ <div className="new-service-page__template-list">
+ {templatesLoading && <div className="new-service-page__repo-state">Loading templates…</div>}
+ {!templatesLoading && templates.length === 0 && (
+ <div className="new-service-page__repo-state">No deploy templates available yet.</div>
+ )}
+ {!templatesLoading && templates.map(template => (
+ <button
+ key={template.id}
+ type="button"
+ className={`new-service-page__template-row ${selectedTemplate?.id === template.id ? 'new-service-page__template-row--active' : ''}`}
+ onClick={() => selectTemplateById(template.id)}
+ >
+ <span className="new-service-page__template-main">
+ <strong>{template.name}</strong>
+ <small>{template.description}</small>
+ {template.repo?.url && <em>{template.repo.url}</em>}
+ </span>
+ {selectedTemplate?.id === template.id ? <CheckCircle2 size={18} /> : <ArrowRight size={18} />}
+ </button>
+ ))}
+ </div>
+ <div className="new-service-page__pane-actions">
+ <Button type="button" variant="outline" asChild>
+ <Link to="/templates?kind=repo">
+ <Package size={16} />
+ Browse all templates
+ </Link>
+ </Button>
+ </div>
+ </div>
+ )}
+
+ {sourceMode === 'local' && (
+ <div className="new-service-page__pane">
+ <div className="new-service-page__field">
+ <Label htmlFor="local-path">Path on server</Label>
+ <Input
+ id="local-path"
+ value={localPath}
+ onChange={(e) => setLocalPath(e.target.value)}
+ placeholder="/opt/my-service"
+ autoComplete="off"
+ />
+ </div>
+ <div className="new-service-page__field">
+ <Label htmlFor="compose-file">Compose file (optional)</Label>
+ <Input
+ id="compose-file"
+ value={composeFile}
+ onChange={(e) => setComposeFile(e.target.value)}
+ placeholder="docker-compose.yml"
+ autoComplete="off"
+ />
+ </div>
+ <div className="new-service-page__field">
+ <Label htmlFor="systemd-unit">systemd unit (optional)</Label>
+ <Input
+ id="systemd-unit"
+ value={systemdUnit}
+ onChange={(e) => setSystemdUnit(e.target.value)}
+ placeholder="my-service"
+ autoComplete="off"
+ />
+ </div>
+ <div className="new-service-page__field">
+ <Label htmlFor="managed-by">Managed by</Label>
+ <select id="managed-by" value={managedBy} onChange={(e) => setManagedBy(e.target.value)}>
+ <option value="auto">Auto-detect</option>
+ <option value="docker_compose">Docker Compose</option>
+ <option value="systemd">systemd</option>
+ </select>
+ </div>
+ </div>
+ )}
+
+ {sourceMode === 'upload' && (
+ <div className="new-service-page__pane">
+ <div
+ className={`new-service-page__upload-drop ${uploadDragOver ? 'new-service-page__upload-drop--over' : ''}`}
+ onDragOver={(e) => { e.preventDefault(); setUploadDragOver(true); }}
+ onDragLeave={() => setUploadDragOver(false)}
+ onDrop={(e) => {
+ e.preventDefault();
+ setUploadDragOver(false);
+ onUploadFile(e.dataTransfer.files[0]);
+ }}
+ onClick={() => document.getElementById('upload-zip')?.click()}
+ >
+ <FileArchive size={32} />
+ <span>{uploadFile ? uploadFile.name : 'Drag a zip here or click to browse'}</span>
+ <input
+ id="upload-zip"
+ type="file"
+ accept=".zip,application/zip,application/x-zip-compressed"
+ className="sr-only"
+ onChange={(e) => onUploadFile(e.target.files[0])}
+ />
+ </div>
+ </div>
+ )}
+
+ {sourceMode === 'manual' && (
+ <div className="new-service-page__pane">
+ <div className="new-service-page__field">
+ <Label htmlFor="manual-repo-url">Repository URL</Label>
+ <Input
+ id="manual-repo-url"
+ value={manualRepoUrl}
+ onChange={(e) => handleManualRepoChange(e.target.value)}
+ placeholder="[email protected]:owner/repo.git"
+ autoComplete="off"
+ />
+ </div>
+ </div>
+ )}
+
+ {/* Detected service name + branch, editable inline. */}
+ <div className="new-service-page__inline-fields">
+ <div className="new-service-page__field">
+ <Label htmlFor="service-name-inline">Service name</Label>
+ <Input
+ id="service-name-inline"
+ value={serviceName}
+ onChange={(e) => onNameChange(e.target.value)}
+ placeholder="my-service"
+ minLength={2}
+ />
+ </div>
+ {showBranch && (
+ <div className="new-service-page__field">
+ <Label htmlFor="branch-inline">Branch</Label>
+ {sourceMode === 'github' && branches.length > 0 ? (
+ <select
+ id="branch-inline"
+ value={branch}
+ onChange={(e) => setBranch(e.target.value)}
+ disabled={branchesLoading}
+ >
+ {branches.map(option => (
+ <option key={option.name} value={option.name}>{option.name}</option>
+ ))}
+ </select>
+ ) : (
+ <Input
+ id="branch-inline"
+ value={branch}
+ onChange={(e) => setBranch(e.target.value)}
+ placeholder="main"
+ />
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+ );
+};
+
+export default ConnectStep;
diff --git a/frontend/src/pages/new-service/NewService.jsx b/frontend/src/pages/new-service/NewService.jsx
new file mode 100644
index 00000000..5629ba1c
--- /dev/null
+++ b/frontend/src/pages/new-service/NewService.jsx
@@ -0,0 +1,100 @@
+import { Link } from 'react-router-dom';
+import { Check, Link2, Rocket } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { useTopbarActions } from '@/hooks/useTopbarActions';
+import DocsLink from '@/components/DocsLink';
+import { useNewServiceForm } from './useNewServiceForm';
+import SourceStep from './SourceStep';
+import ConnectStep from './ConnectStep';
+import ReviewStep from './ReviewStep';
+
+const STEPS = [
+ { n: 1, label: 'Source' },
+ { n: 2, label: 'Connect' },
+ { n: 3, label: 'Review' },
+];
+
+// New Service — a real three-step wizard (plan 43 Phase 3). Step state and
+// submit live in the form hook; each step is a presentational component.
+const NewService = () => {
+ const form = useNewServiceForm();
+ const { step, setStep, submitting, canSubmit, canProceedFromConnect, handleSubmit } = form;
+
+ useTopbarActions(() =>
+ <>
+ <DocsLink to="deploySources" />
+ <Button type="button" variant="outline" size="sm" asChild>
+ <Link to="/settings/connections">
+ <Link2 size={16} />
+ Connections
+ </Link>
+ </Button>
+ </>,
+ []
+ );
+
+ return (
+ <div className="sk-tabgroup__inner new-service-page">
+ {/* Slim stepper header */}
+ <nav className="new-service-page__stepper" aria-label="Progress">
+ {STEPS.map(({ n, label }) => {
+ const state = step === n ? 'current' : step > n ? 'done' : 'todo';
+ return (
+ <button
+ key={n}
+ type="button"
+ className={`new-service-page__stepper-item new-service-page__stepper-item--${state}`}
+ onClick={() => { if (step > n) setStep(n); }}
+ disabled={step < n}
+ aria-current={step === n ? 'step' : undefined}
+ >
+ <span className="new-service-page__stepper-dot">
+ {step > n ? <Check size={14} /> : n}
+ </span>
+ <span className="new-service-page__stepper-label">{label}</span>
+ </button>
+ );
+ })}
+ </nav>
+
+ <form className="new-service-page__wizard-col" onSubmit={handleSubmit}>
+ {step === 1 && <SourceStep form={form} />}
+ {step === 2 && <ConnectStep form={form} />}
+ {step === 3 && <ReviewStep form={form} />}
+
+ {/* Footer nav — Source advances on card click, so it shows only Cancel. */}
+ <div className="new-service-page__footer">
+ {step === 1 ? (
+ <Button type="button" variant="outline" asChild>
+ <Link to="/services">Cancel</Link>
+ </Button>
+ ) : (
+ <Button type="button" variant="outline" onClick={() => setStep(step - 1)}>
+ Back
+ </Button>
+ )}
+
+ {step === 2 && (
+ <Button
+ type="button"
+ onClick={() => setStep(3)}
+ disabled={!canProceedFromConnect}
+ >
+ Continue
+ </Button>
+ )}
+ {step === 3 && (
+ <Button type="submit" disabled={!canSubmit || submitting}>
+ <Rocket size={16} />
+ {submitting
+ ? (form.sourceMode === 'local' ? 'Registering…' : form.sourceMode === 'upload' ? 'Uploading…' : 'Deploying…')
+ : (form.sourceMode === 'local' ? 'Register service' : form.sourceMode === 'upload' ? 'Upload & deploy' : 'Deploy service')}
+ </Button>
+ )}
+ </div>
+ </form>
+ </div>
+ );
+};
+
+export default NewService;
diff --git a/frontend/src/pages/new-service/ReviewStep.jsx b/frontend/src/pages/new-service/ReviewStep.jsx
new file mode 100644
index 00000000..51b6b330
--- /dev/null
+++ b/frontend/src/pages/new-service/ReviewStep.jsx
@@ -0,0 +1,274 @@
+import {
+ ChevronDown, Database, Globe, Lock, Network, Settings2, Zap, CheckCircle2,
+} from 'lucide-react';
+import { Label } from '@/components/ui/label';
+import { Input } from '@/components/ui/input';
+import { Switch } from '@/components/ui/switch';
+import BuildpackPreview from '@/components/buildpack/BuildpackPreview';
+import {
+ APP_TYPE_OPTIONS, BUILD_METHOD_OPTIONS, formatAppType, formatBuildMethod,
+} from './useNewServiceForm';
+
+// Step 3 — Review & deploy. Only renders cards that have real data; the core
+// fields live in one grid, Advanced keeps the genuinely rare bits.
+const ReviewStep = ({ form }) => {
+ const {
+ sourceMode, activeManifest, activeManifestLoading, recommended,
+ buildpackEligible, buildpack, buildpackLoading, buildpackOverrides, setBuildpackOverrides,
+ serviceName, onNameChange, branch, setBranch, appType, setAppType,
+ buildMethod, setBuildMethod, port, setPort, autoDeploy, setAutoDeploy,
+ ingressPlane, setIngressPlane, ingressProxyEligible, advancedOpen, setAdvancedOpen,
+ projects, selectedProjectId, setSelectedProjectId,
+ selectedEnvironmentId, setSelectedEnvironmentId, projectEnvironments,
+ } = form;
+
+ const showBuild = sourceMode !== 'local' && sourceMode !== 'upload';
+ const envList = activeManifest?.manifest_v1
+ ? (activeManifest.manifest_v1.env_required || [])
+ : (activeManifest?.env || []);
+
+ return (
+ <div className="new-service-page__step new-service-page__review">
+ <div className="new-service-page__step-head">
+ <h2>Review &amp; deploy</h2>
+ <p>Confirm the detected settings, then create the service.</p>
+ </div>
+
+ {/* Manifest detection — only when there's something to show. */}
+ {(activeManifestLoading || activeManifest) && (
+ <div className="new-service-page__manifest-card">
+ <div className="new-service-page__manifest-head">
+ <span><Zap size={16} /> Manifest detection</span>
+ <strong>
+ {activeManifestLoading
+ ? 'Inspecting'
+ : activeManifest?.strategy?.replace('_', ' ') || 'Detected'}
+ </strong>
+ </div>
+ {!activeManifestLoading && activeManifest && (
+ activeManifest.manifest_v1 ? (
+ <div className="new-service-page__manifest-v1">
+ <div className="new-service-page__manifest-services">
+ {(activeManifest.manifest_v1.services || []).map(svc => (
+ <div key={svc.name} className="new-service-page__manifest-service">
+ <span className="new-service-page__manifest-service-name">{svc.name}</span>
+ {(svc.type || svc.kind) && (
+ <span className="new-service-page__manifest-badge">{svc.type || svc.kind}</span>
+ )}
+ {svc.port ? <span className="new-service-page__manifest-port">:{svc.port}</span> : null}
+ {svc.auto_deploy && (
+ <span className="new-service-page__manifest-chip">auto-deploy</span>
+ )}
+ </div>
+ ))}
+ </div>
+ {(activeManifest.manifest_v1.databases || []).length > 0 && (
+ <div className="new-service-page__manifest-row">
+ <span className="new-service-page__manifest-row-label">
+ <Database size={13} /> Databases
+ </span>
+ <div className="new-service-page__manifest-tags">
+ {activeManifest.manifest_v1.databases.map(db => <span key={db}>{db}</span>)}
+ </div>
+ </div>
+ )}
+ {(activeManifest.manifest_v1.domains || []).length > 0 && (
+ <div className="new-service-page__manifest-row">
+ <span className="new-service-page__manifest-row-label">
+ <Globe size={13} /> Domains
+ </span>
+ <div className="new-service-page__manifest-tags">
+ {activeManifest.manifest_v1.domains.map(domain => (
+ <span key={domain.host}>{domain.host}{domain.ssl ? ' · SSL' : ''}</span>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ ) : (
+ <>
+ <div className="new-service-page__manifest-grid">
+ <div><span>Type</span><strong>{formatAppType(recommended.app_type)}</strong></div>
+ <div><span>Build</span><strong>{formatBuildMethod(recommended.build_method)}</strong></div>
+ <div><span>Port</span><strong>{recommended.port || 'Auto'}</strong></div>
+ </div>
+ {(activeManifest.manifests || []).length > 0 && (
+ <div className="new-service-page__manifest-files">
+ {activeManifest.manifests.slice(0, 5).map(manifest => (
+ <span key={manifest.file}>
+ <CheckCircle2 size={13} /> {manifest.file}
+ </span>
+ ))}
+ </div>
+ )}
+ </>
+ )
+ )}
+ </div>
+ )}
+
+ {/* Env requirements list — the one load-bearing note is folded in here. */}
+ {envList.length > 0 && (
+ <div className="new-service-page__env-card">
+ <div className="new-service-page__env-head">
+ <Lock size={15} /> Environment
+ </div>
+ <div className="new-service-page__env-preview">
+ {envList.map(env => (
+ <span
+ key={`${env.service || ''}.${env.key}`}
+ className={(env.secret || env.source === 'secret')
+ ? 'new-service-page__env-preview-secret' : ''}
+ >
+ {env.service ? `${env.service}.` : ''}{env.key}{env.required ? ' *' : ''}
+ </span>
+ ))}
+ </div>
+ <p className="new-service-page__env-note">
+ Secret values stay empty until you add them to the service environment.
+ </p>
+ </div>
+ )}
+
+ {buildpackEligible && (buildpackLoading || buildpack?.plan) && (
+ <BuildpackPreview
+ plan={buildpack?.plan}
+ dockerfile={buildpack?.dockerfile}
+ overrides={buildpackOverrides}
+ onChange={setBuildpackOverrides}
+ loading={buildpackLoading}
+ />
+ )}
+
+ {/* Core fields in one tidy grid. */}
+ <div className="new-service-page__fields-grid">
+ <div className="new-service-page__field">
+ <Label htmlFor="review-name">Service name</Label>
+ <Input
+ id="review-name"
+ value={serviceName}
+ onChange={(e) => onNameChange(e.target.value)}
+ placeholder="my-service"
+ minLength={2}
+ required
+ />
+ </div>
+ {showBuild && (
+ <div className="new-service-page__field">
+ <Label htmlFor="review-branch">Branch</Label>
+ <Input
+ id="review-branch"
+ value={branch}
+ onChange={(e) => setBranch(e.target.value)}
+ placeholder="main"
+ />
+ </div>
+ )}
+ <div className="new-service-page__field">
+ <Label htmlFor="review-type">Service type</Label>
+ <select id="review-type" value={appType} onChange={(e) => setAppType(e.target.value)}>
+ {sourceMode === 'upload' && <option value="auto">Auto-detect</option>}
+ {APP_TYPE_OPTIONS.filter(o => o.value !== 'auto').map(option => (
+ <option key={option.value} value={option.value}>{option.label}</option>
+ ))}
+ </select>
+ </div>
+ {showBuild && (
+ <div className="new-service-page__field">
+ <Label htmlFor="review-build">Build method</Label>
+ <select id="review-build" value={buildMethod} onChange={(e) => setBuildMethod(e.target.value)}>
+ {BUILD_METHOD_OPTIONS.map(option => (
+ <option key={option.value} value={option.value}>{option.label}</option>
+ ))}
+ </select>
+ </div>
+ )}
+ <div className="new-service-page__field">
+ <Label htmlFor="review-port">Runtime port</Label>
+ <Input
+ id="review-port"
+ type="number"
+ value={port}
+ onChange={(e) => setPort(e.target.value)}
+ placeholder="3000"
+ min="1"
+ max="65535"
+ />
+ </div>
+ <div className="new-service-page__field">
+ <Label htmlFor="review-ingress">Ingress</Label>
+ {ingressProxyEligible ? (
+ <select id="review-ingress" value={ingressPlane} onChange={(e) => setIngressPlane(e.target.value)}>
+ <option value="nginx">Host Nginx (default)</option>
+ <option value="proxy_stack">Proxy stack (Traefik / Caddy)</option>
+ </select>
+ ) : (
+ <div className="new-service-page__note">
+ <Network size={16} />
+ <span>Served by host Nginx</span>
+ </div>
+ )}
+ </div>
+ {sourceMode !== 'local' && (
+ <div className="new-service-page__toggle">
+ <div>
+ <Label>Auto-deploy</Label>
+ <span>{sourceMode === 'upload' ? 'Deploy immediately after upload.' : 'Webhook deployment for this branch.'}</span>
+ </div>
+ <Switch checked={autoDeploy} onCheckedChange={setAutoDeploy} />
+ </div>
+ )}
+ </div>
+
+ {projects.length > 0 && (
+ <div className="new-service-page__fields-grid">
+ <div className="new-service-page__field">
+ <Label htmlFor="review-project">
+ Project <span className="new-service-page__optional">(optional)</span>
+ </Label>
+ <select id="review-project" value={selectedProjectId} onChange={(e) => setSelectedProjectId(e.target.value)}>
+ <option value="">No project</option>
+ {projects.map(p => <option key={p.id} value={p.id}>{p.name}</option>)}
+ </select>
+ </div>
+ {selectedProjectId && (
+ <div className="new-service-page__field">
+ <Label htmlFor="review-env">Environment</Label>
+ <select id="review-env" value={selectedEnvironmentId} onChange={(e) => setSelectedEnvironmentId(e.target.value)}>
+ {projectEnvironments.map(env => (
+ <option key={env.id} value={env.id}>{env.name}</option>
+ ))}
+ </select>
+ </div>
+ )}
+ </div>
+ )}
+
+ {/* Advanced keeps only the genuinely rare bits. */}
+ {showBuild && (
+ <>
+ <button
+ type="button"
+ className="new-service-page__advanced-toggle"
+ onClick={() => setAdvancedOpen(open => !open)}
+ aria-expanded={advancedOpen}
+ >
+ <span><Settings2 size={16} /> Advanced</span>
+ <ChevronDown size={16} />
+ </button>
+ {advancedOpen && (
+ <div className="new-service-page__advanced">
+ <p className="new-service-page__advanced-note">
+ Detected manifest settings (Dockerfile path, build/start commands) are
+ applied automatically when present. Override the fields above if the
+ detection is wrong.
+ </p>
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ );
+};
+
+export default ReviewStep;
diff --git a/frontend/src/pages/new-service/SourceStep.jsx b/frontend/src/pages/new-service/SourceStep.jsx
new file mode 100644
index 00000000..c5ac8d54
--- /dev/null
+++ b/frontend/src/pages/new-service/SourceStep.jsx
@@ -0,0 +1,49 @@
+import { GitBranch, FolderOpen, FileArchive, Package } from 'lucide-react';
+import { SiGithub } from 'react-icons/si';
+
+// Step 1 — Source. Five clean radio-cards; selecting one advances to Connect.
+const SOURCES = [
+ { mode: 'github', Icon: SiGithub, title: 'GitHub', sub: 'Connect with OAuth and choose a repository' },
+ { mode: 'manual', Icon: GitBranch, title: 'Other Git Remote', sub: 'GitLab, Bitbucket, Gitea, or SSH' },
+ { mode: 'local', Icon: FolderOpen, title: 'Manual / Local', sub: 'Register an app already on the server' },
+ { mode: 'upload', Icon: FileArchive, title: 'Upload ZIP', sub: 'Deploy or update from a zip archive' },
+ { mode: 'template', Icon: Package, title: 'Deploy Template', sub: 'Fast import from a curated repo template' },
+];
+
+const SourceStep = ({ form }) => {
+ const choose = (mode) => {
+ form.selectSource(mode);
+ form.setStep(2);
+ };
+
+ return (
+ <div className="new-service-page__step">
+ <div className="new-service-page__step-head">
+ <h2>How do you want to deploy?</h2>
+ <p>Pick a source. You can change it on the next step.</p>
+ </div>
+ <div className="new-service-page__sources" role="radiogroup" aria-label="Service source">
+ {SOURCES.map(({ mode, Icon, title, sub }) => (
+ <button
+ key={mode}
+ type="button"
+ role="radio"
+ aria-checked={form.sourceMode === mode}
+ className={`new-service-page__source-card ${form.sourceMode === mode ? 'new-service-page__source-card--on' : ''}`}
+ onClick={() => choose(mode)}
+ >
+ <span className="new-service-page__source-icon">
+ <Icon size={20} />
+ </span>
+ <span className="new-service-page__source-text">
+ <strong>{title}</strong>
+ <span>{sub}</span>
+ </span>
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+};
+
+export default SourceStep;
diff --git a/frontend/src/pages/new-service/useNewServiceForm.js b/frontend/src/pages/new-service/useNewServiceForm.js
new file mode 100644
index 00000000..8587fa3e
--- /dev/null
+++ b/frontend/src/pages/new-service/useNewServiceForm.js
@@ -0,0 +1,566 @@
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useNavigate, useSearchParams } from 'react-router-dom';
+import api from '../../services/api';
+import { useToast } from '../../contexts/ToastContext';
+
+export const APP_TYPE_OPTIONS = [
+ { value: 'auto', label: 'Auto-detect' },
+ { value: 'docker', label: 'Docker / Compose' },
+ { value: 'flask', label: 'Python' },
+ { value: 'django', label: 'Django' },
+ { value: 'php', label: 'PHP' },
+ { value: 'static', label: 'Static site' },
+];
+
+export const BUILD_METHOD_OPTIONS = [
+ { value: 'auto', label: 'Auto build' },
+ { value: 'nixpacks', label: 'Nixpacks' },
+ { value: 'dockerfile', label: 'Dockerfile' },
+ { value: 'custom', label: 'Custom command' },
+];
+
+const APP_TYPE_LABELS = Object.fromEntries(APP_TYPE_OPTIONS.map(o => [o.value, o.label]));
+const BUILD_METHOD_LABELS = Object.fromEntries(BUILD_METHOD_OPTIONS.map(o => [o.value, o.label]));
+
+// One inline "you'll need X" line per source — replaces the old three-part
+// SOURCE_GUIDES explainer block.
+export const SOURCE_NEEDS = {
+ github: 'A GitHub account connected via OAuth (Settings → Connections).',
+ manual: 'The repository URL, plus a deploy key or credentials if it is private.',
+ local: 'The path on the server, and its compose file or systemd unit if any.',
+ upload: 'A .zip of the project (with a Dockerfile/compose or a detectable runtime).',
+ template: 'A curated repo template — its manifests prefill the deploy for you.',
+};
+
+export function slugify(value) {
+ return String(value || '').toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
+}
+
+export function repoNameFromUrl(value) {
+ if (!value) return '';
+ const cleaned = value.trim().replace(/\.git$/, '');
+ const parts = cleaned.split(/[/:]/).filter(Boolean);
+ return slugify(parts[parts.length - 1] || '');
+}
+
+export function normalizeManualRepo(value) {
+ const trimmed = value.trim();
+ if (!trimmed) return '';
+ if (/^[\w.-]+\/[\w.-]+$/.test(trimmed)) return `https://github.com/${trimmed}.git`;
+ if (/^github\.com\//i.test(trimmed)) return `https://${trimmed.replace(/\.git$/, '')}.git`;
+ return trimmed;
+}
+
+export function formatAppType(value) {
+ return APP_TYPE_LABELS[value] || value || 'Auto-detect';
+}
+
+export function formatBuildMethod(value) {
+ return BUILD_METHOD_LABELS[value] || value || 'Auto build';
+}
+
+// Map an API template detail object (kind: repo) to the flat fields the wizard
+// prefills. Keeps the create-payload contract identical to before.
+function templateFields(template) {
+ const repo = template.repo || {};
+ return {
+ id: template.id,
+ name: template.name,
+ serviceName: repo.service_name || template.id,
+ description: template.description,
+ repoUrl: repo.url,
+ branch: repo.branch || 'main',
+ appType: repo.app_type || 'auto',
+ buildMethod: repo.build_method || 'auto',
+ port: repo.port || null,
+ categories: template.categories || [],
+ };
+}
+
+/**
+ * All state, derived values, and handlers for the New Service wizard. Kept in a
+ * hook so the page component is just step orchestration + submit, and the step
+ * components stay presentational. Submit payloads are byte-identical to the
+ * pre-redesign monolith — this is a flow re-skin, not a backend change.
+ */
+export function useNewServiceForm() {
+ const navigate = useNavigate();
+ const toast = useToast();
+ const [searchParams] = useSearchParams();
+
+ const [step, setStep] = useState(1);
+ const [sourceMode, setSourceMode] = useState('github');
+
+ const [githubStatus, setGithubStatus] = useState(null);
+ const [repos, setRepos] = useState([]);
+ const [reposLoading, setReposLoading] = useState(false);
+ const [repoSearch, setRepoSearch] = useState('');
+ const [selectedRepo, setSelectedRepo] = useState(null);
+
+ // Repo-kind deploy templates, fetched from the backend catalog.
+ const [templates, setTemplates] = useState([]);
+ const [templatesLoading, setTemplatesLoading] = useState(false);
+ const [selectedTemplate, setSelectedTemplate] = useState(null);
+ const [templateManifest, setTemplateManifest] = useState(null);
+ const [templateManifestLoading, setTemplateManifestLoading] = useState(false);
+
+ const [branches, setBranches] = useState([]);
+ const [branchesLoading, setBranchesLoading] = useState(false);
+ const [repoManifest, setRepoManifest] = useState(null);
+ const [repoManifestLoading, setRepoManifestLoading] = useState(false);
+ const [manualRepoUrl, setManualRepoUrl] = useState('');
+
+ const [name, setName] = useState('');
+ const [nameTouched, setNameTouched] = useState(false);
+ const [branch, setBranch] = useState('main');
+ const [appType, setAppType] = useState('auto');
+ const [buildMethod, setBuildMethod] = useState('auto');
+ const [port, setPort] = useState('');
+ const [ingressPlane, setIngressPlane] = useState('nginx');
+ const [autoDeploy, setAutoDeploy] = useState(true);
+ const [advancedOpen, setAdvancedOpen] = useState(false);
+ const [submitting, setSubmitting] = useState(false);
+
+ const [buildpack, setBuildpack] = useState(null);
+ const [buildpackLoading, setBuildpackLoading] = useState(false);
+ const [buildpackOverrides, setBuildpackOverrides] = useState({});
+
+ const [localPath, setLocalPath] = useState('');
+ const [composeFile, setComposeFile] = useState('');
+ const [systemdUnit, setSystemdUnit] = useState('');
+ const [managedBy, setManagedBy] = useState('auto');
+
+ const [uploadFile, setUploadFile] = useState(null);
+ const [uploadDragOver, setUploadDragOver] = useState(false);
+
+ const [projects, setProjects] = useState([]);
+ const [selectedProjectId, setSelectedProjectId] = useState('');
+ const [selectedEnvironmentId, setSelectedEnvironmentId] = useState('');
+ const [projectEnvironments, setProjectEnvironments] = useState([]);
+
+ const githubConnection = githubStatus?.connection;
+ const githubConfigured = githubStatus?.configured;
+ const normalizedManualRepo = useMemo(() => normalizeManualRepo(manualRepoUrl), [manualRepoUrl]);
+
+ const activeManifest = sourceMode === 'template' ? templateManifest : repoManifest;
+ const activeManifestLoading = sourceMode === 'template' ? templateManifestLoading : repoManifestLoading;
+ const recommended = activeManifest?.recommended || {};
+
+ const detectedServiceName = useMemo(() => {
+ if (sourceMode === 'template' && selectedTemplate) {
+ return slugify(selectedTemplate.serviceName || selectedTemplate.name || '');
+ }
+ if (sourceMode === 'github' && selectedRepo) return slugify(selectedRepo.name || '');
+ return repoNameFromUrl(normalizedManualRepo);
+ }, [normalizedManualRepo, selectedRepo, selectedTemplate, sourceMode]);
+
+ const serviceName = nameTouched ? name : detectedServiceName;
+
+ const canSubmit = sourceMode === 'github'
+ ? Boolean(githubConnection && selectedRepo && serviceName?.length >= 2)
+ : sourceMode === 'template'
+ ? Boolean(selectedTemplate && serviceName?.length >= 2)
+ : sourceMode === 'local'
+ ? Boolean(serviceName?.length >= 2 && localPath?.length >= 1)
+ : sourceMode === 'upload'
+ ? Boolean(serviceName?.length >= 2 && uploadFile)
+ : Boolean(normalizedManualRepo && serviceName?.length >= 2);
+
+ // Whether step 2 (Connect) has enough input to move on to Review.
+ const canProceedFromConnect = sourceMode === 'github'
+ ? Boolean(githubConnection && selectedRepo)
+ : sourceMode === 'template'
+ ? Boolean(selectedTemplate)
+ : sourceMode === 'local'
+ ? Boolean(localPath?.length >= 1)
+ : sourceMode === 'upload'
+ ? Boolean(uploadFile)
+ : Boolean(normalizedManualRepo);
+
+ const buildSummary = buildMethod === 'auto' && recommended.build_method
+ ? `Auto → ${formatBuildMethod(recommended.build_method)}`
+ : formatBuildMethod(buildMethod);
+
+ const ingressProxyEligible = appType === 'docker'
+ || appType === 'auto'
+ || (sourceMode === 'local' && managedBy === 'docker_compose');
+
+ const buildpackEligible = (buildMethod === 'auto' || buildMethod === 'nixpacks')
+ && (sourceMode === 'github' || sourceMode === 'manual' || sourceMode === 'template');
+
+ const loadGithubStatus = useCallback(async () => {
+ try {
+ const data = await api.getGithubSourceStatus();
+ setGithubStatus(data);
+ } catch (err) {
+ toast.error(err.message || 'Failed to load GitHub connection');
+ }
+ }, [toast]);
+
+ const loadGithubRepos = useCallback(async (search = '') => {
+ setReposLoading(true);
+ try {
+ const data = await api.listGithubRepositories({ search, perPage: 80 });
+ setRepos(data.repos || []);
+ } catch (err) {
+ toast.error(err.message || 'Failed to load GitHub repositories');
+ } finally {
+ setReposLoading(false);
+ }
+ }, [toast]);
+
+ const loadBranches = useCallback(async (fullName) => {
+ setBranchesLoading(true);
+ try {
+ const data = await api.listGithubBranches(fullName);
+ setBranches(data.branches || []);
+ } catch (err) {
+ setBranches([]);
+ toast.error(err.message || 'Failed to load branches');
+ } finally {
+ setBranchesLoading(false);
+ }
+ }, [toast]);
+
+ const loadTemplates = useCallback(async () => {
+ setTemplatesLoading(true);
+ try {
+ const data = await api.listTemplates();
+ setTemplates((data.templates || []).filter(t => (t.kind || 'compose') === 'repo'));
+ } catch (err) {
+ setTemplates([]);
+ } finally {
+ setTemplatesLoading(false);
+ }
+ }, []);
+
+ useEffect(() => { loadGithubStatus(); }, [loadGithubStatus]);
+ useEffect(() => { loadTemplates(); }, [loadTemplates]);
+
+ useEffect(() => {
+ if (!ingressProxyEligible && ingressPlane !== 'nginx') {
+ setIngressPlane('nginx');
+ }
+ }, [ingressProxyEligible, ingressPlane]);
+
+ useEffect(() => {
+ let cancelled = false;
+ api.getProjects()
+ .then(data => {
+ if (cancelled) return;
+ setProjects(Array.isArray(data?.projects) ? data.projects : []);
+ })
+ .catch(() => { if (!cancelled) setProjects([]); });
+ return () => { cancelled = true; };
+ }, []);
+
+ useEffect(() => {
+ if (!selectedProjectId) {
+ setProjectEnvironments([]);
+ setSelectedEnvironmentId('');
+ return undefined;
+ }
+ let cancelled = false;
+ api.getProject(selectedProjectId)
+ .then(data => {
+ if (cancelled) return;
+ const envs = Array.isArray(data?.project?.environments) ? data.project.environments : [];
+ setProjectEnvironments(envs);
+ const def = envs.find(e => e.is_default) || envs[0];
+ setSelectedEnvironmentId(def ? String(def.id) : '');
+ })
+ .catch(() => {
+ if (!cancelled) {
+ setProjectEnvironments([]);
+ setSelectedEnvironmentId('');
+ }
+ });
+ return () => { cancelled = true; };
+ }, [selectedProjectId]);
+
+ useEffect(() => {
+ if (sourceMode === 'github' && githubConnection) {
+ loadGithubRepos();
+ }
+ }, [sourceMode, githubConnection, loadGithubRepos]);
+
+ useEffect(() => {
+ if (selectedRepo) {
+ setBranch(selectedRepo.default_branch || 'main');
+ loadBranches(selectedRepo.full_name);
+ }
+ }, [selectedRepo, loadBranches]);
+
+ useEffect(() => {
+ if (sourceMode !== 'github' || !selectedRepo) {
+ if (sourceMode !== 'template') setRepoManifest(null);
+ setRepoManifestLoading(false);
+ return undefined;
+ }
+ let cancelled = false;
+ setRepoManifestLoading(true);
+ api.inspectGithubRepositoryManifest(selectedRepo.full_name, branch || selectedRepo.default_branch || 'main')
+ .then((data) => {
+ if (cancelled) return;
+ const manifest = data.manifest || null;
+ setRepoManifest(manifest);
+ const detectedPort = manifest?.recommended?.port;
+ if (!port && detectedPort) setPort(String(detectedPort));
+ })
+ .catch((err) => {
+ if (!cancelled) {
+ setRepoManifest(null);
+ toast.error(err.message || 'Failed to inspect repository manifests');
+ }
+ })
+ .finally(() => { if (!cancelled) setRepoManifestLoading(false); });
+ return () => { cancelled = true; };
+ }, [branch, port, selectedRepo, sourceMode, toast]);
+
+ useEffect(() => {
+ if (selectedRepo && !nameTouched) {
+ setName(slugify(selectedRepo.name || ''));
+ }
+ }, [selectedRepo, nameTouched]);
+
+ // Build-pack detection (zero-Dockerfile). Only repo-based sources.
+ useEffect(() => {
+ if (!buildpackEligible) {
+ setBuildpack(null);
+ setBuildpackLoading(false);
+ return undefined;
+ }
+ const body = { branch: branch || 'main', name: detectedServiceName || 'app' };
+ if (sourceMode === 'github' && selectedRepo && githubConnection) {
+ body.source_connection_id = githubConnection.id;
+ body.repository_full_name = selectedRepo.full_name;
+ body.repo_url = `https://github.com/${selectedRepo.full_name}.git`;
+ } else if (sourceMode === 'template' && selectedTemplate) {
+ body.repo_url = selectedTemplate.repoUrl;
+ } else if (sourceMode === 'manual' && normalizedManualRepo) {
+ body.repo_url = normalizedManualRepo;
+ } else {
+ setBuildpack(null);
+ return undefined;
+ }
+ let cancelled = false;
+ setBuildpackLoading(true);
+ setBuildpackOverrides({});
+ api.detectBuildpack(body)
+ .then((data) => { if (!cancelled) setBuildpack(data); })
+ .catch(() => { if (!cancelled) setBuildpack(null); })
+ .finally(() => { if (!cancelled) setBuildpackLoading(false); });
+ return () => { cancelled = true; };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [buildpackEligible, sourceMode, selectedRepo, selectedTemplate, normalizedManualRepo, branch, githubConnection]);
+
+ async function handleConnectGithub() {
+ try {
+ const redirectUri = `${window.location.origin}/connections/callback/github`;
+ sessionStorage.setItem('sourceConnectionReturnTo', '/services/new');
+ const { auth_url } = await api.startSourceConnection('github', redirectUri);
+ window.location.href = auth_url;
+ } catch (err) {
+ toast.error(err.message || 'Failed to start GitHub connection');
+ }
+ }
+
+ function selectSource(mode) {
+ setSourceMode(mode);
+ if (mode === 'local') setAppType('docker');
+ if (mode === 'upload') setAppType('auto');
+ }
+
+ // Apply a repo-kind template (API detail object) to the flat wizard fields
+ // and fetch its live/hinted manifest for the review step.
+ const selectTemplate = useCallback((templateDetail) => {
+ const fields = templateFields(templateDetail);
+ setSelectedTemplate(fields);
+ setSelectedRepo(null);
+ setManualRepoUrl(fields.repoUrl || '');
+ setName(slugify(fields.serviceName || fields.name || ''));
+ setNameTouched(false);
+ setBranch(fields.branch || 'main');
+ setAppType(fields.appType || 'auto');
+ setBuildMethod(fields.buildMethod || 'auto');
+ setPort(fields.port ? String(fields.port) : '');
+ setAutoDeploy(true);
+
+ setTemplateManifest(null);
+ setTemplateManifestLoading(true);
+ api.inspectTemplateManifest(fields.id, fields.branch)
+ .then((data) => setTemplateManifest(data?.manifest || null))
+ .catch(() => setTemplateManifest(null))
+ .finally(() => setTemplateManifestLoading(false));
+ }, []);
+
+ // Pick a template by id (deep link or list click): fetch its detail, then apply.
+ const selectTemplateById = useCallback(async (templateId) => {
+ try {
+ const result = await api.getTemplate(templateId);
+ if (result?.template) {
+ setSourceMode('template');
+ selectTemplate(result.template);
+ return true;
+ }
+ } catch (err) {
+ toast.error(err.message || 'Failed to load template');
+ }
+ return false;
+ }, [selectTemplate, toast]);
+
+ function handleManualRepoChange(value) {
+ setManualRepoUrl(value);
+ if (!nameTouched) setName(repoNameFromUrl(normalizeManualRepo(value)));
+ }
+
+ function onNameChange(value) {
+ setNameTouched(true);
+ setName(slugify(value));
+ }
+
+ function onUploadFile(file) {
+ if (!file) return;
+ setUploadFile(file);
+ if (!nameTouched) setName(slugify(file.name.replace(/\.zip$/i, '')));
+ }
+
+ // Deep links: /services/new?template=<id> or ?source=<mode> land preloaded on
+ // the Connect step. Runs once on mount.
+ useEffect(() => {
+ const templateId = searchParams.get('template');
+ const source = searchParams.get('source');
+ if (templateId) {
+ selectTemplateById(templateId).then((ok) => { if (ok) setStep(2); });
+ return;
+ }
+ if (source && ['github', 'manual', 'local', 'upload', 'template'].includes(source)) {
+ selectSource(source);
+ setStep(2);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ async function handleSubmit(e) {
+ if (e) e.preventDefault();
+ if (!canSubmit) {
+ const msg = sourceMode === 'github'
+ ? 'Select a GitHub repository'
+ : sourceMode === 'template'
+ ? 'Select a service template'
+ : sourceMode === 'local'
+ ? 'Service name and server path are required'
+ : sourceMode === 'upload'
+ ? 'Service name and a zip file are required'
+ : 'Repository URL is required';
+ toast.error(msg);
+ return;
+ }
+
+ setSubmitting(true);
+ const projectEnvPayload = {};
+ if (selectedProjectId) {
+ projectEnvPayload.project_id = Number(selectedProjectId);
+ if (selectedEnvironmentId) projectEnvPayload.environment_id = Number(selectedEnvironmentId);
+ }
+ try {
+ if (sourceMode === 'local') {
+ const payload = {
+ name: serviceName,
+ app_type: appType,
+ root_path: localPath.trim(),
+ compose_file: composeFile.trim() || undefined,
+ systemd_unit: systemdUnit.trim() || undefined,
+ managed_by: managedBy === 'auto' ? undefined : managedBy,
+ ingress_plane: ingressProxyEligible ? ingressPlane : 'nginx',
+ ...projectEnvPayload,
+ };
+ const result = await api.createManualApp(payload);
+ toast.success('Manual service registered');
+ navigate(`/services/${result.app.id}`);
+ } else if (sourceMode === 'upload') {
+ const formData = new FormData();
+ formData.append('file', uploadFile);
+ formData.append('name', serviceName);
+ formData.append('app_type', appType);
+ formData.append('auto_deploy', autoDeploy ? 'true' : 'false');
+ formData.append('ingress_plane', ingressProxyEligible ? ingressPlane : 'nginx');
+ if (projectEnvPayload.project_id) formData.append('project_id', projectEnvPayload.project_id);
+ if (projectEnvPayload.environment_id) formData.append('environment_id', projectEnvPayload.environment_id);
+ const result = await api.uploadAppZip(formData);
+ toast.success('Upload service created');
+ navigate(`/services/${result.app.id}`);
+ } else {
+ const payload = {
+ name: serviceName,
+ branch: branch.trim() || null,
+ app_type: appType,
+ build_method: buildMethod,
+ port: port ? Number(port) : null,
+ auto_deploy: autoDeploy,
+ ingress_plane: ingressProxyEligible ? ingressPlane : 'nginx',
+ ...projectEnvPayload,
+ };
+ if (recommended.dockerfile_path) payload.dockerfile_path = recommended.dockerfile_path;
+ if (recommended.custom_build_cmd) payload.custom_build_cmd = recommended.custom_build_cmd;
+ if (recommended.custom_start_cmd) payload.custom_start_cmd = recommended.custom_start_cmd;
+ if (buildpackEligible && buildpack?.plan) {
+ payload.buildpack_plan = buildpack.plan;
+ if (Object.keys(buildpackOverrides).length > 0) {
+ payload.buildpack_overrides = buildpackOverrides;
+ }
+ }
+
+ if (sourceMode === 'github') {
+ payload.source_connection_id = githubConnection.id;
+ payload.repository_full_name = selectedRepo.full_name;
+ payload.repo_url = `https://github.com/${selectedRepo.full_name}.git`;
+ } else if (sourceMode === 'template') {
+ payload.template_id = selectedTemplate.id;
+ payload.repo_url = selectedTemplate.repoUrl;
+ } else {
+ payload.repo_url = normalizedManualRepo;
+ }
+
+ const result = await api.createAppFromRepository(payload);
+ toast.success('Repository service created');
+ navigate(`/services/${result.app.id}`);
+ }
+ } catch (err) {
+ toast.error(err.message || 'Failed to create service');
+ } finally {
+ setSubmitting(false);
+ }
+ }
+
+ return {
+ // step control
+ step, setStep,
+ // source
+ sourceMode, selectSource,
+ // github
+ githubStatus, githubConnection, githubConfigured,
+ repos, reposLoading, repoSearch, setRepoSearch, selectedRepo, setSelectedRepo,
+ loadGithubRepos, handleConnectGithub, branches, branchesLoading,
+ // templates
+ templates, templatesLoading, selectedTemplate, selectTemplate, selectTemplateById,
+ // manual / local / upload
+ manualRepoUrl, handleManualRepoChange, normalizedManualRepo,
+ localPath, setLocalPath, composeFile, setComposeFile,
+ systemdUnit, setSystemdUnit, managedBy, setManagedBy,
+ uploadFile, onUploadFile, uploadDragOver, setUploadDragOver,
+ // core fields
+ name, serviceName, onNameChange, nameTouched,
+ branch, setBranch, appType, setAppType, buildMethod, setBuildMethod,
+ port, setPort, ingressPlane, setIngressPlane, autoDeploy, setAutoDeploy,
+ advancedOpen, setAdvancedOpen,
+ // manifest / buildpack
+ activeManifest, activeManifestLoading, recommended, buildSummary,
+ buildpack, buildpackLoading, buildpackOverrides, setBuildpackOverrides, buildpackEligible,
+ // projects
+ projects, selectedProjectId, setSelectedProjectId,
+ selectedEnvironmentId, setSelectedEnvironmentId, projectEnvironments,
+ // derived + submit
+ ingressProxyEligible, canSubmit, canProceedFromConnect, submitting, handleSubmit,
+ };
+}
diff --git a/frontend/src/styles/pages/_new-service.scss b/frontend/src/styles/pages/_new-service.scss
index e61c8bce..2a04a37b 100644
--- a/frontend/src/styles/pages/_new-service.scss
+++ b/frontend/src/styles/pages/_new-service.scss
@@ -1,345 +1,230 @@
// ============================================
-// NEW SERVICE PAGE
+// NEW SERVICE PAGE (plan 43 — three-step wizard)
+// A slim stepper header over one centered column (~760px). The right rail of the
+// old form-wall is gone; only the review step has real content. Sub-component
+// blocks (repo list, template rows, manifest card, fields) are shared across
+// steps and kept below.
// ============================================
.new-service-page {
- max-width: 1200px;
+ max-width: 820px;
+ margin: 0 auto;
- &__breadcrumb {
+ // ── Stepper header ──────────────────────────────────────
+ &__stepper {
display: flex;
align-items: center;
gap: $space-2;
- margin-bottom: $space-4;
- color: $text-tertiary;
- font-size: $font-size-sm;
-
- a {
- color: $text-secondary;
- text-decoration: none;
-
- &:hover {
- color: $text-primary;
- }
- }
+ margin-bottom: $space-5;
}
- &__header {
+ &__stepper-item {
display: flex;
- align-items: flex-start;
- justify-content: space-between;
- gap: $space-4;
- margin-bottom: $space-5;
-
- h1 {
- margin: 0;
- color: $text-primary;
- font-size: $font-size-2xl;
- font-weight: $font-weight-bold;
- }
+ align-items: center;
+ gap: $space-2;
+ padding: $space-2 $space-3;
+ background: transparent;
+ border: none;
+ border-radius: $radius-md;
+ color: $text-tertiary;
+ font: inherit;
+ cursor: default;
- p {
- max-width: 620px;
- margin: $space-1 0 0;
- color: $text-tertiary;
- font-size: $font-size-sm;
- line-height: 1.5;
+ &::after {
+ content: '';
+ width: 28px;
+ height: 1px;
+ margin-left: $space-2;
+ background: $border-subtle;
}
- }
-
- // Redesign: the demo's horizontal "method card" chooser (.method-grid).
- &__method-grid {
- display: grid;
- grid-template-columns: repeat(3, minmax(0, 1fr));
- gap: 14px;
- margin-bottom: $space-4;
- }
- @media (max-width: $breakpoint-md) {
- &__method-grid {
- grid-template-columns: 1fr;
+ &:last-child::after {
+ display: none;
}
- }
- &__method-card {
- display: block;
- position: relative;
- padding: 18px;
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: var(--radius);
- color: $text-primary;
- font: inherit;
- text-align: left;
- text-decoration: none;
- cursor: pointer;
- transition: border-color $transition-fast, background $transition-fast, transform $transition-fast;
-
- &:hover {
- background: var(--surface-2);
- border-color: var(--border-strong);
- transform: translateY(-2px);
+ &--done {
+ cursor: pointer;
+ color: $text-secondary;
}
- &--on {
- border-color: var(--accent-dim);
- background: var(--accent-bg);
+ &--current {
+ color: $text-primary;
}
}
- // method-card icon tile: dim by default, accent when its card is selected
- &__method-icon {
- width: 42px;
- height: 42px;
- margin-bottom: 13px;
- border-radius: 11px;
- background: var(--surface-2);
- color: var(--text-dim);
- transition: background $transition-fast, color $transition-fast;
- }
- &__method-card--on &__method-icon {
- background: var(--accent-bg);
- color: var(--accent-bright);
- }
-
- &__method-title {
- display: block;
- font-size: 14px;
- font-weight: $font-weight-semibold;
- }
-
- &__method-sub {
- display: block;
- margin-top: 4px;
- color: var(--text-faint);
- font-size: 12px;
- line-height: 1.45;
- }
-
- // Icon tiles: grid + place-items is the most reliable centering (no inline
- // baseline/descender offset that inline-flex leaves behind), and a block SVG
- // drops the phantom inline gap — that's what left the glyphs off-center.
- &__method-icon,
- &__connect-icon,
- &__deploy-icon {
+ &__stepper-dot {
display: grid;
place-items: center;
- flex-shrink: 0;
+ width: 24px;
+ height: 24px;
+ border-radius: $radius-full;
+ background: $bg-elevated;
+ border: 1px solid $border-subtle;
+ color: inherit;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
svg { display: block; }
}
- &__provider-title svg {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- }
- &__connect-icon,
- &__deploy-icon {
- width: 36px;
- height: 36px;
- border-radius: $radius-lg;
- background: $bg-elevated;
- color: $accent-primary;
+ &__stepper-item--current &__stepper-dot {
+ background: var(--accent-bg);
+ border-color: var(--accent-dim);
+ color: var(--accent-bright);
}
- &__wizard {
- display: grid;
- grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
- gap: $space-4;
- align-items: start;
+ &__stepper-item--done &__stepper-dot {
+ background: rgba(16, 185, 129, 0.12);
+ border-color: rgba(16, 185, 129, 0.35);
+ color: $success;
}
- &__panel {
- background: $bg-card;
- border: 1px solid $border-subtle;
- border-radius: $radius-lg;
+ &__stepper-label {
+ font-size: $font-size-sm;
+ font-weight: $font-weight-medium;
}
- &__provider-panel,
- &__review-panel {
+ // ── Single centered column ──────────────────────────────
+ &__wizard-col {
display: grid;
gap: $space-5;
- padding: $space-5;
}
- &__review-panel {
- position: sticky;
- top: $space-4;
+ &__step {
+ display: grid;
+ gap: $space-4;
}
- &__section-heading {
- display: flex;
- align-items: center;
- gap: $space-2;
-
- svg {
- color: $accent-primary;
- }
+ &__step-head {
+ display: grid;
+ gap: $space-1;
h2 {
margin: 0;
color: $text-primary;
- font-size: $font-size-base;
+ font-size: $font-size-xl;
font-weight: $font-weight-semibold;
}
- }
-
- &__section-docs {
- margin-left: auto;
- }
-
- // Per-source explainer strip above the selected source's form.
- &__source-guide {
- margin: $space-3 0 $space-4;
- padding: $space-3 $space-4;
- border: 1px solid $border-color;
- border-radius: $radius-md;
- background: $bg-elevated;
p {
- margin: 0 0 $space-2;
+ margin: 0;
+ color: $text-tertiary;
font-size: $font-size-sm;
- color: $text-secondary;
+ line-height: 1.5;
}
}
- &__source-guide-what {
- color: $text-primary !important;
- font-weight: $font-weight-medium;
- }
-
- &__source-guide-need strong {
- color: $text-secondary;
- }
-
- &__source-guide-steps {
- margin: 0;
- padding-left: $space-4;
+ // "you'll need X" one-liner
+ &__need {
display: flex;
- flex-direction: column;
- gap: 2px;
+ align-items: center;
+ gap: $space-2;
+ margin: 0 !important;
+ color: $text-tertiary !important;
- li {
- font-size: $font-size-sm;
- color: $text-tertiary;
+ svg {
+ flex-shrink: 0;
+ color: $accent-primary;
}
}
- &__template-example {
- margin-left: $space-2;
- padding: 1px $space-2;
- border-radius: $radius-sm;
- background: rgba($accent-primary-raw, 0.15);
- color: $accent-primary;
- font-size: $font-size-xs;
- font-weight: $font-weight-medium;
- text-transform: uppercase;
- letter-spacing: 0.04em;
- vertical-align: middle;
- }
-
- &__provider-grid {
+ // ── Step 1: source radio-cards ──────────────────────────
+ &__sources {
display: grid;
- grid-template-columns: repeat(4, minmax(0, 1fr));
gap: $space-3;
}
- &__provider-card {
- position: relative;
- display: grid;
+ &__source-card {
+ display: flex;
+ align-items: center;
gap: $space-3;
- min-height: 160px;
padding: $space-4;
- background: $bg-elevated;
- border: 1px solid $border-subtle;
- border-radius: $radius-lg;
+ background: var(--surface);
+ border: 1px solid var(--border);
+ border-radius: var(--radius);
color: $text-primary;
+ font: inherit;
text-align: left;
cursor: pointer;
transition: border-color $transition-fast, background $transition-fast, transform $transition-fast;
&:hover {
- background: $bg-hover;
- border-color: $border-hover;
+ background: var(--surface-2);
+ border-color: var(--border-strong);
transform: translateY(-1px);
}
- &--active {
- border-color: rgba(20, 184, 166, 0.55);
- box-shadow: inset 0 0 0 1px rgba(20, 184, 166, 0.18);
+ &--on {
+ border-color: var(--accent-dim);
+ background: var(--accent-bg);
}
+ }
- > svg {
- position: absolute;
- top: $space-4;
- right: $space-4;
- color: $success;
- }
+ &__source-icon {
+ display: grid;
+ place-items: center;
+ width: 42px;
+ height: 42px;
+ flex-shrink: 0;
+ border-radius: 11px;
+ background: var(--surface-2);
+ color: var(--text-dim);
+ transition: background $transition-fast, color $transition-fast;
- small {
- color: $text-tertiary;
- font-size: $font-size-xs;
- line-height: 1.5;
- }
+ svg { display: block; }
}
- &__provider-meta {
- width: max-content;
- padding: 3px $space-2;
- border: 1px solid $border-subtle;
- border-radius: $radius-full;
- color: $text-tertiary;
- font-size: $font-size-xs;
- line-height: 1;
+ &__source-card--on &__source-icon {
+ background: var(--accent-bg);
+ color: var(--accent-bright);
}
- &__provider-title {
- display: flex;
- align-items: center;
- gap: $space-2;
-
- svg {
- color: $accent-primary;
- }
+ &__source-text {
+ display: grid;
+ gap: 3px;
strong {
- font-size: $font-size-base;
+ font-size: 14px;
font-weight: $font-weight-semibold;
}
+
+ span {
+ color: var(--text-faint);
+ font-size: 12px;
+ line-height: 1.45;
+ }
}
- &__connect-box {
+ // ── Step 2: source-specific pane ────────────────────────
+ &__pane {
display: grid;
gap: $space-4;
- padding: $space-4;
- background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
- border: 1px solid $border-subtle;
- border-radius: $radius-lg;
}
- &__connect-heading {
+ &__pane-actions {
display: flex;
- align-items: center;
- gap: $space-3;
+ gap: $space-2;
+ }
- strong,
- span {
- display: block;
- }
+ &__inline-fields {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: $space-4;
+ padding-top: $space-2;
+ border-top: 1px solid $border-subtle;
+ }
- strong {
- color: $text-primary;
- font-size: $font-size-sm;
- font-weight: $font-weight-semibold;
- }
+ &__connect-icon {
+ display: grid;
+ place-items: center;
+ width: 36px;
+ height: 36px;
+ flex-shrink: 0;
+ border-radius: $radius-lg;
+ background: $bg-elevated;
+ color: $accent-primary;
- span {
- margin-top: 2px;
- color: $text-tertiary;
- font-size: $font-size-xs;
- line-height: 1.4;
- }
+ svg { display: block; }
}
&__github-account {
@@ -395,7 +280,7 @@
&__repo-list {
display: grid;
gap: $space-2;
- max-height: 430px;
+ max-height: 380px;
overflow-y: auto;
padding-right: $space-1;
}
@@ -478,7 +363,7 @@
padding: $space-8 $space-4;
text-align: center;
- h2 {
+ h3 {
margin: 0;
color: $text-primary;
font-size: $font-size-lg;
@@ -500,24 +385,23 @@
justify-content: center;
gap: $space-2;
flex-wrap: wrap;
-
- &--left {
- justify-content: flex-start;
- }
}
&__template-list {
display: grid;
gap: $space-2;
+ max-height: 420px;
+ overflow-y: auto;
+ padding-right: $space-1;
}
&__template-row {
display: grid;
- grid-template-columns: minmax(0, 1fr) auto auto;
+ grid-template-columns: minmax(0, 1fr) auto;
align-items: center;
gap: $space-3;
width: 100%;
- min-height: 86px;
+ min-height: 72px;
padding: $space-3;
background: $bg-elevated;
border: 1px solid $border-subtle;
@@ -571,28 +455,11 @@
em {
font-style: normal;
+ font-family: $font-mono;
}
}
- &__template-badges {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: $space-1;
- flex-wrap: wrap;
- max-width: 210px;
-
- span {
- padding: 3px $space-2;
- background: rgba(20, 184, 166, 0.1);
- border: 1px solid rgba(20, 184, 166, 0.22);
- border-radius: $radius-full;
- color: $accent-primary;
- font-size: $font-size-xs;
- line-height: 1;
- }
- }
-
+ // ── Fields (shared) ─────────────────────────────────────
&__field {
display: grid;
gap: $space-2;
@@ -626,107 +493,54 @@
}
}
- &__repo-preview,
- &__summary {
- display: grid;
- gap: $space-2;
-
- > div {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- gap: $space-3;
- min-width: 0;
- padding: $space-3;
- background: $bg-elevated;
- border: 1px solid $border-subtle;
- border-radius: $radius-md;
- }
-
- span,
- strong {
- display: block;
- }
-
- span {
- color: $text-tertiary;
- font-size: $font-size-xs;
- line-height: 1.4;
- }
-
- strong {
- min-width: 0;
- color: $text-primary;
- font-size: $font-size-sm;
- font-weight: $font-weight-semibold;
- overflow-wrap: anywhere;
- text-align: right;
- }
- }
-
- &__repo-preview {
- grid-template-columns: repeat(3, minmax(0, 1fr));
-
- > div {
- display: grid;
- justify-content: stretch;
- }
-
- strong {
- text-align: left;
- }
+ &__optional {
+ color: $text-tertiary;
+ font-weight: $font-weight-normal;
}
- &__deploy-card {
- display: flex;
+ &__upload-drop {
+ display: grid;
+ place-items: center;
gap: $space-3;
- align-items: flex-start;
+ min-height: 160px;
+ padding: $space-5;
+ background: $bg-elevated;
+ border: 2px dashed $border-subtle;
+ border-radius: $radius-lg;
+ color: $text-tertiary;
+ text-align: center;
+ cursor: pointer;
+ transition: border-color $transition-fast, background $transition-fast, color $transition-fast;
- h2 {
- margin: 0;
- color: $text-primary;
- font-size: $font-size-lg;
- font-weight: $font-weight-semibold;
+ &:hover,
+ &--over {
+ background: var(--accent-bg, rgba(109, 124, 255, 0.08));
+ border-color: var(--accent-dim, $accent-primary);
+ color: $text-secondary;
}
- p {
- margin: $space-1 0 0;
- color: $text-tertiary;
+ span {
font-size: $font-size-sm;
- line-height: 1.5;
+ font-weight: $font-weight-medium;
}
- }
- &__deploy-icon {
- background: rgba(16, 185, 129, 0.1);
- color: $success;
+ input {
+ display: none;
+ }
}
- &__flow {
+ // ── Step 3: review ──────────────────────────────────────
+ &__fields-grid {
display: grid;
- grid-template-columns: 1fr auto 1fr auto 1fr;
- align-items: center;
- gap: $space-2;
- color: $text-tertiary;
-
- > div {
- display: grid;
- place-items: center;
- gap: $space-2;
- min-height: 68px;
- background: $bg-elevated;
- border: 1px solid $border-subtle;
- border-radius: $radius-md;
- color: $text-secondary;
- font-size: $font-size-xs;
- font-weight: $font-weight-medium;
- }
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: $space-4;
}
- &__manifest-card {
+ &__manifest-card,
+ &__env-card {
display: grid;
gap: $space-3;
- padding: $space-3;
+ padding: $space-4;
background: $bg-elevated;
border: 1px solid $border-subtle;
border-radius: $radius-md;
@@ -759,6 +573,24 @@
}
}
+ &__env-head {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ color: $text-secondary;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-medium;
+
+ svg { color: $accent-primary; }
+ }
+
+ &__env-note {
+ margin: 0;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ line-height: 1.45;
+ }
+
&__manifest-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
@@ -934,54 +766,6 @@
}
}
- &__advanced-toggle {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: $space-3;
- min-height: 44px;
- padding: 0 $space-3;
- background: $bg-elevated;
- border: 1px solid $border-subtle;
- border-radius: $radius-md;
- color: $text-secondary;
- cursor: pointer;
- transition: border-color $transition-fast, background $transition-fast;
-
- &:hover {
- background: $bg-hover;
- border-color: $border-hover;
- }
-
- span {
- display: flex;
- align-items: center;
- gap: $space-2;
- font-size: $font-size-sm;
- font-weight: $font-weight-medium;
- }
-
- &[aria-expanded='true'] > svg {
- transform: rotate(180deg);
- }
-
- > svg {
- transition: transform $transition-fast;
- }
- }
-
- &__advanced {
- display: grid;
- gap: $space-4;
- padding-top: $space-1;
- }
-
- &__two-col {
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: $space-4;
- }
-
&__toggle {
display: flex;
align-items: center;
@@ -1012,102 +796,89 @@
}
}
- &__notes {
- display: grid;
- gap: $space-2;
- }
-
&__note {
display: flex;
- align-items: flex-start;
+ align-items: center;
gap: $space-2;
- padding: $space-3;
+ min-height: 40px;
+ padding: 0 $space-3;
background: $bg-elevated;
border: 1px solid $border-subtle;
border-radius: $radius-md;
color: $text-tertiary;
- font-size: $font-size-xs;
- line-height: 1.45;
+ font-size: $font-size-sm;
svg {
- margin-top: 1px;
color: $text-secondary;
flex-shrink: 0;
}
}
- &__actions {
+ &__advanced-toggle {
display: flex;
- justify-content: flex-end;
- gap: $space-2;
- padding-top: $space-1;
- }
-
- &__upload-drop {
- display: grid;
- place-items: center;
+ align-items: center;
+ justify-content: space-between;
gap: $space-3;
- min-height: 160px;
- padding: $space-5;
+ min-height: 44px;
+ padding: 0 $space-3;
background: $bg-elevated;
- border: 2px dashed $border-subtle;
- border-radius: $radius-lg;
- color: $text-tertiary;
- text-align: center;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ color: $text-secondary;
cursor: pointer;
- transition: border-color $transition-fast, background $transition-fast, color $transition-fast;
+ transition: border-color $transition-fast, background $transition-fast;
- &:hover,
- &--over {
- background: var(--accent-bg, rgba(109, 124, 255, 0.08));
- border-color: var(--accent-dim, $accent-primary);
- color: $text-secondary;
+ &:hover {
+ background: $bg-hover;
+ border-color: $border-hover;
}
span {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
font-size: $font-size-sm;
font-weight: $font-weight-medium;
}
- input {
- display: none;
+ &[aria-expanded='true'] > svg {
+ transform: rotate(180deg);
}
- }
-}
-@media (max-width: $breakpoint-xl) {
- .new-service-page {
- &__provider-grid {
- grid-template-columns: repeat(2, minmax(0, 1fr));
+ > svg {
+ transition: transform $transition-fast;
}
}
-}
-@media (max-width: $breakpoint-lg) {
- .new-service-page {
- &__wizard {
- grid-template-columns: 1fr;
- }
+ &__advanced {
+ display: grid;
+ gap: $space-4;
+ padding-top: $space-1;
+ }
- &__review-panel {
- position: static;
- }
+ &__advanced-note {
+ margin: 0;
+ color: $text-tertiary;
+ font-size: $font-size-sm;
+ line-height: 1.5;
+ }
+
+ // ── Footer nav ──────────────────────────────────────────
+ &__footer {
+ display: flex;
+ justify-content: space-between;
+ gap: $space-2;
+ padding-top: $space-2;
+ border-top: 1px solid $border-subtle;
}
}
@media (max-width: $breakpoint-md) {
.new-service-page {
- &__header {
- display: grid;
- }
-
- &__method-grid,
- &__provider-grid,
- &__repo-preview,
- &__repo-search,
- &__template-row,
+ &__inline-fields,
+ &__fields-grid,
&__manifest-grid,
- &__two-col {
+ &__repo-search {
grid-template-columns: 1fr;
}
@@ -1121,22 +892,11 @@
}
}
- &__flow {
- grid-template-columns: 1fr;
-
- > svg {
- justify-self: center;
- transform: rotate(90deg);
- }
- }
-
- &__actions {
- flex-direction: column-reverse;
-
+ &__footer {
.btn,
button,
a {
- width: 100%;
+ flex: 1;
}
}
}