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(wordpress): health card, update manager, SSL panel, and archive/delete/rollback UI

Juan Denis4f79e0464547
diff --git a/backend/app/api/wordpress.py b/backend/app/api/wordpress.py
index 8c29f8de..583945d6 100644
--- a/backend/app/api/wordpress.py
+++ b/backend/app/api/wordpress.py
@@ -437,6 +437,22 @@ def install_theme(app_id):
return jsonify(result), 200 if result['success'] else 400
+@wordpress_bp.route('/sites/<int:app_id>/themes/update', methods=['POST'])
+@jwt_required()
+@admin_required
+def update_themes(app_id):
+ """Update themes."""
+ app = _resolve_app(app_id)
+ data = request.get_json()
+
+ if not app:
+ return jsonify({'error': 'Application not found'}), 404
+
+ themes = data.get('themes') if data else None
+ result = WordPressService.update_themes(app.root_path, themes)
+ return jsonify(result), 200 if result['success'] else 400
+
+
@wordpress_bp.route('/sites/<int:app_id>/themes/<theme>/activate', methods=['POST'])
@jwt_required()
@admin_required
diff --git a/backend/app/services/wordpress_service.py b/backend/app/services/wordpress_service.py
index 16c7e3b2..74ff319b 100644
--- a/backend/app/services/wordpress_service.py
+++ b/backend/app/services/wordpress_service.py
@@ -322,6 +322,20 @@ define('WP_AUTO_UPDATE_CORE', 'minor');
return {'success': True, 'message': 'Plugins updated'}
return result
+ @classmethod
+ def update_themes(cls, path: str, themes: List[str] = None) -> Dict:
+ """Update themes."""
+ cmd = ['theme', 'update']
+ if themes:
+ cmd.extend(themes)
+ else:
+ cmd.append('--all')
+
+ result = cls.wp_cli(path, cmd)
+ if result['success']:
+ return {'success': True, 'message': 'Themes updated'}
+ return result
+
@classmethod
def get_themes(cls, path: str) -> List[Dict]:
"""Get list of installed themes."""
diff --git a/docs/WORDPRESS_ROADMAP.md b/docs/WORDPRESS_ROADMAP.md
index b0186fc3..bd39f5bc 100644
--- a/docs/WORDPRESS_ROADMAP.md
+++ b/docs/WORDPRESS_ROADMAP.md
@@ -97,19 +97,19 @@ Every task here reuses a service that already exists and is verified present. **
- **Reuse:** `WordPressService.harden_wordpress/search_replace/flush_cache` (`:497,609,626`).
- **Done when:** Purge/search-replace/harden are one click each.
-### #6 — One consolidated site-health card `[M]` 🟡
+### #6 — One consolidated site-health card `[M]` 🟡 — ✅ Done
- **Today:** `EnvironmentHealthService.check_health` / `get_disk_usage` compute container/MySQL/WP/disk status; frontend stubs `getProjectHealth`/`getEnvironmentHealth`/`getEnvironmentDiskUsage` exist; `components/wordpress/DiskUsageBar.jsx` is **imported nowhere**. `WordPressDetail` OverviewTab shows static text and calls none of them.
- **Do:** Assemble one health header (WP/PHP version, SSL status [from #8], backup status, update count [from #7], disk usage, cache status [from #22/#23], security warnings) and render `DiskUsageBar`.
- **Reuse:** `EnvironmentHealthService`, the existing frontend stubs, `DiskUsageBar.jsx`.
- **Done when:** The site overview shows a live health header instead of static fields.
-### #7 — Update badges + Update buttons `[M]` 🟡
+### #7 — Update badges + Update buttons `[M]` 🟡 — ✅ Done
- **Today:** `get_wordpress_info` (`services/wordpress_service.py:216`) computes `update_available`/`latest_version`; the plugin/theme list JSON already carries per-item update flags. The OverviewTab/PluginsTab/ThemesTab parse none of it. `update_themes` service method is missing (only `update_plugins`/`update_wordpress` exist).
- **Do:** Render a core update badge + per-plugin/theme "Update" buttons; add `update_themes`.
- **Reuse:** `update_wordpress` (`:256`), `update_plugins` (`:312`), `get_plugins`/`get_themes`.
- **Done when:** Available updates show a count and update in place.
-### #8 — Wire SSL to the WordPress site `[M]` 🟡
+### #8 — Wire SSL to the WordPress site `[M]` 🟡 — ✅ Done (live status; Docker/localhost degrades gracefully)
- **Today:** `ssl_service.obtain_certificate` / `advanced_ssl_service.issue_wildcard_cert` / `setup_auto_renewal` take arbitrary domains and are **never** called by `create_site`; the per-env nginx template listens on `:80` only. `WordPressSite` has no `ssl_status`. The SSL-health methods in `services/security.js` (`getSSLHealth`, `issueWildcardCert`, expiry alerts) have **zero** `.jsx` consumers.
- **Do:** Add a per-site "Enable SSL" action + an `ssl_status` field; call `SSLService` on create/domain-attach; use a wildcard cert for `staging.*`/`dev.*`/multidev subdomains; surface cert grade/expiry on the site's domain panel.
- **Reuse:** `ssl_service`, `advanced_ssl_service`, `security.js`.
diff --git a/frontend/src/pages/WordPressDetail.jsx b/frontend/src/pages/WordPressDetail.jsx
index c90807df..958eec03 100644
--- a/frontend/src/pages/WordPressDetail.jsx
+++ b/frontend/src/pages/WordPressDetail.jsx
@@ -1,12 +1,17 @@
import React, { useState, useEffect } from 'react';
import { useParams, useNavigate, Link } from 'react-router-dom';
-import { ExternalLink, Settings, RefreshCw, Plus, Database, GitBranch, Package, Palette, Archive, Trash2, Replace, ShieldCheck, FolderOpen, FileText } from 'lucide-react';
+import { ExternalLink, Settings, RefreshCw, Plus, Database, GitBranch, Package, Palette, Archive, Trash2, Replace, ShieldCheck, FolderOpen, FileText, Lock } from 'lucide-react';
import useTabParam from '../hooks/useTabParam';
import wordpressApi from '../services/wordpress';
+import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useLogsDrawer } from '../contexts/LogsDrawerContext';
-import { EnvironmentCard, SnapshotTable, GitConnectForm, CommitList } from '../components/wordpress';
+import { EnvironmentCard, SnapshotTable, GitConnectForm, CommitList, DiskUsageBar } from '../components/wordpress';
+import { HealthDot } from '../components/wordpress/HealthStatusPanel';
import { ErrorBoundary, ErrorState } from '../components/ErrorBoundary';
+import { useConfirm } from '../hooks/useConfirm';
+import { ConfirmDialog } from '../components/ConfirmDialog';
+import { DangerZone } from '../components/DangerZone';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -271,12 +276,81 @@ const WordPressDetail = () => {
// Overview Tab
const OverviewTab = ({ site, onUpdate }) => {
const toast = useToast();
+ const navigate = useNavigate();
+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();
+ const [wpInfo, setWpInfo] = useState(null);
+ const [updatingCore, setUpdatingCore] = useState(false);
+ const [archiving, setArchiving] = useState(false);
+ const [showDeleteModal, setShowDeleteModal] = useState(false);
const [creatingSnapshot, setCreatingSnapshot] = useState(false);
const [showEnvModal, setShowEnvModal] = useState(false);
const [syncingAll, setSyncingAll] = useState(false);
const [flushingCache, setFlushingCache] = useState(false);
const [hardening, setHardening] = useState(false);
const [showSearchReplace, setShowSearchReplace] = useState(false);
+ const [health, setHealth] = useState(null);
+ const [diskUsage, setDiskUsage] = useState(null);
+ const [healthLoading, setHealthLoading] = useState(true);
+ const [healthError, setHealthError] = useState(false);
+
+ // Live WP-CLI info (core version + update availability) — best-effort.
+ useEffect(() => {
+ let active = true;
+ wordpressApi.getWordPressInfo(site.id)
+ .then(data => { if (active) setWpInfo(data.info || data); })
+ .catch(() => { /* info is best-effort; the badge just won't show */ });
+ return () => { active = false; };
+ }, [site.id]);
+
+ // Site health + disk usage (both can be slow / unavailable; non-fatal).
+ useEffect(() => {
+ let cancelled = false;
+ setHealthLoading(true);
+ setHealthError(false);
+ (async () => {
+ try {
+ const [healthRes, diskRes] = await Promise.all([
+ wordpressApi.getProjectHealth(site.id).catch(() => null),
+ wordpressApi.getProjectDiskUsage(site.id).catch(() => null),
+ ]);
+ if (cancelled) return;
+ const ownHealth = healthRes?.success
+ ? (healthRes.environments?.[site.id] || healthRes.environments?.[String(site.id)] || null)
+ : null;
+ setHealth(ownHealth);
+ const ownDisk = diskRes?.success
+ ? (diskRes.environments?.[site.id] || diskRes.environments?.[String(site.id)] || null)
+ : null;
+ setDiskUsage(ownDisk?.usage || null);
+ if (!healthRes && !diskRes) setHealthError(true);
+ } catch {
+ if (!cancelled) setHealthError(true);
+ } finally {
+ if (!cancelled) setHealthLoading(false);
+ }
+ })();
+ return () => { cancelled = true; };
+ }, [site.id]);
+
+ async function handleUpdateCore() {
+ setUpdatingCore(true);
+ toast.info('Updating WordPress core...', { duration: 4000 });
+ try {
+ const res = await wordpressApi.updateCore(site.id);
+ if (res.success === false) {
+ toast.error(res.error || 'Core update failed');
+ return;
+ }
+ toast.success(res.message || 'WordPress core updated');
+ const fresh = await wordpressApi.getWordPressInfo(site.id);
+ setWpInfo(fresh.info || fresh);
+ onUpdate?.();
+ } catch (err) {
+ toast.error(err.message || 'Core update failed');
+ } finally {
+ setUpdatingCore(false);
+ }
+ }
async function handleQuickSnapshot() {
setCreatingSnapshot(true);
@@ -355,6 +429,53 @@ const OverviewTab = ({ site, onUpdate }) => {
}
}
+ async function handleArchive() {
+ const ok = await confirm({
+ title: 'Archive Site',
+ message: `Stop and archive "${site.name}"? Containers are stopped but all files and the database are kept. You can unarchive it later.`,
+ confirmText: 'Archive',
+ variant: 'warning',
+ });
+ if (!ok) return;
+ setArchiving(true);
+ toast.info('Archiving site...', { duration: 3000 });
+ try {
+ await wordpressApi.archiveSite(site.id);
+ toast.success('Site archived');
+ onUpdate?.();
+ } catch (err) {
+ toast.error(err.message || 'Failed to archive site');
+ } finally {
+ setArchiving(false);
+ }
+ }
+
+ async function handleUnarchive() {
+ setArchiving(true);
+ toast.info('Unarchiving site...', { duration: 3000 });
+ try {
+ await wordpressApi.unarchiveSite(site.id);
+ toast.success('Site unarchived');
+ onUpdate?.();
+ } catch (err) {
+ toast.error(err.message || 'Failed to unarchive site');
+ } finally {
+ setArchiving(false);
+ }
+ }
+
+ async function handleDelete(createBackup) {
+ toast.info(createBackup ? 'Creating final backup and deleting site...' : 'Deleting site...', { duration: 5000 });
+ try {
+ await wordpressApi.deleteSite(site.id, { createBackup });
+ toast.success('Site deleted');
+ setShowDeleteModal(false);
+ navigate('/wordpress');
+ } catch (err) {
+ toast.error(err.message || 'Failed to delete site');
+ }
+ }
+
async function handleSearchReplace(data) {
// data = { search, replace, dry_run }
toast.info(data.dry_run ? 'Running search-replace preview...' : 'Running search-replace...', { duration: 3000 });
@@ -380,7 +501,24 @@ const OverviewTab = ({ site, onUpdate }) => {
<div className="app-info-grid">
<div className="app-info-item">
<span className="app-info-label">WordPress Version</span>
- <span className="app-info-value">{site.wp_version || 'Unknown'}</span>
+ <span className="app-info-value">
+ {wpInfo?.version || site.wp_version || 'Unknown'}
+ {wpInfo?.update_available && (
+ <>
+ <span className="wp-update-badge">
+ Update available{wpInfo.latest_version ? `: ${wpInfo.latest_version}` : ''}
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={handleUpdateCore}
+ disabled={updatingCore}
+ >
+ {updatingCore ? 'Updating...' : 'Update'}
+ </Button>
+ </>
+ )}
+ </span>
</div>
<div className="app-info-item">
<span className="app-info-label">Multisite</span>
@@ -432,6 +570,71 @@ const OverviewTab = ({ site, onUpdate }) => {
</div>
</div>
+ <div className="app-panel">
+ <div className="app-panel-header">Site Health</div>
+ <div className="app-panel-body">
+ {healthLoading ? (
+ <p className="hint">Checking site health...</p>
+ ) : (
+ <>
+ <div className="app-info-grid">
+ <div className="app-info-item">
+ <span className="app-info-label">Status</span>
+ <span className="app-info-value app-health-stat">
+ <HealthDot status={health?.overall_status || site.health_status || 'unknown'} size={10} />
+ {(health?.overall_status || site.health_status || 'unknown').replace(/^./, c => c.toUpperCase())}
+ </span>
+ </div>
+ <div className="app-info-item">
+ <span className="app-info-label">WordPress Version</span>
+ <span className="app-info-value">{wpInfo?.version || site.wp_version || 'Unknown'}</span>
+ </div>
+ {site.application?.php_version && (
+ <div className="app-info-item">
+ <span className="app-info-label">PHP Version</span>
+ <span className="app-info-value">{site.application.php_version}</span>
+ </div>
+ )}
+ <div className="app-info-item">
+ <span className="app-info-label">Container</span>
+ <span className="app-info-value app-health-stat">
+ <HealthDot status={health?.checks?.container?.status || 'unknown'} size={8} />
+ {health?.checks?.container?.message || (site.status === 'running' ? 'Running' : 'Stopped')}
+ </span>
+ </div>
+ <div className="app-info-item">
+ <span className="app-info-label">Database</span>
+ <span className="app-info-value app-health-stat">
+ <HealthDot status={health?.checks?.mysql?.status || 'unknown'} size={8} />
+ {health?.checks?.mysql?.message || '-'}
+ </span>
+ </div>
+ <div className="app-info-item">
+ <span className="app-info-label">HTTP</span>
+ <span className="app-info-value app-health-stat">
+ <HealthDot status={health?.checks?.wordpress?.status || 'unknown'} size={8} />
+ {health?.checks?.wordpress?.message || '-'}
+ </span>
+ </div>
+ </div>
+
+ {diskUsage ? (
+ <div className="app-health-disk">
+ <span className="app-info-label">Disk Usage</span>
+ <DiskUsageBar usage={diskUsage} />
+ </div>
+ ) : (
+ <p className="hint">Disk usage unavailable.</p>
+ )}
+
+ {healthError && !health && (
+ <p className="hint">Live health checks unavailable for this site.</p>
+ )}
+ </>
+ )}
+ </div>
+ </div>
+
{site.git_repo_url && (
<div className="app-panel">
<div className="app-panel-header">Git Integration</div>
@@ -459,6 +662,46 @@ const OverviewTab = ({ site, onUpdate }) => {
</div>
</div>
)}
+ <SiteSSLPanel site={site} />
+
+ <div className="app-panel">
+ <div className="app-panel-header">Danger Zone</div>
+ <div className="app-panel-body">
+ {site.status === 'archived' ? (
+ <DangerZone
+ title="Unarchive Site"
+ description="Restart this site's containers and bring it back online."
+ action={(
+ <Button variant="outline" onClick={handleUnarchive} disabled={archiving}>
+ <Archive size={16} />
+ {archiving ? 'Unarchiving...' : 'Unarchive'}
+ </Button>
+ )}
+ />
+ ) : (
+ <DangerZone
+ title="Archive Site"
+ description="Stop the containers but keep all files and the database. Reversible."
+ action={(
+ <Button variant="outline" onClick={handleArchive} disabled={archiving}>
+ <Archive size={16} />
+ {archiving ? 'Archiving...' : 'Archive'}
+ </Button>
+ )}
+ />
+ )}
+ <DangerZone
+ title="Delete Site"
+ description="Permanently remove this site, all environments, files and databases. A final backup is taken by default."
+ action={(
+ <Button variant="destructive" onClick={() => setShowDeleteModal(true)}>
+ <Trash2 size={16} />
+ Delete Site
+ </Button>
+ )}
+ />
+ </div>
+ </div>
</div>
<div className="app-overview-right">
@@ -564,6 +807,121 @@ const OverviewTab = ({ site, onUpdate }) => {
onSubmit={handleSearchReplace}
/>
)}
+
+ {showDeleteModal && (
+ <DeleteSiteModal
+ siteName={site.name}
+ onClose={() => setShowDeleteModal(false)}
+ onConfirm={handleDelete}
+ />
+ )}
+
+ <ConfirmDialog
+ isOpen={confirmState.isOpen}
+ title={confirmState.title}
+ message={confirmState.message}
+ confirmText={confirmState.confirmText}
+ cancelText={confirmState.cancelText}
+ variant={confirmState.variant}
+ onConfirm={handleConfirm}
+ onCancel={handleCancel}
+ />
+ </div>
+ );
+};
+
+// SSL Certificate panel — live status + issuance for the site's primary domain
+const SiteSSLPanel = ({ site }) => {
+ const toast = useToast();
+ const domains = site.application?.domains || [];
+ const primaryDomain = (domains.find(d => d.is_primary) || domains[0])?.name || null;
+ // localhost / private-IP / no-domain sites cannot get a public certificate.
+ const isPublicDomain = !!primaryDomain
+ && !/^(localhost|127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(primaryDomain)
+ && primaryDomain.includes('.');
+ const [health, setHealth] = useState(null);
+ const [checking, setChecking] = useState(true);
+ const [issuing, setIssuing] = useState(false);
+
+ useEffect(() => {
+ if (!primaryDomain) { setChecking(false); return; }
+ let cancelled = false;
+ (async () => {
+ setChecking(true);
+ try {
+ const res = await api.getSSLHealth(primaryDomain);
+ if (!cancelled) setHealth(res);
+ } catch (err) {
+ if (!cancelled) setHealth({ valid: false, error: err.message });
+ } finally {
+ if (!cancelled) setChecking(false);
+ }
+ })();
+ return () => { cancelled = true; };
+ }, [primaryDomain]);
+
+ async function handleEnableSSL() {
+ if (!primaryDomain || !site.admin_email) return;
+ setIssuing(true);
+ toast.info(`Requesting certificate for ${primaryDomain}...`, { duration: 4000 });
+ try {
+ const res = await api.obtainCertificate({ domains: [primaryDomain], email: site.admin_email, use_nginx: true });
+ if (res.success) {
+ toast.success(res.message || 'Certificate issued');
+ const updated = await api.getSSLHealth(primaryDomain);
+ setHealth(updated);
+ } else {
+ toast.error(res.error || 'Certificate request failed');
+ }
+ } catch (err) {
+ toast.error(err.message || 'Certificate request failed');
+ } finally {
+ setIssuing(false);
+ }
+ }
+
+ const issued = health?.valid;
+ return (
+ <div className="app-panel">
+ <div className="app-panel-header"><Lock size={16} /> SSL Certificate</div>
+ <div className="app-panel-body">
+ <div className="app-info-grid">
+ <div className="app-info-item">
+ <span className="app-info-label">Primary Domain</span>
+ <span className="app-info-value mono">{primaryDomain || 'None configured'}</span>
+ </div>
+ <div className="app-info-item">
+ <span className="app-info-label">Status</span>
+ <span className={`app-status-badge ${issued ? 'running' : 'stopped'}`}>
+ {checking ? 'Checking...' : issued ? `Active (${health.grade})` : 'Not Secured'}
+ </span>
+ </div>
+ {issued && health.expires_at && (
+ <div className="app-info-item">
+ <span className="app-info-label">Expires</span>
+ <span className="app-info-value">
+ {new Date(health.expires_at).toLocaleDateString()}
+ {typeof health.days_remaining === 'number' ? ` (${health.days_remaining}d)` : ''}
+ </span>
+ </div>
+ )}
+ {issued && health.issuer && (
+ <div className="app-info-item">
+ <span className="app-info-label">Issuer</span>
+ <span className="app-info-value">{health.issuer}</span>
+ </div>
+ )}
+ </div>
+ {!isPublicDomain ? (
+ <p className="hint">SSL requires a public domain pointed at this server. This site is on <code>{primaryDomain || 'localhost'}</code>, so a certificate cannot be issued here. Map a public domain to the site first.</p>
+ ) : !site.admin_email ? (
+ <p className="hint">Set an admin email on the site before requesting a certificate.</p>
+ ) : (
+ <Button onClick={handleEnableSSL} disabled={issuing} className="ssl-action-btn">
+ <Lock size={14} /> {issuing ? 'Requesting...' : issued ? 'Re-issue Certificate' : 'Enable SSL'}
+ </Button>
+ )}
+ </div>
</div>
);
};
@@ -634,6 +992,67 @@ const SearchReplaceModal = ({ onClose, onSubmit }) => {
);
};
+// Delete Site Modal (typed confirmation + optional final backup)
+const DeleteSiteModal = ({ siteName, onClose, onConfirm }) => {
+ const [createBackup, setCreateBackup] = useState(true);
+ const [typed, setTyped] = useState('');
+ const [loading, setLoading] = useState(false);
+ const canDelete = typed.trim() === siteName;
+
+ async function handleSubmit(e) {
+ e.preventDefault();
+ if (!canDelete) return;
+ setLoading(true);
+ try {
+ await onConfirm(createBackup);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ return (
+ <div className="modal-overlay" onClick={onClose}>
+ <div className="modal" onClick={e => e.stopPropagation()}>
+ <div className="modal-header">
+ <h2>Delete Site</h2>
+ <button className="modal-close" onClick={onClose}>&times;</button>
+ </div>
+ <form onSubmit={handleSubmit}>
+ <p className="hint">This permanently deletes <strong>{siteName}</strong>, all its environments, files and databases. This cannot be undone.</p>
+ <div className="form-group">
+ <label className="checkbox-label">
+ <input
+ type="checkbox"
+ checked={createBackup}
+ onChange={(e) => setCreateBackup(e.target.checked)}
+ />
+ <span>Create a final files + database backup before deleting</span>
+ </label>
+ </div>
+ <div className="form-group">
+ <Label>Type <strong>{siteName}</strong> to confirm *</Label>
+ <Input
+ type="text"
+ value={typed}
+ onChange={(e) => setTyped(e.target.value)}
+ placeholder={siteName}
+ autoFocus
+ />
+ </div>
+ <div className="modal-actions">
+ <Button type="button" variant="outline" onClick={onClose} disabled={loading}>
+ Cancel
+ </Button>
+ <Button type="submit" variant="destructive" disabled={loading || !canDelete}>
+ {loading ? 'Deleting...' : 'Delete Site'}
+ </Button>
+ </div>
+ </form>
+ </div>
+ </div>
+ );
+};
+
// Reusable Skeleton Components for Tabs
const EnvironmentCardSkeleton = () => (
<div className="wp-env-card-skeleton">
@@ -1184,6 +1603,7 @@ const PluginsTab = ({ siteId }) => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const [installing, setInstalling] = useState(false);
+ const [updating, setUpdating] = useState(null); // plugin name being updated, or 'all'
const [newPlugin, setNewPlugin] = useState('');
useEffect(() => {
@@ -1221,6 +1641,24 @@ const PluginsTab = ({ siteId }) => {
}
}
+ async function handleUpdate(pluginName) {
+ setUpdating(pluginName || 'all');
+ toast.info(pluginName ? `Updating ${pluginName}...` : 'Updating all plugins...', { duration: 4000 });
+ try {
+ const res = await wordpressApi.updatePlugins(siteId, pluginName ? [pluginName] : undefined);
+ if (res.success === false) {
+ toast.error(res.error || 'Plugin update failed');
+ return;
+ }
+ toast.success(res.message || 'Plugins updated');
+ loadPlugins();
+ } catch (err) {
+ toast.error(err.message || 'Plugin update failed');
+ } finally {
+ setUpdating(null);
+ }
+ }
+
if (loading) {
return (
<div className="plugins-tab">
@@ -1265,6 +1703,20 @@ const PluginsTab = ({ siteId }) => {
</Button>
</form>
+ {plugins.some(p => p.update === 'available') && (
+ <div className="bulk-update-bar">
+ <span>{plugins.filter(p => p.update === 'available').length} plugin update(s) available</span>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => handleUpdate(null)}
+ disabled={updating !== null}
+ >
+ {updating === 'all' ? 'Updating...' : 'Update all'}
+ </Button>
+ </div>
+ )}
+
<div className="plugins-list">
{plugins.length === 0 ? (
<p className="hint">No plugins installed.</p>
@@ -1274,10 +1726,27 @@ const PluginsTab = ({ siteId }) => {
<div className="plugin-info">
<span className="plugin-name">{plugin.title || plugin.name}</span>
<span className="plugin-version">{plugin.version}</span>
+ {plugin.update === 'available' && (
+ <span className="wp-update-badge">
+ Update{plugin.update_version ? `: ${plugin.update_version}` : ''}
+ </span>
+ )}
+ </div>
+ <div className="plugin-actions">
+ {plugin.update === 'available' && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => handleUpdate(plugin.name)}
+ disabled={updating !== null}
+ >
+ {updating === plugin.name ? 'Updating...' : 'Update'}
+ </Button>
+ )}
+ <span className={`plugin-status ${plugin.status}`}>
+ {plugin.status === 'active' ? 'Active' : 'Inactive'}
+ </span>
</div>
- <span className={`plugin-status ${plugin.status}`}>
- {plugin.status === 'active' ? 'Active' : 'Inactive'}
- </span>
</div>
))
)}
@@ -1293,6 +1762,7 @@ const ThemesTab = ({ siteId }) => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const [installing, setInstalling] = useState(false);
+ const [updating, setUpdating] = useState(null); // theme name being updated, or 'all'
const [newTheme, setNewTheme] = useState('');
useEffect(() => {
@@ -1330,6 +1800,24 @@ const ThemesTab = ({ siteId }) => {
}
}
+ async function handleUpdate(themeName) {
+ setUpdating(themeName || 'all');
+ toast.info(themeName ? `Updating ${themeName}...` : 'Updating all themes...', { duration: 4000 });
+ try {
+ const res = await wordpressApi.updateThemes(siteId, themeName ? [themeName] : undefined);
+ if (res.success === false) {
+ toast.error(res.error || 'Theme update failed');
+ return;
+ }
+ toast.success(res.message || 'Themes updated');
+ loadThemes();
+ } catch (err) {
+ toast.error(err.message || 'Theme update failed');
+ } finally {
+ setUpdating(null);
+ }
+ }
+
if (loading) {
return (
<div className="themes-tab">
@@ -1374,6 +1862,20 @@ const ThemesTab = ({ siteId }) => {
</Button>
</form>
+ {themes.some(t => t.update === 'available') && (
+ <div className="bulk-update-bar">
+ <span>{themes.filter(t => t.update === 'available').length} theme update(s) available</span>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => handleUpdate(null)}
+ disabled={updating !== null}
+ >
+ {updating === 'all' ? 'Updating...' : 'Update all'}
+ </Button>
+ </div>
+ )}
+
<div className="themes-list">
{themes.length === 0 ? (
<p className="hint">No themes found.</p>
@@ -1383,10 +1885,27 @@ const ThemesTab = ({ siteId }) => {
<div className="theme-info">
<span className="theme-name">{theme.title || theme.name}</span>
<span className="theme-version">{theme.version}</span>
+ {theme.update === 'available' && (
+ <span className="wp-update-badge">
+ Update{theme.update_version ? `: ${theme.update_version}` : ''}
+ </span>
+ )}
+ </div>
+ <div className="theme-actions">
+ {theme.update === 'available' && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => handleUpdate(theme.name)}
+ disabled={updating !== null}
+ >
+ {updating === theme.name ? 'Updating...' : 'Update'}
+ </Button>
+ )}
+ {theme.status === 'active' && (
+ <span className="active-badge">Active</span>
+ )}
</div>
- {theme.status === 'active' && (
- <span className="active-badge">Active</span>
- )}
</div>
))
)}
diff --git a/frontend/src/pages/WordPressProject.jsx b/frontend/src/pages/WordPressProject.jsx
index 59101532..e8b6e84b 100644
--- a/frontend/src/pages/WordPressProject.jsx
+++ b/frontend/src/pages/WordPressProject.jsx
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useCallback, useRef } from 'react';
import { useParams, useNavigate, Link } from 'react-router-dom';
-import { Plus, ExternalLink, RefreshCw, GitBranch, Search, Shield, Activity, Settings } from 'lucide-react';
+import { Plus, ExternalLink, RefreshCw, GitBranch, Search, Shield, Activity, Settings, ArrowRight, RotateCcw } from 'lucide-react';
import useTabParam from '../hooks/useTabParam';
import wordpressApi from '../services/wordpress';
import { useToast } from '../contexts/ToastContext';
@@ -210,6 +210,28 @@ const WordPressProject = () => {
});
}, [id, toast]);
+ const handleRollback = useCallback((promotion) => {
+ setConfirmDialog({
+ title: 'Roll Back Promotion',
+ message: `Restore the pre-promotion snapshot for "${promotion.target_site?.name || 'target environment'}"? This overwrites the target environment's current database with the snapshot taken just before promotion #${promotion.id}.`,
+ confirmText: 'Roll Back',
+ variant: 'danger',
+ onConfirm: async () => {
+ toast.info('Rolling back promotion...', { duration: 4000 });
+ try {
+ await wordpressApi.rollbackPromotion(id, promotion.id);
+ toast.success('Promotion rolled back');
+ loadPipeline();
+ } catch (err) {
+ toast.error(err.message || 'Rollback failed');
+ } finally {
+ setConfirmDialog(null);
+ }
+ },
+ onCancel: () => setConfirmDialog(null),
+ });
+ }, [id, toast]);
+
const handleRestart = useCallback(async (env) => {
try {
await wordpressApi.restartEnvironment(id, env.id);
@@ -560,6 +582,9 @@ const WordPressProject = () => {
onBulkToggle={handleBulkToggle}
/>
+ {/* Promotion History (with rollback) */}
+ <PromotionHistory projectId={id} onRollback={handleRollback} />
+
{/* Recent Activity Preview */}
<div className="pipeline-activity-preview">
<div className="section-header">
@@ -708,6 +733,65 @@ const WordPressProject = () => {
);
};
+// Promotion History (lists past promotions; rollback available for completed promotions with a pre-promotion snapshot)
+const PromotionHistory = ({ projectId, onRollback }) => {
+ const [promotions, setPromotions] = useState([]);
+ const [loading, setLoading] = useState(true);
+
+ const load = useCallback(async () => {
+ setLoading(true);
+ try {
+ const data = await wordpressApi.getPromotionHistory(projectId, { limit: 20 });
+ setPromotions(data.promotions || []);
+ } catch {
+ setPromotions([]);
+ } finally {
+ setLoading(false);
+ }
+ }, [projectId]);
+
+ useEffect(() => { load(); }, [load]);
+
+ if (loading || promotions.length === 0) {
+ return null;
+ }
+
+ return (
+ <div className="pipeline-promotion-history">
+ <div className="section-header">
+ <h3>Promotion History</h3>
+ <Button variant="ghost" size="sm" onClick={load}>
+ <RefreshCw size={14} /> Refresh
+ </Button>
+ </div>
+ <div className="promotion-history-list">
+ {promotions.map(p => {
+ const canRollback = p.status === 'completed' && !!p.pre_promotion_snapshot_id;
+ return (
+ <div key={p.id} className="promotion-history-item">
+ <div className="promotion-history-main">
+ <span className={`promotion-status promotion-status-${p.status}`}>{p.status}</span>
+ <span className="promotion-route">
+ {p.source_site?.name || `#${p.source_site_id}`} <ArrowRight size={12} /> {p.target_site?.name || `#${p.target_site_id}`}
+ </span>
+ <span className="promotion-type">{p.promotion_type}</span>
+ {p.created_at && (
+ <span className="promotion-date">{new Date(p.created_at).toLocaleString()}</span>
+ )}
+ </div>
+ {canRollback && (
+ <Button variant="outline" size="sm" onClick={() => onRollback(p)}>
+ <RotateCcw size={14} /> Rollback
+ </Button>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+};
+
// Create Environment Modal (Pipeline version)
const CreatePipelineEnvModal = ({ onClose, onCreate, productionDomain, existingTypes, projectId }) => {
const [formData, setFormData] = useState({
diff --git a/frontend/src/services/wordpress.js b/frontend/src/services/wordpress.js
index 24ff4dd4..7a8451d7 100644
--- a/frontend/src/services/wordpress.js
+++ b/frontend/src/services/wordpress.js
@@ -107,6 +107,21 @@ const wordpressApi = {
method: 'POST'
}),
+ // Live WP-CLI info (core version + update_available / latest_version)
+ getWordPressInfo: (siteId) => api.request(`${BASE_PATH}/${siteId}/info`),
+
+ // Update plugins. Pass an array of slugs to update specific ones, omit for all.
+ updatePlugins: (siteId, plugins) => api.request(`${BASE_PATH}/${siteId}/plugins/update`, {
+ method: 'POST',
+ body: plugins ? { plugins } : {}
+ }),
+
+ // Update themes. Pass an array of slugs to update specific ones, omit for all.
+ updateThemes: (siteId, themes) => api.request(`${BASE_PATH}/${siteId}/themes/update`, {
+ method: 'POST',
+ body: themes ? { themes } : {}
+ }),
+
// Maintenance & Security
flushCache: (siteId) => api.request(`${BASE_PATH}/${siteId}/flush-cache`, {
method: 'POST'
diff --git a/frontend/src/styles/components/_lists.scss b/frontend/src/styles/components/_lists.scss
index 93abfbbc..6a7e2ac2 100644
--- a/frontend/src/styles/components/_lists.scss
+++ b/frontend/src/styles/components/_lists.scss
@@ -118,6 +118,34 @@
font-size: $font-size-sm;
}
+.plugin-actions,
+.theme-actions {
+ @include flex-start();
+ gap: $space-2;
+}
+
+.wp-update-badge {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px $space-2;
+ margin-left: $space-2;
+ border-radius: $radius-sm;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-medium;
+ color: $warning;
+ background: fade($warning, 12%);
+ white-space: nowrap;
+}
+
+.bulk-update-bar {
+ @include flex-between();
+ padding: $space-3 $space-4;
+ margin-bottom: $space-3;
+ border-radius: $radius-md;
+ background: fade($warning, 8%);
+ font-size: $font-size-sm;
+}
+
// Backups list
.backups-list {
@include flex-column-gap($space-2);
diff --git a/frontend/src/styles/pages/_wordpress-pipeline.scss b/frontend/src/styles/pages/_wordpress-pipeline.scss
index 172a0cc6..4c74a598 100644
--- a/frontend/src/styles/pages/_wordpress-pipeline.scss
+++ b/frontend/src/styles/pages/_wordpress-pipeline.scss
@@ -2340,3 +2340,75 @@
flex-wrap: wrap;
}
}
+
+// ============================================
+// PROMOTION HISTORY (pipeline tab, with rollback)
+// ============================================
+.pipeline-promotion-history {
+ margin-top: $space-6;
+
+ .promotion-history-list {
+ display: flex;
+ flex-direction: column;
+ gap: $space-2;
+ margin-top: $space-3;
+ }
+
+ .promotion-history-item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: $space-3;
+ padding: $space-3 $space-4;
+ background: $bg-card;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ }
+
+ .promotion-history-main {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ flex-wrap: wrap;
+ font-size: $font-size-sm;
+ }
+
+ .promotion-route {
+ display: inline-flex;
+ align-items: center;
+ gap: $space-1;
+ color: $text-primary;
+ font-weight: $font-weight-medium;
+ }
+
+ .promotion-type,
+ .promotion-date {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ }
+
+ .promotion-status {
+ text-transform: capitalize;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-medium;
+ padding: 2px 8px;
+ border-radius: $radius-sm;
+ background: fade($color-info, 12%);
+ color: $color-info;
+
+ &.promotion-status-completed {
+ background: fade($color-success, 12%);
+ color: $color-success;
+ }
+
+ &.promotion-status-failed {
+ background: fade($color-danger, 12%);
+ color: $color-danger;
+ }
+
+ &.promotion-status-rolled_back {
+ background: fade($color-warning, 12%);
+ color: $color-warning;
+ }
+ }
+}
diff --git a/frontend/src/styles/pages/_wordpress.scss b/frontend/src/styles/pages/_wordpress.scss
index 9dcad5fe..0abe294f 100644
--- a/frontend/src/styles/pages/_wordpress.scss
+++ b/frontend/src/styles/pages/_wordpress.scss
@@ -1496,3 +1496,26 @@
}
}
}
+
+// ============================================
+// SITE HEALTH + SSL PANEL HELPERS (Overview tab)
+// ============================================
+
+.app-health-stat {
+ display: inline-flex;
+ align-items: center;
+ gap: $space-2;
+}
+
+.app-health-disk {
+ margin-top: $space-4;
+
+ .app-info-label {
+ display: block;
+ margin-bottom: $space-2;
+ }
+}
+
+.ssl-action-btn {
+ margin-top: $space-3;
+}