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): template step is a mini app gallery, not one card

Juan Denis4bc5e1af9af0
diff --git a/frontend/src/pages/new-service/ConnectStep.jsx b/frontend/src/pages/new-service/ConnectStep.jsx
index c9fa904c..14c5ca1f 100644
--- a/frontend/src/pages/new-service/ConnectStep.jsx
+++ b/frontend/src/pages/new-service/ConnectStep.jsx
@@ -1,8 +1,7 @@
import { useState } from 'react';
import { Link } from 'react-router-dom';
import {
- ArrowRight, CheckCircle2, FileArchive, GitBranch, Info,
- Package, RefreshCw, Search, Settings2,
+ FileArchive, GitBranch, Info, Package, RefreshCw, Search, Settings2,
} from 'lucide-react';
import { SiGithub } from 'react-icons/si';
import { Button } from '@/components/ui/button';
@@ -11,8 +10,25 @@ import { Label } from '@/components/ui/label';
import { Badge } from '@/components/ui/badge';
import { SOURCE_NEEDS } from './useNewServiceForm';
-// Templates flagged as featured get a badge in the picker.
-const FEATURED_TEMPLATES = ['agentsite'];
+// Curated ordering for the gallery: these float to the front (in this order),
+// everything else follows alphabetically. `agentsite` is also badged "Featured".
+const FEATURED_ORDER = [
+ 'agentsite', 'wordpress', 'nextcloud', 'grafana', 'portainer',
+ 'uptime-kuma', 'gitea', 'n8n', 'vaultwarden', 'jellyfin',
+];
+const FEATURED_BADGE = ['agentsite'];
+const COLLAPSED_COUNT = 8; // ~two rows of four before "Show all"
+
+function orderTemplates(list) {
+ return [...list].sort((a, b) => {
+ const ai = FEATURED_ORDER.indexOf(a.id);
+ const bi = FEATURED_ORDER.indexOf(b.id);
+ const aw = ai === -1 ? 999 : ai;
+ const bw = bi === -1 ? 999 : bi;
+ if (aw !== bw) return aw - bw;
+ return (a.name || '').localeCompare(b.name || '');
+ });
+}
// Template icon with a graceful fallback to a Package glyph if the inline/URL
// icon is missing or fails to load.
@@ -21,7 +37,76 @@ const TemplateIcon = ({ template }) => {
if (template.icon && !failed) {
return <img src={template.icon} alt="" onError={() => setFailed(true)} />;
}
- return <Package size={22} />;
+ return <Package size={20} />;
+};
+
+// A mini app gallery: icon + title tiles, ~4 across. Collapsed to two rows;
+// "Show all" expands into a scrollable, searchable grid.
+const TemplateGallery = ({ templates, loading, selectedId, onPick }) => {
+ const [expanded, setExpanded] = useState(false);
+ const [query, setQuery] = useState('');
+
+ if (loading) {
+ return <div className="new-service-page__repo-state">Loading templates…</div>;
+ }
+ if (!templates.length) {
+ return <div className="new-service-page__repo-state">No templates available yet.</div>;
+ }
+
+ const q = query.trim().toLowerCase();
+ const filtered = orderTemplates(templates).filter(t => !q
+ || (t.name || '').toLowerCase().includes(q)
+ || (t.description || '').toLowerCase().includes(q)
+ || (t.categories || []).some(c => c.toLowerCase().includes(q)));
+ const visible = expanded ? filtered : filtered.slice(0, COLLAPSED_COUNT);
+ const hiddenCount = filtered.length - visible.length;
+
+ return (
+ <div className="new-service-page__tpl-gallery">
+ {expanded && (
+ <div className="new-service-page__tpl-gallery-search">
+ <Search size={16} />
+ <Input
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder="Search templates…"
+ autoFocus
+ />
+ </div>
+ )}
+ <div className={`new-service-page__tpl-gallery-grid ${expanded ? 'new-service-page__tpl-gallery-grid--scroll' : ''}`}>
+ {visible.map(template => (
+ <button
+ key={template.id}
+ type="button"
+ title={template.description || template.name}
+ className={`new-service-page__tpl-tile ${selectedId === template.id ? 'new-service-page__tpl-tile--active' : ''}`}
+ onClick={() => onPick(template)}
+ >
+ {FEATURED_BADGE.includes(template.id) && (
+ <Badge variant="info" className="new-service-page__tpl-tile-badge">Featured</Badge>
+ )}
+ <span className="new-service-page__tpl-tile-icon">
+ <TemplateIcon template={template} />
+ </span>
+ <span className="new-service-page__tpl-tile-name">{template.name}</span>
+ </button>
+ ))}
+ {visible.length === 0 && (
+ <div className="new-service-page__repo-state">No templates match “{query}”.</div>
+ )}
+ </div>
+ {(hiddenCount > 0 || expanded) && (
+ <button
+ type="button"
+ className="new-service-page__tpl-gallery-toggle"
+ onClick={() => setExpanded(x => !x)}
+ >
+ {expanded ? 'Show less' : `Show all ${filtered.length} templates`}
+ </button>
+ )}
+ </div>
+ );
};
// Step 2 — Connect. Only the source-specific input, plus the editable detected
@@ -30,7 +115,7 @@ const ConnectStep = ({ form }) => {
const {
sourceMode, selectSource, githubConnection, githubConfigured, reposLoading, repos, repoSearch,
setRepoSearch, selectedRepo, setSelectedRepo, loadGithubRepos, handleConnectGithub,
- templates, templatesLoading, selectedTemplate, selectTemplateById,
+ templates, templatesLoading, selectedTemplate, pickTemplate,
manualRepoUrl, handleManualRepoChange, localPath, setLocalPath, composeFile,
setComposeFile, systemdUnit, setSystemdUnit, managedBy, setManagedBy,
uploadFile, onUploadFile, uploadDragOver, setUploadDragOver,
@@ -136,42 +221,12 @@ const ConnectStep = ({ form }) => {
{sourceMode === 'template' && (
<div className="new-service-page__pane">
- {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 => {
- const active = selectedTemplate?.id === template.id;
- return (
- <button
- key={template.id}
- type="button"
- className={`new-service-page__template-card ${active ? 'new-service-page__template-card--active' : ''}`}
- onClick={() => selectTemplateById(template.id)}
- >
- <span className="new-service-page__template-card-icon">
- <TemplateIcon template={template} />
- </span>
- <span className="new-service-page__template-card-body">
- <span className="new-service-page__template-card-head">
- <strong>{template.name}</strong>
- {FEATURED_TEMPLATES.includes(template.id) && (
- <Badge variant="info">Featured</Badge>
- )}
- {template.version && <Badge variant="outline">v{template.version}</Badge>}
- </span>
- <span className="new-service-page__template-card-desc">{template.description}</span>
- <span className="new-service-page__template-card-meta">
- {(template.categories || []).slice(0, 3).map(cat => (
- <span key={cat} className="tg">{cat}</span>
- ))}
- {template.repo?.url && <em>{template.repo.url}</em>}
- </span>
- </span>
- {active ? <CheckCircle2 size={20} /> : <ArrowRight size={20} />}
- </button>
- );
- })}
+ <TemplateGallery
+ templates={templates}
+ loading={templatesLoading}
+ selectedId={selectedTemplate?.id}
+ onPick={pickTemplate}
+ />
{/* Bring your own — no curated entry needed. Any repo with a
serverkit.yml / Docker Compose / Dockerfile deploys the same
@@ -186,11 +241,6 @@ const ConnectStep = ({ form }) => {
Use a repo URL
</Button>
</div>
-
- <Link to="/templates?kind=repo" className="new-service-page__pane-link">
- <Package size={14} />
- Open the full template library
- </Link>
</div>
)}
diff --git a/frontend/src/pages/new-service/useNewServiceForm.js b/frontend/src/pages/new-service/useNewServiceForm.js
index 8587fa3e..d8d2d760 100644
--- a/frontend/src/pages/new-service/useNewServiceForm.js
+++ b/frontend/src/pages/new-service/useNewServiceForm.js
@@ -222,11 +222,13 @@ export function useNewServiceForm() {
}
}, [toast]);
+ // The template gallery shows the FULL catalog (repo + one-click compose), so
+ // the picker feels like a real app gallery rather than a single row.
const loadTemplates = useCallback(async () => {
setTemplatesLoading(true);
try {
const data = await api.listTemplates();
- setTemplates((data.templates || []).filter(t => (t.kind || 'compose') === 'repo'));
+ setTemplates(data.templates || []);
} catch (err) {
setTemplates([]);
} finally {
@@ -409,6 +411,17 @@ export function useNewServiceForm() {
return false;
}, [selectTemplate, toast]);
+ // Pick a template from the gallery. Repo templates continue in the wizard
+ // (they deploy from their Git repo); one-click compose templates route to
+ // their install flow on the Templates page, which is their real deploy path.
+ const pickTemplate = useCallback((template) => {
+ if ((template.kind || 'compose') === 'repo') {
+ selectTemplateById(template.id);
+ } else {
+ navigate(`/templates?install=${encodeURIComponent(template.id)}`);
+ }
+ }, [selectTemplateById, navigate]);
+
function handleManualRepoChange(value) {
setManualRepoUrl(value);
if (!nameTouched) setName(repoNameFromUrl(normalizeManualRepo(value)));
@@ -543,7 +556,7 @@ export function useNewServiceForm() {
repos, reposLoading, repoSearch, setRepoSearch, selectedRepo, setSelectedRepo,
loadGithubRepos, handleConnectGithub, branches, branchesLoading,
// templates
- templates, templatesLoading, selectedTemplate, selectTemplate, selectTemplateById,
+ templates, templatesLoading, selectedTemplate, selectTemplate, selectTemplateById, pickTemplate,
// manual / local / upload
manualRepoUrl, handleManualRepoChange, normalizedManualRepo,
localPath, setLocalPath, composeFile, setComposeFile,
diff --git a/frontend/src/styles/pages/_new-service.scss b/frontend/src/styles/pages/_new-service.scss
index e2a6a65d..0ad57533 100644
--- a/frontend/src/styles/pages/_new-service.scss
+++ b/frontend/src/styles/pages/_new-service.scss
@@ -460,43 +460,74 @@
}
}
- // Richer featured template card (icon + name + preview + categories).
- &__template-card {
+ // Mini app gallery: icon + title tiles, ~4 across. Collapsed to two rows;
+ // expands into a scrollable, searchable grid.
+ &__tpl-gallery {
display: grid;
- grid-template-columns: auto minmax(0, 1fr) auto;
+ gap: $space-3;
+ }
+
+ &__tpl-gallery-search {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr);
align-items: center;
- gap: $space-4;
- width: 100%;
- padding: $space-4;
+ gap: $space-2;
+ padding: $space-2;
background: $bg-elevated;
border: 1px solid $border-subtle;
- border-radius: $radius-lg;
+ border-radius: $radius-md;
+
+ > svg {
+ margin-left: $space-2;
+ color: $text-tertiary;
+ }
+ }
+
+ &__tpl-gallery-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
+ gap: $space-3;
+
+ &--scroll {
+ max-height: 440px;
+ overflow-y: auto;
+ padding-right: $space-1;
+ }
+ }
+
+ &__tpl-tile {
+ position: relative;
+ display: grid;
+ place-items: center;
+ gap: $space-2;
+ min-height: 120px;
+ padding: $space-4 $space-3;
+ background: $bg-elevated;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
color: $text-primary;
font: inherit;
- text-align: left;
+ text-align: center;
cursor: pointer;
transition: border-color $transition-fast, background $transition-fast, transform $transition-fast;
&:hover {
background: $bg-hover;
border-color: $border-hover;
- transform: translateY(-1px);
+ transform: translateY(-2px);
}
&--active {
border-color: rgba(20, 184, 166, 0.55);
box-shadow: inset 0 0 0 1px rgba(20, 184, 166, 0.18);
-
- > svg { color: $success; }
}
}
- &__template-card-icon {
+ &__tpl-tile-icon {
display: grid;
place-items: center;
- width: 48px;
- height: 48px;
- flex-shrink: 0;
+ width: 44px;
+ height: 44px;
border-radius: $radius-lg;
background: var(--surface-2);
color: var(--accent-bright);
@@ -512,55 +543,33 @@
svg { display: block; }
}
- &__template-card-body {
- display: grid;
- gap: 4px;
- min-width: 0;
+ &__tpl-tile-name {
+ max-width: 100%;
+ color: $text-primary;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-medium;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
- &__template-card-head {
- display: flex;
- align-items: center;
- gap: $space-2;
-
- strong {
- color: $text-primary;
- font-size: $font-size-base;
- font-weight: $font-weight-semibold;
- }
+ &__tpl-tile-badge {
+ position: absolute;
+ top: $space-2;
+ right: $space-2;
}
- &__template-card-desc {
- color: $text-tertiary;
+ &__tpl-gallery-toggle {
+ justify-self: start;
+ padding: $space-2 0;
+ background: none;
+ border: none;
+ color: $accent-primary;
font-size: $font-size-sm;
- line-height: 1.4;
- overflow-wrap: anywhere;
- }
-
- &__template-card-meta {
- display: flex;
- align-items: center;
- gap: $space-2;
- flex-wrap: wrap;
- margin-top: 2px;
-
- .tg {
- padding: 1px 7px;
- border-radius: $radius-sm;
- background: var(--surface-2);
- color: var(--text-dim);
- font-size: 10.5px;
- font-family: $font-mono;
- text-transform: capitalize;
- }
+ font-weight: $font-weight-medium;
+ cursor: pointer;
- em {
- color: var(--text-faint);
- font-size: $font-size-xs;
- font-family: $font-mono;
- font-style: normal;
- overflow-wrap: anywhere;
- }
+ &:hover { text-decoration: underline; }
}
// "Bring your own" — deploy any repo with a serverkit.yml / compose file.