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
fix(ui): one download helper, and delete the dead wordpress client
Juan Denis375677ab0ccb
diff --git a/frontend/scripts/check-frontend-boundaries.mjs b/frontend/scripts/check-frontend-boundaries.mjsindex d2b9c9fb..20b4e6e9 100644--- a/frontend/scripts/check-frontend-boundaries.mjs+++ b/frontend/scripts/check-frontend-boundaries.mjs@@ -133,6 +133,16 @@ for (const path of files) {if (expected) seenPollers.add(file);}+ // Saving a file to disk belongs to utils/downloadBlob. The six-line anchor+ // ritual it replaces had been pasted into 14 components and had drifted:+ // only 3 appended the anchor to the document (Firefox does not reliably+ // click a detached one) and most revoked the object URL on the line after+ // click(), which races the download it just started. An `.download =`+ // assignment outside the helper is that ritual coming back.+ if (file !== 'utils/downloadBlob.js' && /\.\s*download\s*=/.test(source)) {+ failures.push(`${file}: use downloadBlob() instead of building a download anchor by hand.`);+ }+if (/(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(\s*['"`]/m.test(source)) {failures.push(`${file}: use useConfirm() instead of the browser confirm dialog.`);}diff --git a/frontend/src/components/EnvironmentVariables.jsx b/frontend/src/components/EnvironmentVariables.jsxindex e04435fb..d31897ed 100644--- a/frontend/src/components/EnvironmentVariables.jsx+++ b/frontend/src/components/EnvironmentVariables.jsx@@ -21,6 +21,7 @@ import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { useConfirm } from '@/hooks/useConfirm';import { useClipboard } from '@/hooks/useClipboard';+import { downloadBlob } from '@/utils/downloadBlob';// What a masked value renders as. Unchanged from the list this table replaces:// every env var is stored as a secret, so every value is dots until the row's@@ -245,15 +246,7 @@ const EnvironmentVariables = ({ appId }) => {async function handleExport(includeSecrets = true) {try {const data = await api.exportEnvFile(appId, includeSecrets);- const blob = new Blob([data.content], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = data.filename || 'app.env';- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(url);+ downloadBlob(data.content, data.filename || 'app.env');toast.success('Environment file exported');} catch (err) {toast.error('Failed to export');diff --git a/frontend/src/components/databases/ConsoleTab.jsx b/frontend/src/components/databases/ConsoleTab.jsxindex b2e34660..30b1dea8 100644--- a/frontend/src/components/databases/ConsoleTab.jsx+++ b/frontend/src/components/databases/ConsoleTab.jsx@@ -4,6 +4,7 @@ import { useToast } from '../../contexts/ToastContext';import { runQuery, connKey } from './dbAdapter';import ResultsGrid from './ResultsGrid';import SqlEditor from './SqlEditor';+import { downloadBlob } from '@/utils/downloadBlob';const HISTORY_KEY = 'serverkit_query_history';const MAX_HISTORY = 50;@@ -106,12 +107,7 @@ export default function ConsoleTab({ conn, tabId, active, isAdmin, initialQueryresults.columns.map(esc).join(','),...results.rows.map((r) => r.map(esc).join(',')),].join('\n');- const url = URL.createObjectURL(new Blob([csv], { type: 'text/csv' }));- const a = document.createElement('a');- a.href = url;- a.download = `${conn.name || 'query'}_${new Date().toISOString().slice(0, 10)}.csv`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(csv, `${conn.name || 'query'}_${new Date().toISOString().slice(0, 10)}.csv`, { type: 'text/csv' });toast.success('Exported results to CSV');}diff --git a/frontend/src/components/docker/ContainersTab.jsx b/frontend/src/components/docker/ContainersTab.jsxindex 4cdd0e9c..6be3ffdb 100644--- a/frontend/src/components/docker/ContainersTab.jsx+++ b/frontend/src/components/docker/ContainersTab.jsx@@ -40,6 +40,7 @@ import {} from './dockerHelpers';import { ContainerResourceBars } from './dockerShared';import { copyToClipboard } from '@/utils/clipboard';+import { downloadBlob } from '@/utils/downloadBlob';// Action Buttonsexport const RunContainerButton = () => {@@ -1260,13 +1261,7 @@ const ContainerLogsModal = ({ container, onClose }) => {function handleDownload() {if (!logs) return;- const blob = new Blob([logs], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `${container.name}-${Date.now()}.log`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(logs, `${container.name}-${Date.now()}.log`);}return (diff --git a/frontend/src/components/domains/DomainDnsPanel.jsx b/frontend/src/components/domains/DomainDnsPanel.jsxindex e4ef3159..861d2eb0 100644--- a/frontend/src/components/domains/DomainDnsPanel.jsx+++ b/frontend/src/components/domains/DomainDnsPanel.jsx@@ -17,6 +17,7 @@ import { Input } from '@/components/ui/input';import { FormField, FormRow } from '../FormField';import { DataTable, DataTableFooter } from '@/components/ds';import { useConfirm } from '@/hooks/useConfirm';+import { downloadBlob } from '@/utils/downloadBlob';import {Select, SelectTrigger, SelectContent, SelectItem, SelectValue,} from '@/components/ui/select';@@ -204,13 +205,7 @@ export default function DomainDnsPanel({ domain, isAdmin }) {try {const zid = await ensureZone();const data = await api.exportDNSZone(zid);- const blob = new Blob([data.zone_file || ''], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `${domain.name}.txt`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(data.zone_file || '', `${domain.name}.txt`);} catch (e) {toast.error(e.message || 'Export failed');} finally {diff --git a/frontend/src/components/ds/grid/fields.js b/frontend/src/components/ds/grid/fields.jsindex 9504b073..5257ebc2 100644--- a/frontend/src/components/ds/grid/fields.js+++ b/frontend/src/components/ds/grid/fields.js@@ -1,3 +1,5 @@+import { downloadBlob } from '@/utils/downloadBlob';+// DataGrid field model + filter-rule engine.//// A grid column is a superset of the legacy DataTable column descriptor, so a@@ -322,11 +324,6 @@ export function exportRows(rows, columns, format, filename) {mime = 'text/csv';ext = 'csv';}- const url = URL.createObjectURL(new Blob([body], { type: mime }));- const a = document.createElement('a');- a.href = url;- a.download = `${filename || 'export'}.${ext}`;- a.click();- setTimeout(() => URL.revokeObjectURL(url), 2000);+ downloadBlob(body, `${filename || 'export'}.${ext}`, { type: mime });return rows.length;}diff --git a/frontend/src/components/monitoring/FleetCapacityPanel.jsx b/frontend/src/components/monitoring/FleetCapacityPanel.jsxindex 34a9209b..e4807809 100644--- a/frontend/src/components/monitoring/FleetCapacityPanel.jsx+++ b/frontend/src/components/monitoring/FleetCapacityPanel.jsx@@ -9,6 +9,7 @@ import { useToast } from '../../contexts/ToastContext';import { Button } from '@/components/ui/button';import { DataTable, DataTableFooter, Pill } from '@/components/ds';import { CHART_COLORS, METRIC_LABELS } from './fleetMetrics';+import { downloadBlob } from '@/utils/downloadBlob';// The three fleet-wide questions that only make sense across servers: how do// these boxes compare, which one is behaving unlike itself, and when does a@@ -81,12 +82,7 @@ export default function FleetCapacityPanel({ scope, refreshKey = 0 }) {if (selectedServers.length === 0) return;try {const blob = await api.exportFleetCsv(selectedServers, compMetric, compPeriod);- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `fleet_${compMetric}_${compPeriod}.csv`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(blob, `fleet_${compMetric}_${compPeriod}.csv`);} catch {toast.error('Export failed');}diff --git a/frontend/src/components/serverdetail/ServicesTab.jsx b/frontend/src/components/serverdetail/ServicesTab.jsxindex 169a3620..a8bdfbad 100644--- a/frontend/src/components/serverdetail/ServicesTab.jsx+++ b/frontend/src/components/serverdetail/ServicesTab.jsx@@ -12,6 +12,7 @@ import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import LogToolbar from '../log-viewer/LogToolbar';import LogContent from '../log-viewer/LogContent';+import { downloadBlob } from '@/utils/downloadBlob';// Built-in saved views. These are the four buttons that used to sit in the// toolbar (All / Active / Failed / Inactive) — they narrowed the AGENT query@@ -277,12 +278,7 @@ const ServicesTab = ({ serverId = null, serverStatus = 'online' }) => {function downloadLogs() {if (!logText || !logsFor) return;- const url = URL.createObjectURL(new Blob([logText], { type: 'text/plain' }));- const a = document.createElement('a');- a.href = url;- a.download = `${logsFor.unit}-${Date.now()}.log`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(logText, `${logsFor.unit}-${Date.now()}.log`);}// Units table columns. Cell markup and classNames are identical to thediff --git a/frontend/src/components/service-detail/LogsTab.jsx b/frontend/src/components/service-detail/LogsTab.jsxindex 8ad25a54..37f678fa 100644--- a/frontend/src/components/service-detail/LogsTab.jsx+++ b/frontend/src/components/service-detail/LogsTab.jsx@@ -9,6 +9,7 @@ import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Switch } from '@/components/ui/switch';import { copyToClipboard } from '@/utils/clipboard';+import { downloadBlob } from '@/utils/downloadBlob';const LOG_LEVELS = ['all', 'error', 'warn', 'info', 'debug'];@@ -139,13 +140,7 @@ const LogsTab = ({ app }) => {}function handleDownload() {- const blob = new Blob([rawLogs], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `${app.name}-logs-${new Date().toISOString().slice(0, 10)}.txt`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(rawLogs, `${app.name}-logs-${new Date().toISOString().slice(0, 10)}.txt`);}function handleCopy() {diff --git a/frontend/src/components/service-detail/SettingsTab.jsx b/frontend/src/components/service-detail/SettingsTab.jsxindex 0e158fac..2089f201 100644--- a/frontend/src/components/service-detail/SettingsTab.jsx+++ b/frontend/src/components/service-detail/SettingsTab.jsx@@ -36,6 +36,7 @@ import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';+import { downloadBlob } from '@/utils/downloadBlob';// Grouped left sub-nav for the service Settings tab — mirrors the WordPress// detail page's settings layout: an uppercase mono group label per section with@@ -862,15 +863,7 @@ const ManifestSection = ({ app }) => {function handleDownloadScaffold() {if (!scaffold) return;- const blob = new Blob([scaffold], { type: 'text/yaml' });- const url = URL.createObjectURL(blob);- const link = document.createElement('a');- link.href = url;- link.download = 'serverkit.yaml';- document.body.appendChild(link);- link.click();- document.body.removeChild(link);- URL.revokeObjectURL(url);+ downloadBlob(scaffold, 'serverkit.yaml', { type: 'text/yaml' });}async function handlePlan() {diff --git a/frontend/src/components/settings/SecuritySettingsTab.jsx b/frontend/src/components/settings/SecuritySettingsTab.jsxindex 8e53cd82..82808c73 100644--- a/frontend/src/components/settings/SecuritySettingsTab.jsx+++ b/frontend/src/components/settings/SecuritySettingsTab.jsx@@ -10,6 +10,7 @@ import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Badge } from '@/components/ui/badge';import { copyToClipboard } from '@/utils/clipboard';+import { downloadBlob } from '@/utils/downloadBlob';const LinkedAccounts = ({ register }) => {const { ssoProviders } = useAuth();@@ -270,15 +271,7 @@ ${backupCodes.join('\n')}Keep these codes in a safe place.`;- const blob = new Blob([content], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = 'serverkit-backup-codes.txt';- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(url);+ downloadBlob(content, 'serverkit-backup-codes.txt');}function copyBackupCodes() {diff --git a/frontend/src/components/settings/ThemeStudioModal.jsx b/frontend/src/components/settings/ThemeStudioModal.jsxindex 8639717a..8ac352dd 100644--- a/frontend/src/components/settings/ThemeStudioModal.jsx+++ b/frontend/src/components/settings/ThemeStudioModal.jsx@@ -10,6 +10,7 @@ import { useToast } from '../../contexts/ToastContext';import { TOKEN_GROUPS, GROUP_LABELS, TOKEN_TYPE, sanitizeTokens } from '../../data/themeTokens';import { DEFAULT_THEME_SLUG, BUNDLED_THEME_MAP } from '../../data/bundledThemes';import api from '../../services/api';+import { downloadBlob } from '@/utils/downloadBlob';const REGISTRY_REPO = 'https://github.com/jhd3197/serverkit-themes';@@ -90,13 +91,7 @@ const ThemeStudioModal = ({ open, onOpenChange }) => {const setToken = (token, value) => setActiveTokens((prev) => ({ ...prev, [token]: value }));const download = () => {- const blob = new Blob([JSON.stringify(workingTheme, null, 2)], { type: 'application/json' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `${workingTheme.slug || 'theme'}.json`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(JSON.stringify(workingTheme, null, 2), `${workingTheme.slug || 'theme'}.json`, { type: 'application/json' });toast.success('theme.json downloaded');};diff --git a/frontend/src/components/setup/SetupStepSecurity.jsx b/frontend/src/components/setup/SetupStepSecurity.jsxindex 4ffd4534..de52ca83 100644--- a/frontend/src/components/setup/SetupStepSecurity.jsx+++ b/frontend/src/components/setup/SetupStepSecurity.jsx@@ -4,6 +4,7 @@ import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import api from '../../services/api';import { copyToClipboard } from '@/utils/clipboard';+import { downloadBlob } from '@/utils/downloadBlob';// Enrolment is a three-beat flow. Offer is the default so someone who just// wants a dashboard is one click from moving on — 2FA is offered here because@@ -88,12 +89,7 @@ const SetupStepSecurity = ({ onComplete }) => {...backupCodes,].join('\n');- const url = URL.createObjectURL(new Blob([body], { type: 'text/plain' }));- const link = document.createElement('a');- link.href = url;- link.download = 'serverkit-backup-codes.txt';- link.click();- URL.revokeObjectURL(url);+ downloadBlob(body, 'serverkit-backup-codes.txt');setSavedCodes(true);}diff --git a/frontend/src/pages/DeployConsole.jsx b/frontend/src/pages/DeployConsole.jsxindex 46f585f2..c5692d5a 100644--- a/frontend/src/pages/DeployConsole.jsx+++ b/frontend/src/pages/DeployConsole.jsx@@ -11,6 +11,7 @@ import ErrorCard from '../components/deploy-console/ErrorCard';import SuccessBanner from '../components/deploy-console/SuccessBanner';import { sourceRef } from '../utils/deployActivity';import { copyToClipboard } from '@/utils/clipboard';+import { downloadBlob } from '@/utils/downloadBlob';const STATUS_META = {pending: { label: 'Queued', icon: Clock, cls: 'pending' },@@ -198,13 +199,7 @@ export default function DeployConsole() {const ts = l.ts || l.created_at || '';return `${ts ? `[${ts}] ` : ''}${(l.level || 'info').toUpperCase()} ${l.message}`;}).join('\n');- const blob = new Blob([text], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `deploy-${jobId}.txt`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(text, `deploy-${jobId}.txt`);}, [lines, jobId]);const onStepClick = useCallback((index) => {diff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsxindex badab0ac..33350a12 100644--- a/frontend/src/pages/Terminal.jsx+++ b/frontend/src/pages/Terminal.jsx@@ -15,6 +15,7 @@ import ProcessTable, { procUser } from '../components/ProcessTable';import SystemdServicesTab from '../components/serverdetail/ServicesTab';import { useTableSort } from '@/hooks/useTableSort';import PageLayout from '../layouts/PageLayout';+import { downloadBlob } from '@/utils/downloadBlob';import {FileText, Clock, AlertCircle, Search, X, AlertTriangle, Activity,Terminal as TerminalIcon, Server as ServerIcon,@@ -310,13 +311,7 @@ const LogFilesTab = () => {function handleDownload() {if (!logContent) return;- const blob = new Blob([logContent], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = selectedLog ? selectedLog.split('/').pop() : 'log.txt';- a.click();- URL.revokeObjectURL(url);+ downloadBlob(logContent, selectedLog ? selectedLog.split('/').pop() : 'log.txt');}const visibleLineCount = useMemo(() => {@@ -568,13 +563,7 @@ const JournalTab = () => {function handleDownload() {if (!logContent) return;- const blob = new Blob([logContent], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `journal-${unit || 'all'}-${Date.now()}.log`;- a.click();- URL.revokeObjectURL(url);+ downloadBlob(logContent, `journal-${unit || 'all'}-${Date.now()}.log`);}function scrollToBottom() {diff --git a/frontend/src/services/wordpress.js b/frontend/src/services/wordpress.jsdeleted file mode 100644index df1a5ecc..00000000--- a/frontend/src/services/wordpress.js+++ /dev/null@@ -1,494 +0,0 @@-import api from './api';--const BASE_PATH = '/wordpress/sites';--const wordpressApi = {- // Site Management- getSites: () => api.request(BASE_PATH),-- createSite: (data) => api.request(BASE_PATH, {- method: 'POST',- body: data- }),-- // Base domains a new site can be published under (<slug>.<base>), for the- // create-flow picker. Returns { base_domains: [...], default }.- listBaseDomains: () => api.request('/domains/base-domains'),-- // Import an existing WP site from an uploaded SQL dump, plus an optional- // wp-content/full-site .zip (plugins/themes/uploads). Multipart upload.- importSite: ({ name, adminEmail, oldUrl, sqlFile, wpContentFile }) => {- const fd = new FormData();- fd.append('name', name);- fd.append('adminEmail', adminEmail || '');- fd.append('oldUrl', oldUrl);- fd.append('sql', sqlFile);- if (wpContentFile) fd.append('wp_content', wpContentFile);- return api.request(`${BASE_PATH}/import`, { method: 'POST', body: fd });- },-- // Clone a site into a new independent top-level site (fresh admin creds returned once).- cloneSite: (id, data) => api.request(`${BASE_PATH}/${id}/clone`, {- method: 'POST',- body: data- }),-- getSite: (id) => api.request(`${BASE_PATH}/${id}`),-- // Preview a site URL change (dry-run: per-pair DB replacement counts, no mutation).- previewUrlChange: (id, newUrl) => api.request(`${BASE_PATH}/${id}/url/preview`, {- method: 'POST',- body: { new_url: newUrl }- }),-- // Change a site's URL: backup + serialization-safe DB rewrite + re-point routing.- changeUrl: (id, newUrl, keepOldRedirect = true) => api.request(`${BASE_PATH}/${id}/url`, {- method: 'POST',- body: { new_url: newUrl, keep_old_redirect: keepOldRedirect }- }),-- // Attach a custom domain: auto-create DNS (or return the record to add) +- // optional HTTPS, then migrate the site to it.- attachDomain: (id, { domain, migrate = true, issueSsl = false, email } = {}) =>- api.request(`${BASE_PATH}/${id}/domain`, {- method: 'POST',- body: { domain, migrate, issue_ssl: issueSsl, email }- }),-- // Replace the tag list for a site (agency organization labels)- setTags: (id, tags) => api.request(`${BASE_PATH}/${id}/tags`, {- method: 'PATCH',- body: { tags }- }),-- // Deletes the site and all environments. A final files+DB backup is taken- // by default (pass { createBackup: false } to skip).- deleteSite: (id, { createBackup = true } = {}) => api.request(- `${BASE_PATH}/${id}?create_backup=${createBackup}`,- { method: 'DELETE' }- ),-- // Stop the stack but keep data + files (reversible via unarchiveSite).- archiveSite: (id) => api.request(`${BASE_PATH}/${id}/archive`, {- method: 'POST'- }),-- unarchiveSite: (id) => api.request(`${BASE_PATH}/${id}/unarchive`, {- method: 'POST'- }),-- // Environment Management- getEnvironments: (siteId) => api.request(`${BASE_PATH}/${siteId}/environments`),-- createEnvironment: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/environments`, {- method: 'POST',- body: data- }),-- deleteEnvironment: (siteId, envId) => api.request(`${BASE_PATH}/${siteId}/environments/${envId}`, {- method: 'DELETE'- }),-- syncEnvironment: (siteId, data = {}) => api.request(`${BASE_PATH}/${siteId}/sync`, {- method: 'POST',- body: data- }),-- // Database Snapshots- getSnapshots: (siteId) => api.request(`${BASE_PATH}/${siteId}/snapshots`),-- createSnapshot: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/snapshots`, {- method: 'POST',- body: data- }),-- restoreSnapshot: (siteId, snapId) => api.request(`${BASE_PATH}/${siteId}/snapshots/${snapId}/restore`, {- method: 'POST'- }),-- deleteSnapshot: (siteId, snapId) => api.request(`${BASE_PATH}/${siteId}/snapshots/${snapId}`, {- method: 'DELETE'- }),-- // Git Integration- getGitStatus: (siteId) => api.request(`${BASE_PATH}/${siteId}/git`),-- connectRepo: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/git`, {- method: 'POST',- body: data- }),-- disconnectRepo: (siteId) => api.request(`${BASE_PATH}/${siteId}/git`, {- method: 'DELETE'- }),-- getCommits: (siteId, limit = 20) => api.request(`${BASE_PATH}/${siteId}/git/commits?limit=${limit}`),-- deployCommit: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/git/deploy`, {- method: 'POST',- body: data- }),-- createDevFromCommit: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/git/dev-from-commit`, {- method: 'POST',- body: data- }),-- // Plugins- getPlugins: (siteId) => api.request(`${BASE_PATH}/${siteId}/plugins`),-- installPlugin: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/plugins`, {- method: 'POST',- body: data- }),-- // Activate / deactivate an installed plugin (WP-CLI).- activatePlugin: (siteId, plugin) => api.request(`${BASE_PATH}/${siteId}/plugins/${encodeURIComponent(plugin)}/activate`, {- method: 'POST'- }),-- deactivatePlugin: (siteId, plugin) => api.request(`${BASE_PATH}/${siteId}/plugins/${encodeURIComponent(plugin)}/deactivate`, {- method: 'POST'- }),-- // =========================================- // Global Plugin Library- // =========================================- LIBRARY_PATH: '/wordpress/plugins/library',-- getLibraryPlugins: () => api.request('/wordpress/plugins/library'),-- getLibraryPlugin: (id) => api.request(`/wordpress/plugins/library/${id}`),-- addLibraryPlugin: (data) => api.request('/wordpress/plugins/library', {- method: 'POST',- body: data- }),-- updateLibraryPlugin: (id, data) => api.request(`/wordpress/plugins/library/${id}`, {- method: 'PUT',- body: data- }),-- deleteLibraryPlugin: (id) => api.request(`/wordpress/plugins/library/${id}`, {- method: 'DELETE'- }),-- syncLibraryPlugin: (id) => api.request(`/wordpress/plugins/library/${id}/sync`, {- method: 'POST'- }),-- // Install/update a library plugin on a specific site.- installLibraryPluginOnSite: (id, siteId, activate = true) =>- api.request(`/wordpress/plugins/library/${id}/install`, {- method: 'POST',- body: { site_id: siteId, activate }- }),-- uninstallLibraryPluginFromSite: (id, siteId) =>- api.request(`/wordpress/plugins/library/${id}/uninstall`, {- method: 'POST',- body: { site_id: siteId }- }),-- // Push the latest cached version to every site that has the plugin.- bulkUpdateLibraryPlugin: (id) => api.request(`/wordpress/plugins/library/${id}/bulk-update`, {- method: 'POST'- }),-- // Per-site: which installed plugins are library-managed (+ update state).- getManagedPlugins: (siteId) => api.request(`${BASE_PATH}/${siteId}/plugins/managed`),-- scanManagedPlugins: (siteId) => api.request(`${BASE_PATH}/${siteId}/plugins/library-scan`, {- method: 'POST'- }),-- // Themes- getThemes: (siteId) => api.request(`${BASE_PATH}/${siteId}/themes`),-- installTheme: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/themes`, {- method: 'POST',- body: data- }),-- // Activate an installed theme (WP-CLI).- activateTheme: (siteId, theme) => api.request(`${BASE_PATH}/${siteId}/themes/${encodeURIComponent(theme)}/activate`, {- method: 'POST'- }),-- // WordPress Core Update- updateCore: (siteId) => api.request(`${BASE_PATH}/${siteId}/update`, {- method: 'POST'- }),-- // Live WP-CLI info (core version + update_available / latest_version)- getWordPressInfo: (siteId) => api.request(`${BASE_PATH}/${siteId}/info`),-- // Live PHP version + ini limits for a Docker WP site (read-only).- getPhpInfo: (siteId) => api.request(`${BASE_PATH}/${siteId}/php`),-- // Switch the site's PHP version (swaps the Docker image tag + recreates the container).- setPhpVersion: (siteId, version) => api.request(`${BASE_PATH}/${siteId}/php`, {- method: 'POST',- body: { version }- }),-- // Durably set per-site PHP ini limits (conf.d drop-in + bind-mount; #24).- setPhpLimits: (siteId, limits) => api.request(`${BASE_PATH}/${siteId}/php/limits`, {- method: 'POST',- body: { limits }- }),-- // 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'- }),-- // Full-page cache (plugin-backed) — status / enable / disable- getPageCache: (siteId) => api.request(`${BASE_PATH}/${siteId}/page-cache`),- enablePageCache: (siteId) => api.request(`${BASE_PATH}/${siteId}/page-cache`, { method: 'POST' }),- disablePageCache: (siteId) => api.request(`${BASE_PATH}/${siteId}/page-cache`, { method: 'DELETE' }),-- searchReplace: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/search-replace`, {- method: 'POST',- body: data- }),-- harden: (siteId) => api.request(`${BASE_PATH}/${siteId}/harden`, {- method: 'POST'- }),-- // Object cache (Redis) — status / enable / disable- getObjectCacheStatus: (siteId) => api.request(`${BASE_PATH}/${siteId}/object-cache`),- enableObjectCache: (siteId) => api.request(`${BASE_PATH}/${siteId}/object-cache`, { method: 'POST' }),- disableObjectCache: (siteId) => api.request(`${BASE_PATH}/${siteId}/object-cache`, { method: 'DELETE' }),-- // Status-page binding + uptime (#26): live health, bound component + uptime %, attach/detach- getSiteStatusPage: (siteId) => api.request(`${BASE_PATH}/${siteId}/status-page`),- attachStatusPage: (siteId, pageId) => api.request(`${BASE_PATH}/${siteId}/status-page`, { method: 'POST', body: { page_id: pageId } }),- detachStatusPage: (siteId) => api.request(`${BASE_PATH}/${siteId}/status-page`, { method: 'DELETE' }),-- // Traffic + error analytics (#25) — parsed on-demand from the apache access log.- getSiteAnalytics: (siteId, hours = 24) => api.request(`${BASE_PATH}/${siteId}/analytics?hours=${hours}`),-- // Vulnerability scanning (#28) — plugin/theme/core vs the WPVulnerability feed.- getVulnerabilities: (siteId) => api.request(`${BASE_PATH}/${siteId}/vulnerabilities`),- scanVulnerabilities: (siteId) => api.request(`${BASE_PATH}/${siteId}/vulnerabilities/scan`, { method: 'POST' }),-- // Safe update manager (#29): run history, on-demand safe update, schedule- getUpdates: (siteId) => api.request(`${BASE_PATH}/${siteId}/updates`),- runUpdates: (siteId, body = {}) => api.request(`${BASE_PATH}/${siteId}/updates/run`, { method: 'POST', body }),- setUpdateSchedule: (siteId, body) => api.request(`${BASE_PATH}/${siteId}/updates/schedule`, { method: 'POST', body }),-- // Security depth (#30): file integrity / debug toggle / WP-Cron- getIntegrity: (siteId) => api.request(`${BASE_PATH}/${siteId}/integrity`),- scanIntegrity: (siteId) => api.request(`${BASE_PATH}/${siteId}/integrity/scan`, { method: 'POST' }),- getDebug: (siteId) => api.request(`${BASE_PATH}/${siteId}/debug`),- setDebug: (siteId, enabled) => api.request(`${BASE_PATH}/${siteId}/debug`, { method: 'POST', body: { enabled } }),- getCron: (siteId) => api.request(`${BASE_PATH}/${siteId}/cron`),- runCron: (siteId) => api.request(`${BASE_PATH}/${siteId}/cron/run`, { method: 'POST' }),- setCronDisabled: (siteId, disabled) => api.request(`${BASE_PATH}/${siteId}/cron`, { method: 'POST', body: { disabled } }),-- // Per-site brute-force protection: a WP-login Fail2ban jail watching the- // site's reverse-proxy access log.- getBruteForce: (siteId) => api.request(`${BASE_PATH}/${siteId}/security/bruteforce`),- setBruteForce: (siteId, enabled) => api.request(`${BASE_PATH}/${siteId}/security/bruteforce`, { method: 'POST', body: { enabled } }),- unbanBruteForceIp: (siteId, ip) => api.request(`${BASE_PATH}/${siteId}/security/bruteforce/unban`, { method: 'POST', body: { ip } }),-- // Monthly client reports (#33): persisted per-month uptime/updates/backups/vuln rollups- getReports: (siteId) => api.request(`${BASE_PATH}/${siteId}/reports`),- generateReport: (siteId, body = {}) => api.request(`${BASE_PATH}/${siteId}/reports/generate`, { method: 'POST', body }),- deleteReport: (siteId, reportId) => api.request(`${BASE_PATH}/${siteId}/reports/${reportId}`, { method: 'DELETE' }),-- // Mint a one-time passwordless wp-admin login URL for the current operator.- autoLogin: (siteId) => api.request(`${BASE_PATH}/${siteId}/login`, {- method: 'POST'- }),-- // Clone Database (for advanced use)- cloneDatabase: (siteId, data) => api.request(`${BASE_PATH}/${siteId}/clone-db`, {- method: 'POST',- body: data- }),-- // =========================================- // Pipeline API (Environment Management v2)- // =========================================- PIPELINE_PATH: '/wordpress/projects',-- // Pipeline listing. "Pipelines" is the user-facing term (§2); getProjects- // is kept as a back-compat alias. Both hit the canonical backend route,- // which is also mounted at /wordpress/pipelines.- getPipelines: () => api.request('/wordpress/projects'),- getProjects: () => api.request('/wordpress/projects'),-- // Pipeline dashboard- getProjectPipeline: (prodId) => api.request(`/wordpress/projects/${prodId}/pipeline`),-- // Environment CRUD- createProjectEnvironment: (prodId, data) => api.request(`/wordpress/projects/${prodId}/environments`, {- method: 'POST',- body: data- }),-- getProjectEnvironment: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}`),-- deleteProjectEnvironment: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}`, {- method: 'DELETE'- }),-- // Container lifecycle- startEnvironment: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/start`, {- method: 'POST'- }),-- stopEnvironment: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/stop`, {- method: 'POST'- }),-- restartEnvironment: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/restart`, {- method: 'POST'- }),-- // Promotion- promoteEnvironment: (prodId, data) => api.request(`/wordpress/projects/${prodId}/promote`, {- method: 'POST',- body: data- }),-- // Sync from production- syncProjectEnvironment: (prodId, envId, data) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/sync`, {- method: 'POST',- body: data- }),-- // Compare environments- compareEnvironments: (prodId, envAId, envBId) =>- api.request(`/wordpress/projects/${prodId}/compare?env_a=${envAId}&env_b=${envBId}`),-- // Locking- lockEnvironment: (prodId, envId, data) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/lock`, {- method: 'POST',- body: data- }),-- unlockEnvironment: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/lock`, {- method: 'DELETE'- }),-- // Activity log- getProjectActivity: (prodId, params = {}) => {- const query = new URLSearchParams(params).toString();- return api.request(`/wordpress/projects/${prodId}/activity${query ? `?${query}` : ''}`);- },-- // Container logs- getEnvironmentLogs: (prodId, envId, params = {}) => {- const query = new URLSearchParams(params).toString();- return api.request(`/wordpress/projects/${prodId}/environments/${envId}/logs${query ? `?${query}` : ''}`);- },-- // Promotion history- getPromotionHistory: (prodId, params = {}) => {- const query = new URLSearchParams(params).toString();- return api.request(`/wordpress/projects/${prodId}/promotions${query ? `?${query}` : ''}`);- },-- // Restore a promotion's pre-promotion snapshot into its target environment- rollbackPromotion: (prodId, promotionId) => api.request(- `/wordpress/projects/${prodId}/promotions/${promotionId}/rollback`,- { method: 'POST' }- ),-- // Git branches (for multidev)- getBranches: (prodId) => api.request(`/wordpress/projects/${prodId}/git/branches`),-- // Multidev cleanup- cleanupMultidevs: (prodId, dryRun = true) => api.request(`/wordpress/projects/${prodId}/multidev/cleanup`, {- method: 'POST',- body: { dry_run: dryRun }- }),-- // Sanitization Profiles- getSanitizationProfiles: () => api.request('/wordpress/projects/sanitization-profiles'),-- createSanitizationProfile: (data) => api.request('/wordpress/projects/sanitization-profiles', {- method: 'POST',- body: data- }),-- updateSanitizationProfile: (profileId, data) => api.request(`/wordpress/projects/sanitization-profiles/${profileId}`, {- method: 'PUT',- body: data- }),-- deleteSanitizationProfile: (profileId) => api.request(`/wordpress/projects/sanitization-profiles/${profileId}`, {- method: 'DELETE'- }),-- // =========================================- // Phase 7: Advanced Features- // =========================================-- // Resource Limits- updateResourceLimits: (prodId, envId, limits) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/resources`, {- method: 'PUT',- body: limits- }),-- // Basic Auth- enableBasicAuth: (prodId, envId, data = {}) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/auth`, {- method: 'POST',- body: data- }),-- disableBasicAuth: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/auth`, {- method: 'DELETE'- }),-- getBasicAuthStatus: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/auth`),-- // WP-CLI- executeWpCli: (prodId, envId, command) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/exec`, {- method: 'POST',- body: { command }- }),-- // Health- getEnvironmentHealth: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/health`),-- getProjectHealth: (prodId) => api.request(`/wordpress/projects/${prodId}/health`),-- // Disk Usage- getEnvironmentDiskUsage: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/disk-usage`),-- getProjectDiskUsage: (prodId) => api.request(`/wordpress/projects/${prodId}/disk-usage`),-- // Bulk Operations- executeBulkOperation: (prodId, operations) => api.request(`/wordpress/projects/${prodId}/bulk`, {- method: 'POST',- body: { operations }- }),-- // Auto-Sync- getAutoSyncSchedule: (prodId, envId) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/auto-sync`),-- updateAutoSyncSchedule: (prodId, envId, config) => api.request(`/wordpress/projects/${prodId}/environments/${envId}/auto-sync`, {- method: 'PUT',- body: config- })-};--export default wordpressApi;diff --git a/frontend/src/utils/downloadBlob.js b/frontend/src/utils/downloadBlob.jsnew file mode 100644index 00000000..07472145--- /dev/null+++ b/frontend/src/utils/downloadBlob.js@@ -0,0 +1,47 @@+// Canonical "save this to the user's disk" helper.+//+// downloadBlob(logText, 'app-logs.txt');+// downloadBlob(JSON.stringify(theme, null, 2), 'theme.json', { type: 'application/json' });+// downloadBlob(pngBlob, 'chart.png');+//+// The six-line anchor ritual this replaces was pasted into 14 components, and+// the copies had drifted apart in two ways that decide whether the download+// actually happens:+//+// * only 3 of 14 appended the anchor to the document. Chrome dispatches a+// click on a detached anchor; Firefox has not always done so, which makes+// "download does nothing" a browser-specific bug that never reproduces for+// whoever wrote it.+// * most revoked the object URL on the very next line after click(). The+// download is started asynchronously, so revoking immediately can cancel+// it — again browser- and timing-dependent, so it shows up as a flaky+// "sometimes the file is empty / never appears".+//+// Revoking is not optional either: an un-revoked object URL pins its blob in+// memory for the lifetime of the document, which on a long-lived panel page+// that exports repeatedly is a leak.+export function downloadBlob(content, filename, options = {}) {+ const { type = 'text/plain' } = options;++ if (typeof document === 'undefined') return false;++ const blob = content instanceof Blob ? content : new Blob([content ?? ''], { type });+ const url = URL.createObjectURL(blob);+ const anchor = document.createElement('a');+ anchor.href = url;+ anchor.download = filename;+ anchor.rel = 'noopener';+ anchor.style.display = 'none';++ // In the document, because a detached anchor is not reliably clickable.+ document.body.appendChild(anchor);+ anchor.click();+ document.body.removeChild(anchor);++ // On a later task, so the browser has actually picked the blob up. Revoking+ // synchronously after click() races the download it just started.+ setTimeout(() => URL.revokeObjectURL(url), 0);+ return true;+}++export default downloadBlob;