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
feat(ui): Projects, Vaults and Shared Variables are tables like everything else
Juan Denis449c849b277c
diff --git a/frontend/src/components/ds/DataTableFooter.jsx b/frontend/src/components/ds/DataTableFooter.jsxindex 0359f83f..efff6f61 100644--- a/frontend/src/components/ds/DataTableFooter.jsx+++ b/frontend/src/components/ds/DataTableFooter.jsx@@ -42,11 +42,18 @@ export function DataTableFooter({const paged = page != null && totalPages != null && onPageChange;+ // "25 · 50 · 100 · All" over three rows is a control with nothing to+ // control — every option shows the same three rows. Offer it only once the+ // table is longer than the smallest page it could cut to (or when a page+ // size is already pinned, so the way back to All never disappears).+ const smallestPage = Math.min(...pageSizeOptions);+ const worthPaging = (total ?? shown) > smallestPage || (pageSize != null && pageSize !== 'all');+return (<div className={cn('sk-dtable-footer', className)}><span className="sk-dtable-footer__count">{label}</span><div className="sk-dtable-footer__controls">- {onPageSizeChange && (+ {onPageSizeChange && worthPaging && (<SegControlclassName="sk-dtable-footer__sizes"value={String(pageSize)}diff --git a/frontend/src/components/shared/SharedVariableGroups.jsx b/frontend/src/components/shared/SharedVariableGroups.jsxindex b387dfd6..d868a23b 100644--- a/frontend/src/components/shared/SharedVariableGroups.jsx+++ b/frontend/src/components/shared/SharedVariableGroups.jsx@@ -1,16 +1,44 @@-import { useState, useEffect, useCallback } from 'react';+import { useState, useEffect, useCallback, useMemo } from 'react';+import { ArrowLeft, Boxes, Plus, Trash2 } from 'lucide-react';import api from '../../services/api';import { useToast } from '../../contexts/ToastContext';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';import { Checkbox } from '@/components/ui/checkbox';+import Modal from '@/components/Modal';+import ResourceListPage from '../layouts/ResourceListPage';+import { useTopbarActions } from '@/hooks/useTopbarActions';+import { SearchField, Pill, ServiceTile } from '@/components/ds';const RESOURCE_TYPES = ['application', 'database', 'service', 'wordpress', 'server'];+// Preset views. "Unattached" is the one that earns its place: a group nothing+// is attached to is a group whose variables reach nothing, which is almost+// always a mistake rather than a choice.+const GROUP_VIEWS = [+ { name: 'All groups', state: { search: '', sorts: [], hiddenKeys: [], columnFilters: null } },+ {+ name: 'Unattached',+ state: {+ search: '',+ sorts: [],+ hiddenKeys: [],+ columnFilters: { match: 'all', rules: [{ id: 'sg1', field: 'attachments', op: 'eq', value: 0 }] },+ },+ },+];+/*** Manage shared variable groups for a given scope: create groups, add/remove* variables (secrets masked), and attach/detach a group to resources.*+ * Two depths on the same surface, matching every other list page: a table of+ * groups, and — once you pick one — a table of that group's variables. It used+ * to be a fixed sidebar of groups beside a detail pane, which meant the group+ * list alone could not be searched, sorted, filtered or saved as a view the way+ * every other list in the panel can.+ ** Props:* scopeType 'workspace' | 'project' | 'environment' (default 'workspace')* scopeId the scope identifier (string) (default 'default')@@ -23,8 +51,10 @@ const SharedVariableGroups = ({ scopeType = 'workspace', scopeId = 'default' })const [detail, setDetail] = useState(null);// create-group form+ const [creating, setCreating] = useState(false);const [newName, setNewName] = useState('');const [newDescription, setNewDescription] = useState('');+ const [search, setSearch] = useState('');// add-variable formconst [varKey, setVarKey] = useState('');@@ -72,6 +102,7 @@ const SharedVariableGroups = ({ scopeType = 'workspace', scopeId = 'default' })toast.success('Group created');setNewName('');setNewDescription('');+ setCreating(false);await loadGroups();setSelectedId(group.id);} catch (err) {@@ -144,59 +175,251 @@ const SharedVariableGroups = ({ scopeType = 'workspace', scopeId = 'default' })}}- return (- <div className="shared-groups">- <div className="shared-groups__layout">- {/* Group list + create */}- <aside className="shared-groups__sidebar">- <form className="shared-groups__create" onSubmit={handleCreateGroup}>- <Input- type="text"- value={newName}- onChange={(e) => setNewName(e.target.value)}- placeholder="New group name"- />- <Input- type="text"- value={newDescription}- onChange={(e) => setNewDescription(e.target.value)}- placeholder="Description (optional)"- />- <Button type="submit" size="sm" disabled={!newName.trim()}>- Create group- </Button>- </form>+ // The top bar follows the depth, like Vaults: create groups at the list,+ // go back and manage one inside it.+ useTopbarActions(() => (detail ? (+ <>+ <Button variant="outline" size="sm" onClick={() => setSelectedId(null)}>+ <ArrowLeft size={15} /> All groups+ </Button>+ <SearchField value={search} onSearch={setSearch} placeholder="Search variables…" />+ </>+ ) : (+ <>+ <Button size="sm" onClick={() => setCreating(true)}>+ <Plus size={15} /> New group+ </Button>+ <SearchField value={search} onSearch={setSearch} placeholder="Search groups…" />+ </>+ )), [detail, search]);- <ul className="shared-groups__list">- {loading ? (- <li className="shared-groups__hint">Loading…</li>- ) : groups.length === 0 ? (- <li className="shared-groups__hint">No groups in this scope yet</li>- ) : (- groups.map((g) => (- <li- key={g.id}- className={`shared-groups__item ${selectedId === g.id ? 'is-active' : ''}`}- onClick={() => setSelectedId(g.id)}- >- <div className="shared-groups__item-name">{g.name}</div>- <div className="shared-groups__item-meta">- {g.variable_count} vars · {g.attachment_count} attached- </div>- </li>- ))- )}- </ul>- </aside>+ // A term that matched a group name is not a variable key; clear on depth change.+ useEffect(() => { setSearch(''); }, [selectedId]);++ const groupRows = useMemo(() => {+ const q = search.trim().toLowerCase();+ if (!q) return groups;+ return groups.filter((g) => (+ g.name?.toLowerCase().includes(q) || g.description?.toLowerCase().includes(q)+ ));+ }, [groups, search]);- {/* Detail */}- <section className="shared-groups__detail">- {!detail ? (- <div className="shared-groups__empty">- Select a group to manage its variables and attachments.+ const variableRows = useMemo(() => {+ const all = detail?.variables || [];+ const q = search.trim().toLowerCase();+ if (!q) return all;+ return all.filter((v) => (+ v.key?.toLowerCase().includes(q) || v.target_service?.toLowerCase().includes(q)+ ));+ }, [detail, search]);++ const groupColumns = useMemo(() => [+ {+ key: 'name',+ header: 'Group',+ sortable: true,+ hideable: false,+ value: (g) => g.name,+ render: (g) => (+ <div className="sk-cell-name">+ <ServiceTile name={g.name} size={30} className="wp-list__tile" aria-hidden="true" />+ <span>{g.name}</span>+ </div>+ ),+ },+ {+ key: 'description',+ header: 'Description',+ sortable: true,+ value: (g) => g.description || '',+ render: (g) => g.description || <span className="wp-list__dash">—</span>,+ },+ // `value` sorts and filters; `render` is what the cell shows —+ // DataTable falls back to row[key], and these counts have no such key.+ {+ key: 'variables',+ header: 'Variables',+ type: 'number',+ sortable: true,+ width: 110,+ cellClassName: 'sk-cell-mono',+ value: (g) => g.variable_count ?? 0,+ render: (g) => g.variable_count ?? 0,+ },+ {+ key: 'attachments',+ header: 'Attached',+ type: 'number',+ sortable: true,+ width: 110,+ cellClassName: 'sk-cell-mono',+ value: (g) => g.attachment_count ?? 0,+ render: (g) => g.attachment_count ?? 0,+ },+ {+ key: '__actions',+ header: '',+ sortable: false,+ hideable: false,+ width: 56,+ className: 'text-right',+ render: (g) => (+ <Button+ variant="ghost"+ size="icon"+ className="text-destructive"+ title="Delete group"+ onClick={(e) => { e.stopPropagation(); handleDeleteGroup(g.id); }}+ >+ <Trash2 size={14} />+ </Button>+ ),+ },+ // eslint-disable-next-line react-hooks/exhaustive-deps+ ], []);++ const variableColumns = useMemo(() => [+ {+ key: 'key',+ header: 'Key',+ sortable: true,+ hideable: false,+ value: (v) => v.key,+ cellClassName: 'sk-cell-mono',+ render: (v) => (+ <span className="shared-vars-table__key">+ {v.key}+ {v.is_secret && <Pill kind="amber" dot={false}>secret</Pill>}+ </span>+ ),+ },+ {+ key: 'value',+ header: 'Value',+ sortable: false,+ filterable: false,+ cellClassName: 'sk-cell-mono',+ render: (v) => <span className="shared-vars-table__value">{v.value}</span>,+ },+ {+ key: 'target',+ header: 'Target service',+ sortable: true,+ // A blank target is not missing data — it means every service in the+ // stack, which is a different statement from "unknown".+ value: (v) => v.target_service || '',+ render: (v) => (v.target_service ? (+ <span className="env-target-chip" title={`Applies only to the "${v.target_service}" service`}>+ → {v.target_service}+ </span>+ ) : (+ <span className="shared-vars-table__target-all">all services</span>+ )),+ },+ {+ key: '__actions',+ header: '',+ sortable: false,+ hideable: false,+ width: 56,+ className: 'text-right',+ render: (v) => (+ <Button+ variant="ghost"+ size="icon"+ className="text-destructive"+ title="Delete variable"+ aria-label={`Delete variable ${v.key}`}+ onClick={(e) => { e.stopPropagation(); handleDeleteVariable(v.id); }}+ >+ <Trash2 size={14} />+ </Button>+ ),+ },+ // eslint-disable-next-line react-hooks/exhaustive-deps+ ], []);++ if (!detail) {+ return (+ <>+ <ResourceListPage+ className="shared-groups"+ loading={loading}+ loadingTitle="Loading variable groups…"+ storageKey="serverkit-list-variable-groups"+ viewPageKey="variable-groups"+ noun="groups"+ builtinViews={GROUP_VIEWS}+ totalCount={groups.length}+ items={groupRows}+ columns={groupColumns}+ keyField="id"+ onRowClick={(g) => setSelectedId(g.id)}+ emptyIcon={Boxes}+ emptyTitle="No variable groups yet"+ emptyDescription="A group is a set of variables you attach to services, databases or servers at once, instead of copying the same values into each."+ emptyAction={<Button onClick={() => setCreating(true)}><Plus size={16} /> Create your first group</Button>}+ filteredEmptyIcon={Boxes}+ filteredEmptyTitle="No groups found"+ filteredEmptyDescription="Try adjusting your search or filters."+ />++ <Modal open={creating} onClose={() => setCreating(false)} title="New variable group">+ <form onSubmit={handleCreateGroup}>+ <p className="sk-modal__subtitle">+ Variables in this group apply to every resource you attach it to.+ </p>+ <div className="projects-form">+ <div className="projects-form__field">+ <Label htmlFor="vg-name">Name</Label>+ <Input+ id="vg-name"+ autoFocus+ value={newName}+ onChange={(e) => setNewName(e.target.value)}+ placeholder="e.g. shared-database"+ required+ />+ </div>+ <div className="projects-form__field">+ <Label htmlFor="vg-desc">Description (optional)</Label>+ <Input+ id="vg-desc"+ value={newDescription}+ onChange={(e) => setNewDescription(e.target.value)}+ placeholder="What this group is for…"+ />+ </div>+ </div>+ <div className="modal-actions">+ <Button type="button" variant="outline" onClick={() => setCreating(false)}>Cancel</Button>+ <Button type="submit" disabled={!newName.trim()}>Create group</Button></div>- ) : (- <>+ </form>+ </Modal>+ </>+ );+ }++ return (+ <ResourceListPage+ className="shared-groups"+ loading={false}+ storageKey="serverkit-list-group-variables"+ viewPageKey="group-variables"+ noun="variables"+ totalCount={(detail.variables || []).length}+ items={variableRows}+ columns={variableColumns}+ keyField="id"+ emptyIcon={Boxes}+ emptyTitle={`No variables in ${detail.name}`}+ emptyDescription="Add the first key/value pair below — it reaches every resource this group is attached to."+ filteredEmptyIcon={Boxes}+ filteredEmptyTitle="No variables found"+ filteredEmptyDescription="Try adjusting your search or filters."+ >+ <div className="shared-groups__detail"><div className="shared-groups__detail-header"><div><h3>{detail.name}</h3>@@ -213,54 +436,6 @@ const SharedVariableGroups = ({ scopeType = 'workspace', scopeId = 'default' })</Button></div>- {/* Variables */}- <h4 className="shared-groups__subhead">Variables</h4>- {(detail.variables || []).length === 0 ? (- <p className="shared-groups__hint">No variables yet.</p>- ) : (- <table className="shared-vars-table">- <thead>- <tr>- <th>Key</th>- <th>Value</th>- <th>Target service</th>- <th></th>- </tr>- </thead>- <tbody>- {detail.variables.map((v) => (- <tr key={v.id} className={v.is_secret ? 'is-secret' : ''}>- <td className="shared-vars-table__key">{v.key}</td>- <td className="shared-vars-table__value">{v.value}</td>- <td className="shared-vars-table__target">- {v.target_service ? (- <span- className="env-target-chip"- title={`Applies only to the "${v.target_service}" service`}- >- → {v.target_service}- </span>- ) : (- <span className="shared-vars-table__target-all">all services</span>- )}- </td>- <td>- <button- type="button"- className="shared-tag__remove"- onClick={() => handleDeleteVariable(v.id)}- title="Delete variable"- aria-label={`Delete variable ${v.key}`}- >- ×- </button>- </td>- </tr>- ))}- </tbody>- </table>- )}-<form className="shared-groups__add-var" onSubmit={handleAddVariable}><Inputtype="text"@@ -339,11 +514,8 @@ const SharedVariableGroups = ({ scopeType = 'workspace', scopeId = 'default' })Attach</Button></form>- </>- )}- </section></div>- </div>+ </ResourceListPage>);};diff --git a/frontend/src/pages/Projects.jsx b/frontend/src/pages/Projects.jsxindex ecf19962..ff7f102a 100644--- a/frontend/src/pages/Projects.jsx+++ b/frontend/src/pages/Projects.jsx@@ -1,24 +1,61 @@-import { useState, useEffect, useCallback } from 'react';-import { Link } from 'react-router-dom';-import { FolderKanban, Plus, Layers, Boxes } from 'lucide-react';+import { useState, useEffect, useCallback, useMemo } from 'react';+import { useNavigate } from 'react-router-dom';+import { FolderKanban, Plus } from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';-import EmptyState from '../components/EmptyState';+import ResourceListPage from '../components/layouts/ResourceListPage';import { useTopbarActions } from '@/hooks/useTopbarActions';import useFocusParam from '@/hooks/useFocusParam';+import { SearchField, ServiceTile } from '@/components/ds';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Textarea } from '@/components/ui/textarea';import Modal from '@/components/Modal';+// Preset views. A project list is short, so these are about SHAPE rather than+// status: which projects are actually carrying anything, and which are empty+// shells someone made and forgot.+const PROJECT_VIEWS = [+ {+ name: 'All projects',+ state: { search: '', sorts: [], hiddenKeys: [], columnFilters: null },+ },+ {+ name: 'Has services',+ state: {+ search: '',+ sorts: [{ key: 'apps', direction: 'desc' }],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'pv1', field: 'apps', op: 'gt', value: 0 }],+ },+ },+ },+ {+ name: 'Empty',+ state: {+ search: '',+ sorts: [],+ hiddenKeys: [],+ columnFilters: {+ match: 'all',+ rules: [{ id: 'pv2', field: 'apps', op: 'eq', value: 0 }],+ },+ },+ },+];+const Projects = () => {const [projects, setProjects] = useState([]);const [loading, setLoading] = useState(true);const [showCreate, setShowCreate] = useState(false);+ const [search, setSearch] = useState('');// Quick-create deep link: /projects?focus=create:project opens the dialog.useFocusParam('create', () => setShowCreate(true));const toast = useToast();+ const navigate = useNavigate();const loadProjects = useCallback(async () => {setLoading(true);@@ -38,36 +75,99 @@ const Projects = () => {}, [loadProjects]);useTopbarActions(() => (- <Button onClick={() => setShowCreate(true)}>- <Plus size={16} /> New Project- </Button>- ), []);+ <>+ <Button size="sm" onClick={() => setShowCreate(true)}>+ <Plus size={16} /> New Project+ </Button>+ <SearchField value={search} onSearch={setSearch} placeholder="Search projects…" />+ </>+ ), [search]);- return (- <div className="sk-tabgroup__inner projects-page">- <div className="projects-page__body">- {loading ? (- <EmptyState loading loadingVariant="cards" title="Loading projects" />- ) : projects.length === 0 ? (- <EmptyState- icon={FolderKanban}- title="No projects yet"- description="Group your applications into projects and environments (production, staging, development) to keep things organized."- action={- <Button onClick={() => setShowCreate(true)}>- <Plus size={16} /> Create your first project- </Button>- }- />- ) : (- <div className="projects-grid">- {projects.map(project => (- <ProjectCard key={project.id} project={project} />- ))}- </div>- )}- </div>+ const rows = useMemo(() => {+ const q = search.trim().toLowerCase();+ if (!q) return projects;+ return projects.filter((p) => (+ p.name?.toLowerCase().includes(q)+ || p.slug?.toLowerCase().includes(q)+ || p.description?.toLowerCase().includes(q)+ ));+ }, [projects, search]);+ const columns = useMemo(() => [+ {+ key: 'name',+ header: 'Project',+ sortable: true,+ hideable: false,+ value: (p) => p.name,+ render: (p) => (+ <div className="sk-cell-name">+ <ServiceTile name={p.name} size={30} className="wp-list__tile" aria-hidden="true" />+ <span>+ <div>{p.name}</div>+ <div className="sk-cell-sub">{p.slug}</div>+ </span>+ </div>+ ),+ },+ {+ key: 'description',+ header: 'Description',+ sortable: true,+ value: (p) => p.description || '',+ render: (p) => p.description || <span className="wp-list__dash">—</span>,+ },+ // `value` feeds sorting and the filter rules; `render` is what the cell+ // shows. DataTable falls back to row[key] when there is no render, and+ // these are derived counts with no matching key on the row — so both.+ {+ key: 'environments',+ header: 'Environments',+ type: 'number',+ sortable: true,+ width: 140,+ cellClassName: 'sk-cell-mono',+ value: (p) => p.environment_count ?? 0,+ render: (p) => p.environment_count ?? 0,+ },+ {+ key: 'apps',+ header: 'Services',+ type: 'number',+ sortable: true,+ width: 120,+ cellClassName: 'sk-cell-mono',+ value: (p) => p.app_count ?? 0,+ render: (p) => p.app_count ?? 0,+ },+ ], []);++ return (+ <ResourceListPage+ className="projects-page"+ loading={loading}+ loadingTitle="Loading projects…"+ storageKey="serverkit-list-projects"+ viewPageKey="projects"+ noun="projects"+ builtinViews={PROJECT_VIEWS}+ totalCount={projects.length}+ items={rows}+ columns={columns}+ keyField="id"+ onRowClick={(p) => navigate(`/projects/${p.id}`)}+ emptyIcon={FolderKanban}+ emptyTitle="No projects yet"+ emptyDescription="Group your applications into projects and environments (production, staging, development) to keep things organized."+ emptyAction={(+ <Button onClick={() => setShowCreate(true)}>+ <Plus size={16} /> Create your first project+ </Button>+ )}+ filteredEmptyIcon={FolderKanban}+ filteredEmptyTitle="No projects found"+ filteredEmptyDescription="Try adjusting your search or filters."+ ><CreateProjectDialogopen={showCreate}onOpenChange={setShowCreate}@@ -76,38 +176,7 @@ const Projects = () => {loadProjects();}}/>- </div>- );-};--const ProjectCard = ({ project }) => {- const envCount = project.environment_count ?? 0;- const appCount = project.app_count ?? 0;- return (- <Link to={`/projects/${project.id}`} className="project-card">- <div className="project-card__header">- <span className="project-card__icon" aria-hidden="true">- <FolderKanban size={18} />- </span>- <div className="project-card__titles">- <h3 className="project-card__name">{project.name}</h3>- <span className="project-card__slug">{project.slug}</span>- </div>- </div>- {project.description && (- <p className="project-card__description">{project.description}</p>- )}- <div className="project-card__stats">- <span className="project-card__stat">- <Layers size={14} />- {envCount} environment{envCount === 1 ? '' : 's'}- </span>- <span className="project-card__stat">- <Boxes size={14} />- {appCount} app{appCount === 1 ? '' : 's'}- </span>- </div>- </Link>+ </ResourceListPage>);};diff --git a/frontend/src/pages/SharedVariables.jsx b/frontend/src/pages/SharedVariables.jsxindex 595e1ae2..84d067c9 100644--- a/frontend/src/pages/SharedVariables.jsx+++ b/frontend/src/pages/SharedVariables.jsx@@ -8,11 +8,10 @@ import SharedVariableGroups from '../components/shared/SharedVariableGroups';const SharedVariables = () => {const workspaceId = localStorage.getItem('active_workspace_id') || 'default';- return (- <div className="sk-tabgroup__inner shared-variables-page">- <SharedVariableGroups scopeType="workspace" scopeId={workspaceId} />- </div>- );+ // No wrapper: SharedVariableGroups renders through ResourceListPage, which+ // supplies the `sk-tabgroup__inner` box itself. Nesting a second one padded+ // the table twice.+ return <SharedVariableGroups scopeType="workspace" scopeId={workspaceId} />;};export default SharedVariables;diff --git a/frontend/src/pages/Vaults.jsx b/frontend/src/pages/Vaults.jsxindex 37f09187..1531a27a 100644--- a/frontend/src/pages/Vaults.jsx+++ b/frontend/src/pages/Vaults.jsx@@ -1,20 +1,37 @@-import { useEffect, useState } from 'react';+import { useEffect, useMemo, useState } from 'react';import api from '../services/api';-import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Textarea } from '@/components/ui/textarea';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';import Modal from '@/components/Modal';-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';import { useToast } from '../contexts/ToastContext';-import { Plus, MoreVertical, Copy, Eye, EyeOff, Trash2 } from 'lucide-react';-import EmptyState from '../components/EmptyState';+import { ArrowLeft, Plus, MoreVertical, Copy, Eye, EyeOff, KeyRound, Trash2 } from 'lucide-react';+import ResourceListPage from '../components/layouts/ResourceListPage';+import { useTopbarActions } from '@/hooks/useTopbarActions';+import { SearchField, ServiceTile } from '@/components/ds';+import { formatRelativeTime } from '@/utils/time';const formatDate = (d) => (d ? new Date(d).toLocaleString() : '—');+// Two tables, one chrome. The vault list and a vault's secrets are the same+// surface at two depths, so both go through ResourceListPage rather than the+// list being a table and the drill-down being a hand-rolled card.+const VAULT_VIEWS = [+ { name: 'All vaults', state: { search: '', sorts: [], hiddenKeys: [], columnFilters: null } },+ {+ name: 'Empty vaults',+ state: {+ search: '',+ sorts: [],+ hiddenKeys: [],+ columnFilters: { match: 'all', rules: [{ id: 'vv1', field: 'secrets', op: 'eq', value: 0 }] },+ },+ },+];+/*** Vaults — encrypted key/value stores for credentials and tokens. Rendered* inside the Organization tab group (alongside Projects / Shared Variables /@@ -34,6 +51,7 @@ export default function Vaults() {const [secretForm, setSecretForm] = useState({ open: false, name: '', value: '', description: '' });const [revealSecretId, setRevealSecretId] = useState(null);const [revealedValue, setRevealedValue] = useState('');+ const [search, setSearch] = useState('');useEffect(() => {loadAll();@@ -131,127 +149,226 @@ export default function Vaults() {}}- if (loading) {- return (- <div className="sk-tabgroup__inner secrets-page">- <EmptyState loading loadingVariant="table" title="Loading vaults..." />- </div>- );- }+ // The top bar follows the depth: at the list it creates vaults, inside one+ // it goes back and adds secrets. Search is published here too so it lands+ // in the bar next to the filter and "⋮" the table hoists into it.+ useTopbarActions(() => (selectedVault ? (+ <>+ <Button variant="outline" size="sm" onClick={() => setSelectedVault(null)}>+ <ArrowLeft size={15} /> All vaults+ </Button>+ <Button size="sm" onClick={() => setSecretForm({ open: true, name: '', value: '', description: '' })}>+ <Plus size={15} /> Add secret+ </Button>+ <SearchField value={search} onSearch={setSearch} placeholder="Search secrets…" />+ </>+ ) : (+ <>+ <Button size="sm" onClick={() => setVaultForm({ open: true, name: '', description: '', workspace_id: activeWorkspaceId })}>+ <Plus size={15} /> New vault+ </Button>+ <SearchField value={search} onSearch={setSearch} placeholder="Search vaults…" />+ </>+ )), [selectedVault, search, activeWorkspaceId]);- return (- <div className="sk-tabgroup__inner secrets-page">- {!selectedVault ? (- <Card>- <CardHeader>- <div className="secrets__header">- <div>- <CardTitle>Secret Vaults</CardTitle>- <CardDescription>Encrypted key/value stores for credentials and tokens.</CardDescription>- </div>- <Button onClick={() => setVaultForm({ open: true, name: '', description: '', workspace_id: activeWorkspaceId })}>- <Plus size={14} /> New Vault- </Button>- </div>- </CardHeader>- <CardContent>- {vaults.length === 0 ? (- <EmptyState title="No vaults yet" description="Create a vault to start storing secrets." />- ) : (- <Table>- <TableHeader>- <TableRow>- <TableHead>Name</TableHead>- <TableHead>Description</TableHead>- <TableHead>Secrets</TableHead>- <TableHead className="text-right">Actions</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {vaults.map(vault => (- <TableRow key={vault.id} className="cursor-pointer" onClick={() => openVault(vault.id)}>- <TableCell className="font-medium">{vault.name}</TableCell>- <TableCell>{vault.description || '—'}</TableCell>- <TableCell>{vault.secret_count ?? '—'}</TableCell>- <TableCell className="text-right">- <DropdownMenu>- <DropdownMenuTrigger asChild onClick={(e) => e.stopPropagation()}>- <Button variant="ghost" size="icon"><MoreVertical size={14} /></Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuItem onClick={() => openVault(vault.id)}>Open</DropdownMenuItem>- <DropdownMenuItem className="text-destructive" onClick={() => deleteVault(vault.id)}>Delete</DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>- )}- </CardContent>- </Card>- ) : (- <Card>- <CardHeader>- <div className="secrets__header">- <div>- <Button variant="ghost" size="sm" onClick={() => setSelectedVault(null)}>← Back</Button>- <CardTitle className="mt-2">{selectedVault.name}</CardTitle>- <CardDescription>{selectedVault.description || 'No description'}</CardDescription>- </div>- <Button onClick={() => setSecretForm({ open: true, name: '', value: '', description: '' })}>- <Plus size={14} /> Add Secret- </Button>- </div>- </CardHeader>- <CardContent>- {(selectedVault.secrets || []).length === 0 ? (- <EmptyState title="No secrets yet" description="Add your first secret to this vault." />- ) : (- <Table>- <TableHeader>- <TableRow>- <TableHead>Name</TableHead>- <TableHead>Value</TableHead>- <TableHead>Description</TableHead>- <TableHead>Updated</TableHead>- <TableHead className="text-right">Actions</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {selectedVault.secrets.map(secret => {- const revealed = revealSecretId === secret.id;- return (- <TableRow key={secret.id}>- <TableCell className="font-medium">{secret.name}</TableCell>- <TableCell>- <code className="secrets__value">- {revealed ? revealedValue : secret.value}- </code>- </TableCell>- <TableCell>{secret.description || '—'}</TableCell>- <TableCell>{formatDate(secret.updated_at)}</TableCell>- <TableCell className="text-right">- <Button variant="ghost" size="icon" onClick={() => revealed ? setRevealSecretId(null) : revealSecret(secret)}>- {revealed ? <EyeOff size={14} /> : <Eye size={14} />}- </Button>- <Button variant="ghost" size="icon" onClick={() => { navigator.clipboard.writeText(revealed ? revealedValue : secret.value); toast.success('Copied') }}>- <Copy size={14} />- </Button>- <Button variant="ghost" size="icon" className="text-destructive" onClick={() => deleteSecret(secret.id)}>- <Trash2 size={14} />- </Button>- </TableCell>- </TableRow>- );- })}- </TableBody>- </Table>- )}- </CardContent>- </Card>+ // Reset the query when changing depth — a term that matched a vault name is+ // almost never a secret name, and leaving it applied shows an empty table.+ useEffect(() => { setSearch(''); }, [selectedVault?.id]);++ const vaultRows = useMemo(() => {+ const q = search.trim().toLowerCase();+ if (!q) return vaults;+ return vaults.filter((v) => (+ v.name?.toLowerCase().includes(q) || v.description?.toLowerCase().includes(q)+ ));+ }, [vaults, search]);++ const secretRows = useMemo(() => {+ const all = selectedVault?.secrets || [];+ const q = search.trim().toLowerCase();+ if (!q) return all;+ return all.filter((s) => (+ s.name?.toLowerCase().includes(q) || s.description?.toLowerCase().includes(q)+ ));+ }, [selectedVault, search]);++ const vaultColumns = useMemo(() => [+ {+ key: 'name',+ header: 'Vault',+ sortable: true,+ hideable: false,+ value: (v) => v.name,+ render: (v) => (+ <div className="sk-cell-name">+ <ServiceTile name={v.name} size={30} className="wp-list__tile" aria-hidden="true" />+ <span>{v.name}</span>+ </div>+ ),+ },+ {+ key: 'description',+ header: 'Description',+ sortable: true,+ value: (v) => v.description || '',+ render: (v) => v.description || <span className="wp-list__dash">—</span>,+ },+ {+ key: 'secrets',+ header: 'Secrets',+ type: 'number',+ sortable: true,+ width: 100,+ cellClassName: 'sk-cell-mono',+ // `value` sorts and filters; `render` is what the cell shows —+ // DataTable falls back to row[key], and there is no `secrets` key.+ value: (v) => v.secret_count ?? 0,+ render: (v) => v.secret_count ?? 0,+ },+ {+ key: '__actions',+ header: '',+ sortable: false,+ hideable: false,+ width: 56,+ className: 'text-right',+ render: (v) => (+ <DropdownMenu>+ <DropdownMenuTrigger asChild onClick={(e) => e.stopPropagation()}>+ <Button variant="ghost" size="icon"><MoreVertical size={14} /></Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem onClick={() => openVault(v.id)}>Open</DropdownMenuItem>+ <DropdownMenuItem className="text-destructive" onClick={() => deleteVault(v.id)}>Delete</DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ ),+ },+ // eslint-disable-next-line react-hooks/exhaustive-deps+ ], []);++ const secretColumns = useMemo(() => [+ {+ key: 'name',+ header: 'Secret',+ sortable: true,+ hideable: false,+ value: (s) => s.name,+ cellClassName: 'sk-cell-mono',+ },+ {+ key: 'value',+ header: 'Value',+ sortable: false,+ filterable: false,+ render: (s) => (+ <code className="secrets__value">+ {revealSecretId === s.id ? revealedValue : s.value}+ </code>+ ),+ },+ {+ key: 'description',+ header: 'Description',+ sortable: true,+ value: (s) => s.description || '',+ render: (s) => s.description || <span className="wp-list__dash">—</span>,+ },+ {+ key: 'updated',+ header: 'Updated',+ type: 'date',+ sortable: true,+ width: 130,+ cellClassName: 'sk-cell-mono',+ value: (s) => s.updated_at || null,+ render: (s) => (s.updated_at+ ? <span title={formatDate(s.updated_at)}>{formatRelativeTime(s.updated_at)}</span>+ : <span className="wp-list__dash">—</span>),+ },+ {+ key: '__actions',+ header: '',+ sortable: false,+ hideable: false,+ width: 120,+ className: 'text-right',+ render: (s) => {+ const revealed = revealSecretId === s.id;+ return (+ <div onClick={(e) => e.stopPropagation()}>+ <Button variant="ghost" size="icon" onClick={() => (revealed ? setRevealSecretId(null) : revealSecret(s))} title={revealed ? 'Hide' : 'Reveal'}>+ {revealed ? <EyeOff size={14} /> : <Eye size={14} />}+ </Button>+ <Button variant="ghost" size="icon" title="Copy" onClick={() => { navigator.clipboard.writeText(revealed ? revealedValue : s.value); toast.success('Copied'); }}>+ <Copy size={14} />+ </Button>+ <Button variant="ghost" size="icon" className="text-destructive" title="Delete" onClick={() => deleteSecret(s.id)}>+ <Trash2 size={14} />+ </Button>+ </div>+ );+ },+ },+ // eslint-disable-next-line react-hooks/exhaustive-deps+ ], [revealSecretId, revealedValue]);++ const vaultTable = selectedVault ? (+ <ResourceListPage+ key="secrets"+ loading={false}+ storageKey="serverkit-list-secrets"+ viewPageKey="vault-secrets"+ noun="secrets"+ totalCount={(selectedVault.secrets || []).length}+ items={secretRows}+ columns={secretColumns}+ keyField="id"+ emptyIcon={KeyRound}+ emptyTitle="No secrets yet"+ emptyDescription={`Add your first secret to ${selectedVault.name}.`}+ emptyAction={(+ <Button onClick={() => setSecretForm({ open: true, name: '', value: '', description: '' })}>+ <Plus size={16} /> Add secret+ </Button>+ )}+ filteredEmptyIcon={KeyRound}+ filteredEmptyTitle="No secrets found"+ filteredEmptyDescription="Try adjusting your search or filters."+ />+ ) : (+ <ResourceListPage+ key="vaults"+ loading={loading}+ loadingTitle="Loading vaults…"+ storageKey="serverkit-list-vaults"+ viewPageKey="vaults"+ noun="vaults"+ builtinViews={VAULT_VIEWS}+ totalCount={vaults.length}+ items={vaultRows}+ columns={vaultColumns}+ keyField="id"+ onRowClick={(v) => openVault(v.id)}+ emptyIcon={KeyRound}+ emptyTitle="No vaults yet"+ emptyDescription="A vault is an encrypted key/value store for credentials and tokens. Create one to start putting secrets in it."+ emptyAction={(+ <Button onClick={() => setVaultForm({ open: true, name: '', description: '', workspace_id: activeWorkspaceId })}>+ <Plus size={16} /> Create your first vault+ </Button>)}+ filteredEmptyIcon={KeyRound}+ filteredEmptyTitle="No vaults found"+ filteredEmptyDescription="Try adjusting your search or filters."+ />+ );++ // ResourceListPage supplies the `sk-tabgroup__inner` wrapper itself, so the+ // page is just the active table plus the two dialogs.+ return (+ <>+ {vaultTable}<Modal open={vaultForm.open} onClose={() => setVaultForm({ ...vaultForm, open: false })} title="New Vault"><p className="sk-modal__subtitle">Create an encrypted vault to group secrets.</p>@@ -309,6 +426,6 @@ export default function Vaults() {</div></form></Modal>- </div>+ </>);}