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.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
refactor(ui): move the last hand-rolled list and modals onto the shared parts
Juan Denis5cd411b20a3a
diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsxindex dd10c135..ed1630e5 100644--- a/frontend/src/pages/Servers.jsx+++ b/frontend/src/pages/Servers.jsx@@ -919,23 +919,22 @@ const AddServerModal = ({ groups, onClose, onCreated }) => {Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registrationData.registration_token}"` : '';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal server-setup-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <div>- <h2>{step === 1 ? (mode === 'link' ? 'Link to Master Panel' : 'Add Server') : (mode === 'pair' ? 'Pair Agent' : 'Connect Agent')}</h2>- <p>- {step === 1 && mode === 'link'- ? 'Make THIS server manageable by another ServerKit panel — no agent install needed.'- : step === 2 && mode !== 'pair'- ? 'Paste the connection string into the agent, or run the one-liner installer.'- : step === 2- ? 'Enter the 6-char code shown on the agent and your passphrase.'- : 'Connect an existing agent or set up a brand-new machine.'}- </p>- </div>- <button type="button" className="modal-close" onClick={onClose}>×</button>- </div>+ <Modal+ open+ onClose={onClose}+ size="lg"+ className="server-setup-modal"+ title={step === 1 ? (mode === 'link' ? 'Link to Master Panel' : 'Add Server') : (mode === 'pair' ? 'Pair Agent' : 'Connect Agent')}+ >+ <p className="sk-modal__subtitle">+ {step === 1 && mode === 'link'+ ? 'Make THIS server manageable by another ServerKit panel — no agent install needed.'+ : step === 2 && mode !== 'pair'+ ? 'Paste the connection string into the agent, or run the one-liner installer.'+ : step === 2+ ? 'Enter the 6-char code shown on the agent and your passphrase.'+ : 'Connect an existing agent or set up a brand-new machine.'}+ </p>{step === 1 && (<div className="mode-switcher">@@ -1073,8 +1072,7 @@ Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registratio</div></div>)}- </div>- </div>+ </Modal>);};diff --git a/frontend/src/pages/Templates.jsx b/frontend/src/pages/Templates.jsxindex 59485fd7..4607e537 100644--- a/frontend/src/pages/Templates.jsx+++ b/frontend/src/pages/Templates.jsx@@ -9,6 +9,7 @@ import {} from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import Modal from '@/components/Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Badge } from '@/components/ui/badge';@@ -688,21 +689,39 @@ const Templates = () => {{/* Template Detail Modal */}{selectedTemplate && !showInstallModal && (- <div className="modal-overlay" onClick={() => { setSelectedTemplate(null); setRepoManifest(null); }}>- <div className="modal template-detail-drawer" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <div className="template-detail-header">- <div className="template-icon-large">- {renderIcon(selectedTemplate, 40)}- </div>- <div>- <h2>{selectedTemplate.name}</h2>- <span className="template-version">Version {selectedTemplate.version}</span>- </div>- </div>- <button type="button" className="modal-close" onClick={() => { setSelectedTemplate(null); setRepoManifest(null); }}>×</button>- </div>- <div className="modal-body">+ <Modal+ open+ onClose={() => { setSelectedTemplate(null); setRepoManifest(null); }}+ size="lg"+ className="template-detail-drawer"+ title={(+ <span className="template-detail-header">+ <span className="template-icon-large">+ {renderIcon(selectedTemplate, 40)}+ </span>+ <span>+ {selectedTemplate.name}+ <span className="template-version">Version {selectedTemplate.version}</span>+ </span>+ </span>+ )}+ footer={(+ <>+ <Button variant="outline" onClick={() => { setSelectedTemplate(null); setRepoManifest(null); }}>+ Close+ </Button>+ {selectedTemplate.kind === 'repo' ? (+ <Button onClick={() => deployRepoTemplate(selectedTemplate.id)}>+ <Rocket size={14} /> Deploy+ </Button>+ ) : (+ <Button onClick={() => setShowInstallModal(true)}>+ Install Template+ </Button>+ )}+ </>+ )}+ ><p className="template-full-description">{selectedTemplate.description}</p><div className="template-links">@@ -829,23 +848,7 @@ const Templates = () => {)}</div>)}- </div>- <div className="modal-footer">- <Button variant="outline" onClick={() => { setSelectedTemplate(null); setRepoManifest(null); }}>- Close- </Button>- {selectedTemplate.kind === 'repo' ? (- <Button onClick={() => deployRepoTemplate(selectedTemplate.id)}>- <Rocket size={14} /> Deploy- </Button>- ) : (- <Button onClick={() => setShowInstallModal(true)}>- Install Template- </Button>- )}- </div>- </div>- </div>+ </Modal>)}{/* Install Modal (compose templates only) */}diff --git a/frontend/src/pages/Workspaces.jsx b/frontend/src/pages/Workspaces.jsxindex 937a5883..b96532b2 100644--- a/frontend/src/pages/Workspaces.jsx+++ b/frontend/src/pages/Workspaces.jsx@@ -2,10 +2,10 @@ import { useState, useEffect, useCallback } from 'react';import { useNavigate } from 'react-router-dom';import api from '../services/api';import { useToast } from '../contexts/ToastContext';-import EmptyState from '../components/EmptyState';import Modal from '@/components/Modal';-import { LayoutGrid, Plus, ChevronRight, Search } from 'lucide-react';-import { Pill, SegControl, ServiceTile } from '@/components/ds';+import ResourceListPage from '../components/layouts/ResourceListPage';+import { LayoutGrid, Plus, ChevronRight } from 'lucide-react';+import { Pill, ServiceTile } from '@/components/ds';import { useTopbarActions } from '@/hooks/useTopbarActions';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';@@ -69,8 +69,6 @@ const Workspaces = () => {}};- if (loading) return <div className="sk-tabgroup__inner workspaces-page"><EmptyState loading loadingVariant="cards" title="Loading workspaces" /></div>;-const q = search.trim().toLowerCase();const shownWorkspaces = workspaces.filter(ws => {const matchesStatus = statusFilter === 'all'@@ -82,144 +80,118 @@ const Workspaces = () => {const activeCount = workspaces.filter(ws => ws.status === 'active').length;- return (- <div className="sk-tabgroup__inner workspaces-page">- {workspaces.length === 0 ? (- <EmptyState- icon={LayoutGrid}- title="No workspaces yet"- description="Create one to isolate servers by team or project."- action={- <Button onClick={() => setShowCreateModal(true)}>- New Workspace- </Button>- }+ // DataTable columns. Interactive cells stop click propagation so they don't+ // trigger the row's navigate.+ const columns = [+ {+ key: '__select',+ className: 'wp-list__ck',+ cellClassName: 'wp-list__ck',+ header: (+ <Checkbox+ checked={shownWorkspaces.length > 0 && shownWorkspaces.every(ws => selectedIds.has(ws.id))}+ onCheckedChange={(checked) => {+ setSelectedIds(checked ? new Set(shownWorkspaces.map(ws => ws.id)) : new Set());+ }}+ aria-label="Select all workspaces"/>- ) : (- <div className="wp-list">- <div className="wp-list__toolbar">- <SegControl- value={statusFilter}- onChange={setStatusFilter}- options={[- { value: 'all', label: 'All', count: workspaces.length },- { value: 'active', label: 'Active', count: activeCount },- { value: 'inactive', label: 'Inactive', count: workspaces.length - activeCount },- ]}+ ),+ render: (ws) => (+ <div onClick={e => e.stopPropagation()}>+ <Checkbox+ checked={selectedIds.has(ws.id)}+ onCheckedChange={(checked) => {+ setSelectedIds(prev => {+ const next = new Set(prev);+ if (checked) next.add(ws.id);+ else next.delete(ws.id);+ return next;+ });+ }}+ aria-label={`Select ${ws.name || `workspace ${ws.id}`}`}+ />+ </div>+ ),+ },+ {+ key: 'name',+ header: 'Workspace',+ render: (ws) => {+ const since = formatSince(ws.created_at);+ return (+ <div className="sk-cell-name">+ <ServiceTile+ name={ws.name}+ size={30}+ gradient={ws.primary_color || undefined}+ className="wp-list__tile"+ aria-hidden="true"/>- <div className="wp-list__search">- <Search size={15} aria-hidden="true" />- <input- type="text"- value={search}- onChange={e => setSearch(e.target.value)}- placeholder="Search workspaces…"- aria-label="Search workspaces"- />- </div>+ <span>+ <div>{ws.name}</div>+ {ws.description && <div className="sk-cell-sub">{ws.description}</div>}+ {since && !ws.description && <div className="sk-cell-sub">since {since}</div>}+ </span></div>+ );+ },+ },+ { key: 'slug', header: 'Slug', cellClassName: 'sk-cell-mono', render: (ws) => `/${ws.slug}` },+ { key: 'members', header: 'Members', cellClassName: 'sk-cell-mono', render: (ws) => ws.member_count ?? 0 },+ { key: 'servers', header: 'Servers', cellClassName: 'sk-cell-mono', render: (ws) => (ws.max_servers > 0 ? ws.max_servers : '—') },+ { key: 'users', header: 'Users', cellClassName: 'sk-cell-mono', render: (ws) => (ws.max_users > 0 ? ws.max_users : '—') },+ {+ key: 'status',+ header: 'Status',+ render: (ws) => (+ activeId === String(ws.id)+ ? <Pill kind="green">active</Pill>+ : <Pill kind={ws.status === 'active' ? 'green' : 'amber'}>{ws.status || 'unknown'}</Pill>+ ),+ },+ {+ key: '__chev',+ header: '',+ className: 'wp-list__action',+ render: () => <ChevronRight size={16} className="wp-list__chev" />,+ },+ ];- {selectedIds.size > 0 && (- <div className="wp-list__bulkbar">- <span className="wp-list__bulkcount">{selectedIds.size} selected</span>- <div className="wp-list__bulkactions">- <Button variant="ghost" size="sm" onClick={() => setSelectedIds(new Set())}>- Clear- </Button>- </div>- </div>- )}-- <div className="wp-list__card">- <table className="sk-dtable">- <thead>- <tr>- <th className="wp-list__ck">- <Checkbox- checked={shownWorkspaces.length > 0 && shownWorkspaces.every(ws => selectedIds.has(ws.id))}- onCheckedChange={(checked) => {- setSelectedIds(checked ? new Set(shownWorkspaces.map(ws => ws.id)) : new Set());- }}- aria-label="Select all workspaces"- />- </th>- <th>Workspace</th>- <th>Slug</th>- <th>Members</th>- <th>Servers</th>- <th>Users</th>- <th>Status</th>- <th className="wp-list__action" />- </tr>- </thead>- <tbody>- {shownWorkspaces.map(ws => {- const since = formatSince(ws.created_at);- const isCurrent = activeId === String(ws.id);- return (- <tr- key={ws.id}- className={`is-clickable ${selectedIds.has(ws.id) ? 'is-selected' : ''}`}- onClick={() => navigate(`/workspaces/${ws.id}`)}- >- <td className="wp-list__ck" onClick={e => e.stopPropagation()}>- <Checkbox- checked={selectedIds.has(ws.id)}- onCheckedChange={(checked) => {- setSelectedIds(prev => {- const next = new Set(prev);- if (checked) next.add(ws.id);- else next.delete(ws.id);- return next;- });- }}- aria-label={`Select ${ws.name || `workspace ${ws.id}`}`}- />- </td>- <td>- <div className="sk-cell-name">- <ServiceTile- name={ws.name}- size={30}- gradient={ws.primary_color || undefined}- className="wp-list__tile"- aria-hidden="true"- />- <span>- <div>{ws.name}</div>- {ws.description && (- <div className="sk-cell-sub">{ws.description}</div>- )}- {since && !ws.description && (- <div className="sk-cell-sub">since {since}</div>- )}- </span>- </div>- </td>- <td className="sk-cell-mono">/{ws.slug}</td>- <td className="sk-cell-mono">{ws.member_count ?? 0}</td>- <td className="sk-cell-mono">{ws.max_servers > 0 ? ws.max_servers : '—'}</td>- <td className="sk-cell-mono">{ws.max_users > 0 ? ws.max_users : '—'}</td>- <td>- {isCurrent ? (- <Pill kind="green">active</Pill>- ) : (- <Pill kind={ws.status === 'active' ? 'green' : 'amber'}>- {ws.status || 'unknown'}- </Pill>- )}- </td>- <td>- <ChevronRight size={16} className="wp-list__chev" />- </td>- </tr>- );- })}- </tbody>- </table>- </div>- </div>- )}+ return (+ <ResourceListPage+ className="workspaces-page"+ loading={loading}+ loadingTitle="Loading workspaces"+ totalCount={workspaces.length}+ items={shownWorkspaces}+ columns={columns}+ keyField="id"+ onRowClick={(ws) => navigate(`/workspaces/${ws.id}`)}+ rowClassName={(ws) => (selectedIds.has(ws.id) ? 'is-selected' : '')}+ filters={[+ { value: 'all', label: 'All', count: workspaces.length },+ { value: 'active', label: 'Active', count: activeCount },+ { value: 'inactive', label: 'Inactive', count: workspaces.length - activeCount },+ ]}+ activeFilter={statusFilter}+ onFilterChange={setStatusFilter}+ searchTerm={search}+ onSearchChange={setSearch}+ searchPlaceholder="Search workspaces…"+ selectedCount={selectedIds.size}+ onClearSelection={() => setSelectedIds(new Set())}+ emptyIcon={LayoutGrid}+ emptyTitle="No workspaces yet"+ emptyDescription="Create one to isolate servers by team or project."+ emptyAction={+ <Button onClick={() => setShowCreateModal(true)}>+ New Workspace+ </Button>+ }+ filteredEmptyIcon={LayoutGrid}+ filteredEmptyTitle="No workspaces found"+ filteredEmptyDescription="Try adjusting your search or filter."+ ><Modalopen={showCreateModal}@@ -262,7 +234,7 @@ const Workspaces = () => {<span className="form-hint">Recolors the panel for anyone viewing this workspace. Leave the default for no custom branding.</span></div></Modal>- </div>+ </ResourceListPage>);};diff --git a/frontend/src/styles/components/_ui.scss b/frontend/src/styles/components/_ui.scssindex bb37de72..6a3e7f97 100644--- a/frontend/src/styles/components/_ui.scss+++ b/frontend/src/styles/components/_ui.scss@@ -880,6 +880,15 @@border-bottom: 1px solid $border-subtle;}+// Lead paragraph under a modal title. Lives at the top of the body rather than+// in the header, so the header stays a single title row for every modal.+.sk-modal__subtitle {+ margin: 0 0 $space-4;+ color: $text-tertiary;+ font-size: $font-size-sm;+ line-height: 1.5;+}+.sk-modal__body {flex: 1;min-height: 0;