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(services): URL-route detail tabs and adopt the shared repo-connect form

Juan Denis1c519a24a2b5
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index a72001d1..382fc527 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -275,6 +275,10 @@ function AppRoutes() {
<Route path="deployments/:jobId" element={<Deployments />} />
</Route>
<Route path="services/:id" element={<ServiceDetail />} />
+ <Route path="services/:id/:tab" element={<ServiceDetail />} />
+ {/* Settings sub-section in the URL (e.g. .../settings/repository)
+ so the Settings left-nav is shareable and survives a refresh. */}
+ <Route path="services/:id/:tab/:section" element={<ServiceDetail />} />
<Route path="apps" element={<Navigate to="/services" replace />} />
<Route path="apps/:id" element={<ApplicationDetail />} />
<Route path="apps/:id/:tab" element={<ApplicationDetail />} />
diff --git a/frontend/src/components/service-detail/GitConnectModal.jsx b/frontend/src/components/service-detail/GitConnectModal.jsx
deleted file mode 100644
index fa87edd6..00000000
--- a/frontend/src/components/service-detail/GitConnectModal.jsx
+++ /dev/null
@@ -1,185 +0,0 @@
-import { useState } from 'react';
-import { ChevronDown, GitBranch, Settings2 } 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 { Textarea } from '@/components/ui/textarea';
-import { Switch } from '@/components/ui/switch';
-import Modal from '../Modal';
-import { RepoProviderStrip, ProviderBadge, detectProvider } from '../git/GitProviders';
-
-const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => {
- const toast = useToast();
- const [saving, setSaving] = useState(false);
- const [repoUrl, setRepoUrl] = useState(deployConfig?.repo_url || '');
- const [branch, setBranch] = useState(deployConfig?.branch || 'main');
- const [autoDeploy, setAutoDeploy] = useState(deployConfig?.auto_deploy ?? true);
- const [preDeployScript, setPreDeployScript] = useState(deployConfig?.pre_deploy_script || '');
- const [postDeployScript, setPostDeployScript] = useState(deployConfig?.post_deploy_script || '');
- const [scriptsOpen, setScriptsOpen] = useState(
- Boolean(deployConfig?.pre_deploy_script || deployConfig?.post_deploy_script)
- );
-
- const provider = detectProvider(repoUrl);
-
- async function handleSubmit(e) {
- e.preventDefault();
- if (!repoUrl.trim()) return;
-
- setSaving(true);
- try {
- await api.configureDeployment(
- appId,
- repoUrl.trim(),
- branch || 'main',
- autoDeploy,
- preDeployScript || null,
- postDeployScript || null
- );
-
- if (autoDeploy && !deployConfig) {
- try {
- await api.createWebhook({
- deploy_on_push: true,
- app_id: appId,
- repo_url: repoUrl.trim(),
- branch: branch || 'main',
- });
- } catch {
- // Webhook creation is best-effort
- }
- }
-
- toast.success('Repository connected');
- onSaved();
- } catch {
- toast.error('Failed to save deployment configuration');
- } finally {
- setSaving(false);
- }
- }
-
- async function handleDisconnect() {
- if (!confirm('Disconnect this repository? Auto-deploy will stop.')) return;
-
- setSaving(true);
- try {
- await api.removeDeployment(appId);
- toast.success('Repository disconnected');
- onSaved();
- } catch {
- toast.error('Failed to disconnect repository');
- setSaving(false);
- }
- }
-
- return (
- <Modal open={true} onClose={onClose} title={deployConfig ? 'Edit Repository' : 'Connect Repository'}>
- <form className="git-connect" onSubmit={handleSubmit}>
- <div className="git-connect__intro">
- <span className="git-connect__intro-icon">
- <GitBranch size={19} />
- </span>
- <div className="git-connect__intro-text">
- <strong>Connect a Git repository</strong>
- <span>Link a repo so ServerKit can pull your code and redeploy on every push.</span>
- </div>
- </div>
-
- <RepoProviderStrip detected={provider?.key} />
-
- <div className="git-connect__field">
- <Label htmlFor="git-repo-url">Repository URL</Label>
- <Input
- id="git-repo-url"
- type="text"
- value={repoUrl}
- onChange={(e) => setRepoUrl(e.target.value)}
- placeholder="https://github.com/user/repo.git"
- required
- />
- {provider && <ProviderBadge provider={provider} />}
- </div>
-
- <div className="git-connect__field">
- <Label htmlFor="git-branch">Branch</Label>
- <Input
- id="git-branch"
- type="text"
- value={branch}
- onChange={(e) => setBranch(e.target.value)}
- placeholder="main"
- />
- </div>
-
- <div className="git-connect__toggle">
- <div>
- <strong>Auto-deploy on push</strong>
- <span>Automatically deploy when new commits land on this branch.</span>
- </div>
- <Switch checked={autoDeploy} onCheckedChange={setAutoDeploy} />
- </div>
-
- <button
- type="button"
- className="git-connect__advanced-toggle"
- onClick={() => setScriptsOpen((open) => !open)}
- aria-expanded={scriptsOpen}
- >
- <span>
- <Settings2 size={16} />
- Deploy scripts (optional)
- </span>
- <ChevronDown size={16} />
- </button>
-
- {scriptsOpen && (
- <div className="git-connect__advanced">
- <div className="git-connect__field">
- <Label htmlFor="pre-deploy-script">Pre-deploy script</Label>
- <Textarea
- id="pre-deploy-script"
- value={preDeployScript}
- onChange={(e) => setPreDeployScript(e.target.value)}
- placeholder="Commands to run before deployment..."
- />
- </div>
- <div className="git-connect__field">
- <Label htmlFor="post-deploy-script">Post-deploy script</Label>
- <Textarea
- id="post-deploy-script"
- value={postDeployScript}
- onChange={(e) => setPostDeployScript(e.target.value)}
- placeholder="Commands to run after deployment..."
- />
- </div>
- </div>
- )}
-
- <div className="git-connect__actions">
- {deployConfig && (
- <Button
- type="button"
- variant="destructive"
- onClick={handleDisconnect}
- disabled={saving}
- className="git-connect__actions-spacer"
- >
- Disconnect
- </Button>
- )}
- <Button type="button" variant="outline" onClick={onClose}>
- Cancel
- </Button>
- <Button type="submit" disabled={saving}>
- {saving ? 'Saving...' : deployConfig ? 'Save Changes' : 'Connect'}
- </Button>
- </div>
- </form>
- </Modal>
- );
-};
-
-export default GitConnectModal;
diff --git a/frontend/src/components/service-detail/SettingsTab.jsx b/frontend/src/components/service-detail/SettingsTab.jsx
index dab55d0b..83b0dbb1 100644
--- a/frontend/src/components/service-detail/SettingsTab.jsx
+++ b/frontend/src/components/service-detail/SettingsTab.jsx
@@ -1,9 +1,10 @@
import React, { useState } from 'react';
-import { useNavigate } from 'react-router-dom';
+import { useNavigate, useParams } from 'react-router-dom';
import { SlidersHorizontal, GitBranch, AlertTriangle } from 'lucide-react';
import api from '../../services/api';
import { useToast } from '../../contexts/ToastContext';
import { DangerZone } from '../DangerZone';
+import RepoConnectForm from '../git/RepoConnectForm';
import { Button } from '@/components/ui/button';
import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';
@@ -17,10 +18,16 @@ const SVC_SETTINGS_GROUPS = [
{ label: 'Advanced', items: [{ id: 'danger', label: 'Danger Zone', icon: AlertTriangle }] },
];
-const SettingsTab = ({ app, deployConfig, onUpdate, onOpenGitModal }) => {
+const SVC_SETTINGS_ITEMS = SVC_SETTINGS_GROUPS.flatMap((g) => g.items);
+
+const SettingsTab = ({ app, deployConfig, onUpdate }) => {
const navigate = useNavigate();
const toast = useToast();
- const [section, setSection] = useState('environment');
+ // Section lives in the URL (/services/:id/settings/:section) so it's
+ // shareable and survives a refresh — same as the WordPress detail page.
+ const { section: sectionParam } = useParams();
+ const section = SVC_SETTINGS_ITEMS.some((s) => s.id === sectionParam) ? sectionParam : 'environment';
+ const setSection = (s) => navigate(`/services/${app.id}/settings/${s}`, { replace: true });
const [deleting, setDeleting] = useState(false);
const [environmentType, setEnvironmentType] = useState(app.environment_type || 'standalone');
const [savingEnvironment, setSavingEnvironment] = useState(false);
@@ -77,6 +84,50 @@ const SettingsTab = ({ app, deployConfig, onUpdate, onOpenGitModal }) => {
}
}
+ // Repo state shaped for the shared RepoConnectForm (the same component the
+ // WordPress Git settings use). A connected deploy config == connected repo.
+ const gitStatus = {
+ connected: Boolean(deployConfig),
+ repo_url: deployConfig?.repo_url,
+ branch: deployConfig?.branch,
+ auto_deploy: deployConfig?.auto_deploy,
+ last_deploy_commit: deployConfig?.last_deploy_commit,
+ last_deploy_at: deployConfig?.last_deploy_at,
+ };
+
+ async function handleConnectRepo(data) {
+ const repoUrl = (data.repo_url || '').trim();
+ await api.configureDeployment(
+ app.id,
+ repoUrl,
+ data.branch || 'main',
+ data.auto_deploy,
+ // Preserve any existing deploy scripts (not editable in this form).
+ deployConfig?.pre_deploy_script || null,
+ deployConfig?.post_deploy_script || null
+ );
+ if (data.auto_deploy && !deployConfig) {
+ try {
+ await api.createWebhook({
+ deploy_on_push: true,
+ app_id: app.id,
+ repo_url: repoUrl,
+ branch: data.branch || 'main',
+ });
+ } catch {
+ // Webhook creation is best-effort.
+ }
+ }
+ toast.success('Repository connected');
+ onUpdate();
+ }
+
+ async function handleDisconnectRepo() {
+ await api.removeDeployment(app.id);
+ toast.success('Repository disconnected');
+ onUpdate();
+ }
+
return (
<div className="svc-settings">
<nav className="svc-settings__nav" aria-label="Service settings sections">
@@ -162,27 +213,23 @@ const SettingsTab = ({ app, deployConfig, onUpdate, onOpenGitModal }) => {
</div>
)}
- {/* Repository Configuration */}
+ {/* Repository — the same shared RepoConnectForm the WordPress Git
+ settings use (provider picker + URL fallback, connected summary
+ with Disconnect), wired to the service deployment API. */}
{section === 'repository' && (
<div className="svc-settings__section">
<h3 className="svc-settings__section-title">Repository</h3>
- <div className="card">
- <div className="settings-row">
- <div className="settings-label">
- <span>Connected Repository</span>
- <span className="settings-hint">
- {deployConfig
- ? `${deployConfig.repo_url} (${deployConfig.branch || 'main'})`
- : 'No repository connected'}
- </span>
- </div>
- <div className="settings-control">
- <Button variant="outline" onClick={onOpenGitModal}>
- {deployConfig ? 'Edit' : 'Connect'}
- </Button>
- </div>
- </div>
- </div>
+ <RepoConnectForm
+ gitStatus={gitStatus}
+ onConnect={handleConnectRepo}
+ onDisconnect={handleDisconnectRepo}
+ intro={{
+ title: 'Connect a Git repository',
+ subtitle: 'Link a repo so ServerKit can pull your code and redeploy on every push.',
+ }}
+ submitLabel="Connect Repository"
+ idPrefix="svc"
+ />
</div>
)}
diff --git a/frontend/src/pages/ServiceDetail.jsx b/frontend/src/pages/ServiceDetail.jsx
index 5e753d79..351c4292 100644
--- a/frontend/src/pages/ServiceDetail.jsx
+++ b/frontend/src/pages/ServiceDetail.jsx
@@ -5,6 +5,7 @@ import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import { ConfirmDialog } from '../components/ConfirmDialog';
import { useService } from '../hooks/useService';
+import useTabParam from '../hooks/useTabParam';
import { getTabsForType } from '../utils/serviceTypes';
import EnvironmentVariables from '../components/EnvironmentVariables';
import EventsTab from '../components/service-detail/EventsTab';
@@ -15,7 +16,6 @@ import MetricsTab from '../components/service-detail/MetricsTab';
import PackagesTab from '../components/service-detail/PackagesTab';
import GunicornTab from '../components/service-detail/GunicornTab';
import CommandsTab from '../components/service-detail/CommandsTab';
-import GitConnectModal from '../components/service-detail/GitConnectModal';
import OverviewTab from '../components/service-detail/OverviewTab';
import EmptyState from '../components/EmptyState';
import { Layers, FileArchive, RotateCcw, LayoutDashboard, History, ScrollText, Variable, Terminal, Activity, Package, Server, SquareTerminal, Settings } from 'lucide-react';
@@ -64,10 +64,11 @@ const ServiceDetail = () => {
const toast = useToast();
const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();
const { service, deployConfig, loading, error, reload, performAction, deleteService } = useService(id);
- const [activeTab, setActiveTab] = useState('overview');
+ // Active tab lives in the URL (/services/:id/:tab) so it's shareable and
+ // survives a refresh — same pattern as the WordPress detail page.
+ const [activeTab, setActiveTab] = useTabParam(`/services/${id}`, Object.keys(TAB_LABELS));
const [showDeployMenu, setShowDeployMenu] = useState(false);
const [showMoreMenu, setShowMoreMenu] = useState(false);
- const [showGitModal, setShowGitModal] = useState(false);
const [actionLoading, setActionLoading] = useState(null);
const [versions, setVersions] = useState([]);
const [currentVersion, setCurrentVersion] = useState(null);
@@ -422,7 +423,7 @@ const ServiceDetail = () => {
)}
</span>
) : deployConfig ? (
- <div className="svc-detail__repo-pill" onClick={() => setShowGitModal(true)}>
+ <div className="svc-detail__repo-pill" onClick={() => navigate(`/services/${id}/settings/repository`)}>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<circle cx="18" cy="18" r="3"/>
<circle cx="6" cy="6" r="3"/>
@@ -436,7 +437,7 @@ const ServiceDetail = () => {
)}
</div>
) : (
- <button className="svc-detail__connect-repo" onClick={() => setShowGitModal(true)}>
+ <button className="svc-detail__connect-repo" onClick={() => navigate(`/services/${id}/settings/repository`)}>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<circle cx="18" cy="18" r="3"/>
<circle cx="6" cy="6" r="3"/>
@@ -526,24 +527,11 @@ const ServiceDetail = () => {
app={service}
deployConfig={deployConfig}
onUpdate={reload}
- onOpenGitModal={() => setShowGitModal(true)}
/>
)}
</div>
</div>
- {/* Git Connect Modal */}
- {showGitModal && isGitBased && (
- <GitConnectModal
- appId={service.id}
- deployConfig={deployConfig}
- onClose={() => setShowGitModal(false)}
- onSaved={() => {
- setShowGitModal(false);
- reload();
- }}
- />
- )}
<ConfirmDialog
isOpen={confirmState.isOpen}
title={confirmState.title}