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): move linked-panel flow into the Add Server drawer as a third tab
Juan Denisb50a008984cb
diff --git a/frontend/src/components/servers/LinkPanelForm.jsx b/frontend/src/components/servers/LinkPanelForm.jsxnew file mode 100644index 00000000..dd1b812b--- /dev/null+++ b/frontend/src/components/servers/LinkPanelForm.jsx@@ -0,0 +1,184 @@+import { useEffect, useState } from 'react';+import { Unlink } from 'lucide-react';+import api from '../../services/api';+import { useToast } from '../../contexts/ToastContext';+import { ConfirmDialog } from '../ConfirmDialog';+import StatusBadge from '../StatusBadge';+import { InfoList, InfoItem } from '../InfoList';+import { Button } from '@/components/ui/button';+import { Input } from '@/components/ui/input';++const POLL_INTERVAL = 5000;++function formatTimestamp(iso) {+ if (!iso) return '—';+ const date = new Date(iso);+ return Number.isNaN(date.getTime()) ? '—' : date.toLocaleString();+}++// "Link panel" tab of the Add Server modal — the inverse of the other two+// tabs: instead of adding a remote server to THIS panel, link THIS panel to a+// master ServerKit so the master can manage this server (embedded agent mode,+// no Go agent install). Polls the link status while visible so the connection+// badge flips to Connected live.+const LinkPanelForm = ({ onClose }) => {+ const toast = useToast();+ const [status, setStatus] = useState(null); // null = still loading+ const [masterUrl, setMasterUrl] = useState('');+ const [token, setToken] = useState('');+ const [name, setName] = useState('');+ const [submitting, setSubmitting] = useState(false);+ const [linkError, setLinkError] = useState('');+ const [unlinkOpen, setUnlinkOpen] = useState(false);++ async function loadStatus({ silent = false } = {}) {+ try {+ const data = await api.getLinkedPanel();+ setStatus(data);+ } catch (err) {+ if (!silent) setLinkError(err?.data?.error || err.message || 'Failed to load linked panel status');+ }+ }++ useEffect(() => {+ loadStatus();+ const interval = setInterval(() => loadStatus({ silent: true }), POLL_INTERVAL);+ return () => clearInterval(interval);+ }, []);++ async function handleLink(e) {+ e.preventDefault();+ setLinkError('');+ setSubmitting(true);+ try {+ const result = await api.linkPanel({+ master_url: masterUrl.trim(),+ registration_token: token.trim(),+ name: name.trim() || undefined,+ });+ toast.success('Panel linked to master');+ setStatus(result.status || { linked: true, master_url: masterUrl.trim() });+ setToken('');+ } catch (err) {+ setLinkError(err?.data?.error || err.message || 'Failed to link panel');+ } finally {+ setSubmitting(false);+ }+ }++ async function handleUnlink() {+ try {+ await api.unlinkPanel();+ toast.success('Panel unlinked');+ setUnlinkOpen(false);+ setStatus({ linked: false });+ } catch (err) {+ toast.error(err?.data?.error || err.message || 'Failed to unlink panel');+ }+ }++ if (status?.linked) {+ return (+ <div className="server-setup-form">+ <div className="server-setup-form__body">+ <div className="link-panel-status">+ <StatusBadge status={status.connected ? 'connected' : 'disconnected'} />+ <InfoList>+ <InfoItem label="Master" value={status.master_url} mono />+ <InfoItem+ label="Remote server"+ value={status.remote_server_name+ ? `${status.remote_server_name}${status.remote_server_id ? ` (#${status.remote_server_id})` : ''}`+ : (status.remote_server_id ? `#${status.remote_server_id}` : '—')}+ />+ <InfoItem label="Linked since" value={formatTimestamp(status.created_at)} />+ <InfoItem label="Last heartbeat" value={formatTimestamp(status.last_heartbeat_at)} />+ </InfoList>+ {status.last_error && (+ <div className="error-message">+ Connection error: {status.last_error}+ </div>+ )}+ </div>+ </div>++ <div className="modal-actions">+ <Button type="button" variant="outline" onClick={onClose}>+ Close+ </Button>+ <Button type="button" variant="destructive" onClick={() => setUnlinkOpen(true)}>+ <Unlink size={14} /> Unlink+ </Button>+ </div>++ <ConfirmDialog+ isOpen={unlinkOpen}+ title="Unlink from master panel?"+ message={`This server will stop being manageable by ${status?.master_url || 'the master panel'}. The link credentials are removed from this panel.`}+ confirmText="Unlink"+ variant="danger"+ onConfirm={handleUnlink}+ onCancel={() => setUnlinkOpen(false)}+ />+ </div>+ );+ }++ return (+ <form className="server-setup-form" onSubmit={handleLink}>+ <div className="server-setup-form__body">+ <p className="section-description">+ Link this panel to a master ServerKit so it can manage this server — no+ separate agent install needed. Generate a registration token on the+ master: Servers → Add Server / regenerate token.+ </p>++ {linkError && <div className="error-message">{linkError}</div>}++ <div className="form-group">+ <label>Master URL *</label>+ <Input+ type="url"+ value={masterUrl}+ onChange={(e) => setMasterUrl(e.target.value)}+ placeholder="https://panel.example.com"+ required+ />+ </div>++ <div className="form-group">+ <label>Registration token *</label>+ <Input+ type="password"+ value={token}+ onChange={(e) => setToken(e.target.value)}+ placeholder="Token generated on the master"+ required+ />+ </div>++ <div className="form-group">+ <label>Display name</label>+ <Input+ type="text"+ value={name}+ onChange={(e) => setName(e.target.value)}+ placeholder="Optional"+ />+ <span className="form-hint">How this server appears on the master panel.</span>+ </div>+ </div>++ <div className="modal-actions">+ <Button type="button" variant="outline" onClick={onClose}>+ Cancel+ </Button>+ <Button type="submit" disabled={submitting || status === null}>+ {submitting ? 'Linking…' : 'Link panel'}+ </Button>+ </div>+ </form>+ );+};++export default LinkPanelForm;diff --git a/frontend/src/components/servers/LinkedPanelCard.jsx b/frontend/src/components/servers/LinkedPanelCard.jsxdeleted file mode 100644index e6cee4e0..00000000--- a/frontend/src/components/servers/LinkedPanelCard.jsx+++ /dev/null@@ -1,180 +0,0 @@-import { useEffect, useState } from 'react';-import { Link2, Unlink } from 'lucide-react';-import api from '../../services/api';-import { useToast } from '../../contexts/ToastContext';-import { ConfirmDialog } from '../ConfirmDialog';-import StatusBadge from '../StatusBadge';-import { InfoList, InfoItem } from '../InfoList';-import { Button } from '@/components/ui/button';-import { Input } from '@/components/ui/input';--const POLL_INTERVAL = 5000;--function formatTimestamp(iso) {- if (!iso) return '—';- const date = new Date(iso);- return Number.isNaN(date.getTime()) ? '—' : date.toLocaleString();-}--// "Linked Panel" — the inverse of Add Server: link THIS panel to a master-// ServerKit so the master can deploy apps here as if the Go agent were-// installed. Polls the link status while visible so the connection badge-// flips to Connected live.-const LinkedPanelCard = () => {- const toast = useToast();- const [status, setStatus] = useState(null); // null = still loading- const [masterUrl, setMasterUrl] = useState('');- const [token, setToken] = useState('');- const [name, setName] = useState('');- const [submitting, setSubmitting] = useState(false);- const [linkError, setLinkError] = useState('');- const [unlinkOpen, setUnlinkOpen] = useState(false);-- async function loadStatus({ silent = false } = {}) {- try {- const data = await api.getLinkedPanel();- setStatus(data);- } catch (err) {- if (!silent) toast.error(err?.data?.error || err.message || 'Failed to load linked panel status');- }- }-- useEffect(() => {- loadStatus();- const interval = setInterval(() => loadStatus({ silent: true }), POLL_INTERVAL);- return () => clearInterval(interval);- // eslint-disable-next-line react-hooks/exhaustive-deps- }, []);-- async function handleLink(e) {- e.preventDefault();- setLinkError('');- setSubmitting(true);- try {- const result = await api.linkPanel({- master_url: masterUrl.trim(),- registration_token: token.trim(),- name: name.trim() || undefined,- });- toast.success('Panel linked to master');- setStatus(result.status || { linked: true, master_url: masterUrl.trim() });- setToken('');- } catch (err) {- setLinkError(err?.data?.error || err.message || 'Failed to link panel');- } finally {- setSubmitting(false);- }- }-- async function handleUnlink() {- try {- await api.unlinkPanel();- toast.success('Panel unlinked');- setUnlinkOpen(false);- setStatus({ linked: false });- } catch (err) {- toast.error(err?.data?.error || err.message || 'Failed to unlink panel');- }- }-- const linked = Boolean(status?.linked);-- return (- <section className="linked-panel-card">- <div className="linked-panel-card__header">- <Link2 size={16} />- <div>- <h3>Linked Panel</h3>- <p className="text-muted">- Link this panel to a master ServerKit so it can manage this server — no separate agent install needed.- </p>- </div>- {linked && (- <StatusBadge status={status.connected ? 'connected' : 'disconnected'} />- )}- </div>-- {status === null ? (- <p className="text-muted">Loading link status…</p>- ) : !linked ? (- <form className="linked-panel-card__form" onSubmit={handleLink}>- <p className="text-muted">- Generate a registration token on the master: Servers → Add Server / regenerate token.- </p>- {linkError && <div className="alert alert-danger">{linkError}</div>}- <div className="form-group">- <label>Master URL *</label>- <Input- type="url"- value={masterUrl}- onChange={(e) => setMasterUrl(e.target.value)}- placeholder="https://panel.example.com"- required- />- </div>- <div className="form-group">- <label>Registration token *</label>- <Input- type="password"- value={token}- onChange={(e) => setToken(e.target.value)}- placeholder="Token generated on the master"- required- />- </div>- <div className="form-group">- <label>Display name</label>- <Input- type="text"- value={name}- onChange={(e) => setName(e.target.value)}- placeholder="Optional — how this server appears on the master"- />- </div>- <div className="linked-panel-card__actions">- <Button type="submit" disabled={submitting}>- <Link2 size={14} /> {submitting ? 'Linking…' : 'Link panel'}- </Button>- </div>- </form>- ) : (- <div className="linked-panel-card__status">- <InfoList>- <InfoItem label="Master" value={status.master_url} mono />- <InfoItem- label="Remote server"- value={status.remote_server_name- ? `${status.remote_server_name}${status.remote_server_id ? ` (#${status.remote_server_id})` : ''}`- : (status.remote_server_id ? `#${status.remote_server_id}` : '—')}- />- <InfoItem label="Agent ID" value={status.agent_id} mono />- <InfoItem label="Linked since" value={formatTimestamp(status.created_at)} />- <InfoItem label="Last heartbeat" value={formatTimestamp(status.last_heartbeat_at)} />- </InfoList>- {status.last_error && (- <div className="alert alert-danger">- <strong>Connection error:</strong> {status.last_error}- </div>- )}- <div className="linked-panel-card__actions">- <Button type="button" variant="destructive" onClick={() => setUnlinkOpen(true)}>- <Unlink size={14} /> Unlink- </Button>- </div>- </div>- )}-- <ConfirmDialog- isOpen={unlinkOpen}- title="Unlink from master panel?"- message={`This server will stop being manageable by ${status?.master_url || 'the master panel'}. The link credentials are removed from this panel.`}- confirmText="Unlink"- variant="danger"- onConfirm={handleUnlink}- onCancel={() => setUnlinkOpen(false)}- />- </section>- );-};--export default LinkedPanelCard;diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsxindex 65392625..dd10c135 100644--- a/frontend/src/pages/Servers.jsx+++ b/frontend/src/pages/Servers.jsx@@ -19,7 +19,7 @@ import Modal from '@/components/Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { DataTable } from '@/components/ds';-import LinkedPanelCard from '../components/servers/LinkedPanelCard';+import LinkPanelForm from '../components/servers/LinkPanelForm';const Servers = () => {const [servers, setServers] = useState([]);@@ -440,8 +440,6 @@ const Servers = () => {/></div>)}-- <LinkedPanelCard /></main></div>@@ -925,9 +923,11 @@ Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registratio<div className="modal server-setup-modal" onClick={e => e.stopPropagation()}><div className="modal-header"><div>- <h2>{step === 1 ? 'Add Server' : (mode === 'pair' ? 'Pair Agent' : 'Connect Agent')}</h2>+ <h2>{step === 1 ? (mode === 'link' ? 'Link to Master Panel' : 'Add Server') : (mode === 'pair' ? 'Pair Agent' : 'Connect Agent')}</h2><p>- {step === 2 && mode !== 'pair'+ {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.'@@ -953,10 +953,19 @@ Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registratio>Pair code</button>+ <button+ type="button"+ className={`mode-switcher__tab${mode === 'link' ? ' is-active' : ''}`}+ onClick={() => setMode('link')}+ >+ Link panel+ </button></div>)}- {step === 1 && mode === 'pair' ? (+ {step === 1 && mode === 'link' ? (+ <LinkPanelForm onClose={onClose} />+ ) : step === 1 && mode === 'pair' ? (<PairAgentFormgroups={groups}onClose={onClose}diff --git a/frontend/src/styles/pages/_servers.scss b/frontend/src/styles/pages/_servers.scssindex d92e5ca4..fd153154 100644--- a/frontend/src/styles/pages/_servers.scss+++ b/frontend/src/styles/pages/_servers.scss@@ -4293,68 +4293,10 @@}// ============================================-// LINKED PANEL CARD — link this panel to a master ServerKit (embedded agent)+// LINK PANEL — "Link panel" tab of the Add Server modal (linked state view)// ============================================-.linked-panel-card {- flex-shrink: 0;+.link-panel-status {display: flex;flex-direction: column;gap: $space-3;- padding: $space-4;- background: $bg-card;- border: 1px solid $border-default;- border-radius: $radius-lg;-- &__header {- display: flex;- align-items: flex-start;- gap: $space-3;-- > svg {- color: $accent-primary;- flex-shrink: 0;- margin-top: 2px;- }-- > div {- flex: 1;- min-width: 0;- }-- h3 {- margin: 0;- font-size: $font-size-base;- font-weight: $font-weight-semibold;- color: $text-primary;- }-- p {- margin: $space-1 0 0;- font-size: $font-size-sm;- }- }-- &__form {- display: flex;- flex-direction: column;- gap: $space-3;- max-width: 480px;-- > p {- margin: 0;- font-size: $font-size-sm;- }- }-- &__status {- display: flex;- flex-direction: column;- gap: $space-3;- }-- &__actions {- display: flex;- justify-content: flex-end;- gap: $space-2;- }}