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.

refactor(frontend): Phase 3 §6.1 — migrate ~37 hand-rolled modals to shared Modal

Juan Denisf3fd9c5e76fd
diff --git a/frontend/src/components/deployments/ConfigDiffModal.jsx b/frontend/src/components/deployments/ConfigDiffModal.jsx
index 1f520c14..7b036558 100644
--- a/frontend/src/components/deployments/ConfigDiffModal.jsx
+++ b/frontend/src/components/deployments/ConfigDiffModal.jsx
@@ -1,6 +1,7 @@
import { useState, useEffect } from 'react';
-import { RotateCcw, X, Info } from 'lucide-react';
+import { RotateCcw, Info } from 'lucide-react';
import api from '../../services/api';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { useToast } from '../../contexts/ToastContext';
@@ -114,19 +115,8 @@ const ConfigDiffModal = ({ appId, snapId, against = 'previous', onClose, onResto
}
return (
- <div className="modal-overlay" onClick={onClose}>
- <div
- className="modal config-diff"
- onClick={(e) => e.stopPropagation()}
- >
- <div className="modal-header">
- <h2>Configuration diff</h2>
- <button className="modal-close" onClick={onClose} aria-label="Close">
- <X size={18} />
- </button>
- </div>
-
- <div className="config-diff__body">
+ <Modal open onClose={onClose} title="Configuration diff" size="xl" className="config-diff">
+ <div className="config-diff__body">
{loading && <p className="config-diff__loading">Loading diff…</p>}
{error && <div className="alert alert-danger">{error}</div>}
@@ -210,8 +200,7 @@ const ConfigDiffModal = ({ appId, snapId, against = 'previous', onClose, onResto
</>
)}
</div>
- </div>
- </div>
+ </Modal>
);
};
diff --git a/frontend/src/components/service-detail/SettingsTab.jsx b/frontend/src/components/service-detail/SettingsTab.jsx
index 0e6ff309..9b104867 100644
--- a/frontend/src/components/service-detail/SettingsTab.jsx
+++ b/frontend/src/components/service-detail/SettingsTab.jsx
@@ -17,6 +17,7 @@ import { useToast } from '../../contexts/ToastContext';
import { DangerZone } from '../DangerZone';
import RepoConnectForm from '../git/RepoConnectForm';
import ProtectionPanel from '../backups/ProtectionPanel';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -583,13 +584,13 @@ const DomainSslPanel = ({ app, domains, primaryDomain, onUpdate }) => {
</div>
)}
- {subdomainModal && (
- <div className="modal-overlay" onClick={() => setSubdomainModal(null)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Give it a subdomain</h2>
- <button className="modal-close" onClick={() => setSubdomainModal(null)}>&times;</button>
- </div>
+ <Modal
+ open={!!subdomainModal}
+ onClose={() => setSubdomainModal(null)}
+ title="Give it a subdomain"
+ >
+ {subdomainModal && (
+ <>
<div className="modal-body">
<p className="hint">
Publish <strong>{app.name}</strong> at a managed subdomain of{' '}
@@ -620,9 +621,9 @@ const DomainSslPanel = ({ app, domains, primaryDomain, onUpdate }) => {
{publishing ? 'Publishing…' : 'Publish'}
</Button>
</div>
- </div>
- </div>
- )}
+ </>
+ )}
+ </Modal>
</div>
);
};
diff --git a/frontend/src/components/wordpress/AttachDomainModal.jsx b/frontend/src/components/wordpress/AttachDomainModal.jsx
index 6345dc49..9e34b417 100644
--- a/frontend/src/components/wordpress/AttachDomainModal.jsx
+++ b/frontend/src/components/wordpress/AttachDomainModal.jsx
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { Globe, AlertTriangle, CheckCircle2 } from 'lucide-react';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -45,92 +46,85 @@ export default function AttachDomainModal({ site, onClose, onChanged }) {
const rec = result?.dns?.record;
return (
- <div className="modal-overlay" onClick={() => !attaching && onClose()}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2><Globe size={18} /> Add Custom Domain</h2>
- <button className="modal-close" onClick={() => !attaching && onClose()}>&times;</button>
- </div>
+ <Modal open onClose={() => !attaching && onClose()} title={<><Globe size={18} /> Add Custom Domain</>}>
+ {!result ? (
+ <form onSubmit={handleAttach}>
+ <div className="wp-url-swap">
+ <div className="wp-url-swap__warning">
+ <AlertTriangle size={18} aria-hidden="true" />
+ <span>
+ Points a domain you own at this site. If a connected DNS provider
+ manages it, the A record is created automatically — otherwise
+ you&apos;ll get the exact record to add. The site URL is then
+ migrated to the domain (serialization-safe).
+ </span>
+ </div>
- {!result ? (
- <form onSubmit={handleAttach}>
- <div className="wp-url-swap">
- <div className="wp-url-swap__warning">
- <AlertTriangle size={18} aria-hidden="true" />
- <span>
- Points a domain you own at this site. If a connected DNS provider
- manages it, the A record is created automatically — otherwise
- you&apos;ll get the exact record to add. The site URL is then
- migrated to the domain (serialization-safe).
- </span>
- </div>
+ <div className="form-group">
+ <Label htmlFor="wp-domain">Domain</Label>
+ <Input
+ id="wp-domain"
+ type="text"
+ value={domain}
+ onChange={(e) => setDomain(e.target.value)}
+ placeholder="example.com"
+ disabled={attaching}
+ autoFocus
+ />
+ <span className="form-hint">A domain or subdomain you control, without http://</span>
+ </div>
- <div className="form-group">
- <Label htmlFor="wp-domain">Domain</Label>
- <Input
- id="wp-domain"
- type="text"
- value={domain}
- onChange={(e) => setDomain(e.target.value)}
- placeholder="example.com"
- disabled={attaching}
- autoFocus
- />
- <span className="form-hint">A domain or subdomain you control, without http://</span>
- </div>
+ <label className="wp-url-swap__keep">
+ <Switch checked={issueSsl} onCheckedChange={setIssueSsl} disabled={attaching} />
+ <span>
+ Set up HTTPS now
+ <small>Requests a Let&apos;s Encrypt certificate. Needs DNS to already resolve to this server.</small>
+ </span>
+ </label>
+ </div>
- <label className="wp-url-swap__keep">
- <Switch checked={issueSsl} onCheckedChange={setIssueSsl} disabled={attaching} />
- <span>
- Set up HTTPS now
- <small>Requests a Let&apos;s Encrypt certificate. Needs DNS to already resolve to this server.</small>
- </span>
- </label>
+ <div className="modal-actions">
+ <Button type="button" variant="outline" onClick={onClose} disabled={attaching}>Cancel</Button>
+ <Button type="submit" disabled={!valid || attaching}>
+ {attaching ? 'Attaching…' : 'Attach Domain'}
+ </Button>
+ </div>
+ </form>
+ ) : (
+ <>
+ <div className="wp-url-swap">
+ <div className="wp-url-swap__result">
+ <CheckCircle2 size={18} aria-hidden="true" />
+ <span>Site is now at <code>{result.url}</code></span>
</div>
- <div className="modal-actions">
- <Button type="button" variant="outline" onClick={onClose} disabled={attaching}>Cancel</Button>
- <Button type="submit" disabled={!valid || attaching}>
- {attaching ? 'Attaching…' : 'Attach Domain'}
- </Button>
- </div>
- </form>
- ) : (
- <>
- <div className="wp-url-swap">
- <div className="wp-url-swap__result">
- <CheckCircle2 size={18} aria-hidden="true" />
- <span>Site is now at <code>{result.url}</code></span>
+ {result.dns?.created ? (
+ <div className="form-hint">
+ DNS A record created automatically via {result.dns.provider}
+ {result.dns.zone ? ` (zone ${result.dns.zone})` : ''}.
</div>
+ ) : (
+ <div className="wp-url-swap__dns-manual">
+ <strong>Add this DNS record to finish:</strong>
+ {rec?.value ? (
+ <code className="wp-url-swap__record">
+ {rec.type}&nbsp;&nbsp;{rec.name}&nbsp;→&nbsp;{rec.value}
+ </code>
+ ) : (
+ <div className="form-hint">{result.dns?.message}</div>
+ )}
+ </div>
+ )}
- {result.dns?.created ? (
- <div className="form-hint">
- DNS A record created automatically via {result.dns.provider}
- {result.dns.zone ? ` (zone ${result.dns.zone})` : ''}.
- </div>
- ) : (
- <div className="wp-url-swap__dns-manual">
- <strong>Add this DNS record to finish:</strong>
- {rec?.value ? (
- <code className="wp-url-swap__record">
- {rec.type}&nbsp;&nbsp;{rec.name}&nbsp;→&nbsp;{rec.value}
- </code>
- ) : (
- <div className="form-hint">{result.dns?.message}</div>
- )}
- </div>
- )}
-
- {result.warning && (
- <div className="wp-url-swap__preview-error">{result.warning}</div>
- )}
- </div>
- <div className="modal-actions">
- <Button type="button" onClick={onClose}>Done</Button>
- </div>
- </>
- )}
- </div>
- </div>
+ {result.warning && (
+ <div className="wp-url-swap__preview-error">{result.warning}</div>
+ )}
+ </div>
+ <div className="modal-actions">
+ <Button type="button" onClick={onClose}>Done</Button>
+ </div>
+ </>
+ )}
+ </Modal>
);
}
diff --git a/frontend/src/components/wordpress/ChangeUrlModal.jsx b/frontend/src/components/wordpress/ChangeUrlModal.jsx
index b9faae6e..94d35c90 100644
--- a/frontend/src/components/wordpress/ChangeUrlModal.jsx
+++ b/frontend/src/components/wordpress/ChangeUrlModal.jsx
@@ -1,5 +1,6 @@
import { useState, useEffect } from 'react';
import { Globe, AlertTriangle, ArrowRight } from 'lucide-react';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -63,89 +64,83 @@ export default function ChangeUrlModal({ site, onClose, onChanged }) {
}
return (
- <div className="modal-overlay" onClick={() => !applying && onClose()}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2><Globe size={18} /> Change Site URL</h2>
- <button className="modal-close" onClick={() => !applying && onClose()}>&times;</button>
- </div>
- <form onSubmit={handleApply}>
- <div className="wp-url-swap">
- <div className="wp-url-swap__warning">
- <AlertTriangle size={18} aria-hidden="true" />
- <span>
- This rewrites every reference to the site URL across the database
- (posts, options, serialized data) with a serialization-safe
- search-replace. A database backup is taken first and restored
- automatically if anything fails.
- </span>
- </div>
+ <Modal open onClose={() => !applying && onClose()} title={<><Globe size={18} /> Change Site URL</>} size="lg">
+ <form onSubmit={handleApply}>
+ <div className="wp-url-swap">
+ <div className="wp-url-swap__warning">
+ <AlertTriangle size={18} aria-hidden="true" />
+ <span>
+ This rewrites every reference to the site URL across the database
+ (posts, options, serialized data) with a serialization-safe
+ search-replace. A database backup is taken first and restored
+ automatically if anything fails.
+ </span>
+ </div>
- <div className="wp-url-swap__fromto">
- <code>{currentUrl || '—'}</code>
- <ArrowRight size={15} aria-hidden="true" />
- <code className={dirty ? 'is-new' : ''}>{target || '—'}</code>
- </div>
+ <div className="wp-url-swap__fromto">
+ <code>{currentUrl || '—'}</code>
+ <ArrowRight size={15} aria-hidden="true" />
+ <code className={dirty ? 'is-new' : ''}>{target || '—'}</code>
+ </div>
- <div className="form-group">
- <Label htmlFor="wp-new-url">New URL</Label>
- <Input
- id="wp-new-url"
- type="text"
- value={newUrl}
- onChange={(e) => setNewUrl(e.target.value)}
- placeholder="https://example.com"
- disabled={applying}
- autoFocus
- />
- <span className="form-hint">
- Include http:// or https://. Point this hostname&apos;s DNS at the server first.
- </span>
- </div>
+ <div className="form-group">
+ <Label htmlFor="wp-new-url">New URL</Label>
+ <Input
+ id="wp-new-url"
+ type="text"
+ value={newUrl}
+ onChange={(e) => setNewUrl(e.target.value)}
+ placeholder="https://example.com"
+ disabled={applying}
+ autoFocus
+ />
+ <span className="form-hint">
+ Include http:// or https://. Point this hostname&apos;s DNS at the server first.
+ </span>
+ </div>
- <label className="wp-url-swap__keep">
- <Switch checked={keepOld} onCheckedChange={setKeepOld} disabled={applying} />
- <span>
- Keep the old address working
- <small>The previous host keeps resolving; WordPress 301-redirects it to the new URL.</small>
- </span>
- </label>
+ <label className="wp-url-swap__keep">
+ <Switch checked={keepOld} onCheckedChange={setKeepOld} disabled={applying} />
+ <span>
+ Keep the old address working
+ <small>The previous host keeps resolving; WordPress 301-redirects it to the new URL.</small>
+ </span>
+ </label>
- {dirty && (
- <div className="wp-url-swap__preview">
- {previewing && <span className="form-hint">Previewing changes…</span>}
- {!previewing && preview?.success && (
- <>
- <div className="wp-url-swap__preview-total">
- {preview.total} database replacement{preview.total === 1 ? '' : 's'} will be made
- </div>
- <ul className="wp-url-swap__preview-pairs">
- {preview.pairs.map((p, i) => (
- <li key={i}>
- <code>{p.search}</code>
- <ArrowRight size={12} aria-hidden="true" />
- <code>{p.replace}</code>
- <span className="wp-url-swap__count">{p.replacements}</span>
- </li>
- ))}
- </ul>
- </>
- )}
- {!previewing && preview && !preview.success && (
- <div className="wp-url-swap__preview-error">{preview.error}</div>
- )}
- </div>
- )}
- </div>
+ {dirty && (
+ <div className="wp-url-swap__preview">
+ {previewing && <span className="form-hint">Previewing changes…</span>}
+ {!previewing && preview?.success && (
+ <>
+ <div className="wp-url-swap__preview-total">
+ {preview.total} database replacement{preview.total === 1 ? '' : 's'} will be made
+ </div>
+ <ul className="wp-url-swap__preview-pairs">
+ {preview.pairs.map((p, i) => (
+ <li key={i}>
+ <code>{p.search}</code>
+ <ArrowRight size={12} aria-hidden="true" />
+ <code>{p.replace}</code>
+ <span className="wp-url-swap__count">{p.replacements}</span>
+ </li>
+ ))}
+ </ul>
+ </>
+ )}
+ {!previewing && preview && !preview.success && (
+ <div className="wp-url-swap__preview-error">{preview.error}</div>
+ )}
+ </div>
+ )}
+ </div>
- <div className="modal-actions">
- <Button type="button" variant="outline" onClick={onClose} disabled={applying}>Cancel</Button>
- <Button type="submit" disabled={!dirty || applying}>
- {applying ? 'Changing…' : 'Change URL'}
- </Button>
- </div>
- </form>
- </div>
- </div>
+ <div className="modal-actions">
+ <Button type="button" variant="outline" onClick={onClose} disabled={applying}>Cancel</Button>
+ <Button type="submit" disabled={!dirty || applying}>
+ {applying ? 'Changing…' : 'Change URL'}
+ </Button>
+ </div>
+ </form>
+ </Modal>
);
}
diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsx
index 4461af05..3ef8d7b0 100644
--- a/frontend/src/pages/Backups.jsx
+++ b/frontend/src/pages/Backups.jsx
@@ -6,6 +6,7 @@ import { formatBytes } from '@/utils/formatBytes';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { FormField, FormRow } from '../components/FormField';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -973,15 +974,8 @@ const Backups = () => {
)}
{/* Create Backup Modal */}
- {showBackupModal && (
- <div className="modal-overlay" onClick={() => setShowBackupModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create Backup</h2>
- <button className="modal-close" onClick={() => setShowBackupModal(false)}>&times;</button>
- </div>
+ <Modal open={showBackupModal} onClose={() => setShowBackupModal(false)} title="Create Backup">
<form onSubmit={handleCreateBackup}>
- <div className="modal-body">
<div className="form-group">
<label>Backup Type</label>
<select
@@ -1101,28 +1095,18 @@ const Backups = () => {
</div>
</>
)}
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button type="button" variant="outline" onClick={() => setShowBackupModal(false)}>
Cancel
</Button>
<Button type="submit">Create Backup</Button>
</div>
</form>
- </div>
- </div>
- )}
+ </Modal>
{/* Add Schedule Modal */}
- {showScheduleModal && (
- <div className="modal-overlay" onClick={() => setShowScheduleModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Add Backup Schedule</h2>
- <button className="modal-close" onClick={() => setShowScheduleModal(false)}>&times;</button>
- </div>
+ <Modal open={showScheduleModal} onClose={() => setShowScheduleModal(false)} title="Add Backup Schedule">
<form onSubmit={handleAddSchedule}>
- <div className="modal-body">
<div className="form-group">
<label>Schedule Name</label>
<Input
@@ -1192,27 +1176,18 @@ const Backups = () => {
</label>
</div>
)}
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button type="button" variant="outline" onClick={() => setShowScheduleModal(false)}>
Cancel
</Button>
<Button type="submit">Add Schedule</Button>
</div>
</form>
- </div>
- </div>
- )}
+ </Modal>
{/* Restore Modal */}
- {showRestoreModal && selectedBackup && (
- <div className="modal-overlay" onClick={() => setShowRestoreModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Restore Backup</h2>
- <button className="modal-close" onClick={() => setShowRestoreModal(false)}>&times;</button>
- </div>
- <div className="modal-body">
+ <Modal open={showRestoreModal && !!selectedBackup} onClose={() => setShowRestoreModal(false)} title="Restore Backup">
+ {selectedBackup && (<>
<div className="bk-restore-warn">
<AlertTriangle size={18} />
<span><b>Warning:</b> restoring this backup will overwrite existing data. This action cannot be undone.</span>
@@ -1235,8 +1210,8 @@ const Backups = () => {
<span className="v">{formatBytes(selectedBackup.size, { defaultValue: '0 B' })}</span>
</div>
</div>
- </div>
- <div className="modal-footer">
+ </>)}
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowRestoreModal(false)}>
Cancel
</Button>
@@ -1244,9 +1219,7 @@ const Backups = () => {
Restore Backup
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
</div>
);
};
diff --git a/frontend/src/pages/CloudProvision.jsx b/frontend/src/pages/CloudProvision.jsx
index 4425a228..70569c6b 100644
--- a/frontend/src/pages/CloudProvision.jsx
+++ b/frontend/src/pages/CloudProvision.jsx
@@ -6,6 +6,7 @@ import { useAuth } from '../contexts/AuthContext';
import PageLoader from '../components/PageLoader';
import ConfirmDialog from '../components/ConfirmDialog';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Badge } from '@/components/ui/badge';
@@ -189,46 +190,44 @@ const CloudProvision = () => {
</TabsContent>
</Tabs>
- {showCreateProvider && (
- <div className="modal-overlay" onClick={() => setShowCreateProvider(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header"><h2>Add Cloud Provider</h2><button className="modal-close" onClick={() => setShowCreateProvider(false)}>&times;</button></div>
- <div className="modal-body">
- <div className="form-group"><label>Provider</label><select className="form-select" value={providerForm.provider_type} onChange={e => setProviderForm({...providerForm, provider_type: e.target.value})}>{Object.entries(providerTypes).map(([k,v]) => <option key={k} value={k}>{v}</option>)}</select></div>
- <div className="form-group"><label>Name</label><Input value={providerForm.name} onChange={e => setProviderForm({...providerForm, name: e.target.value})} /></div>
- <div className="form-group"><label>API Key</label><Input type="password" value={providerForm.api_key} onChange={e => setProviderForm({...providerForm, api_key: e.target.value})} /></div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreateProvider(false)}>Cancel</Button>
- <Button onClick={handleCreateProvider}>Add</Button>
- </div>
- </div>
- </div>
- )}
-
- {showCreateServer && (
- <div className="modal-overlay" onClick={() => setShowCreateServer(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header"><h2>New Cloud Server</h2><button className="modal-close" onClick={() => setShowCreateServer(false)}>&times;</button></div>
- <div className="modal-body">
- <div className="form-group"><label>Provider</label><select className="form-select" value={serverForm.provider_id} onChange={e => { setServerForm({...serverForm, provider_id: parseInt(e.target.value)}); const p = providers.find(x => x.id === parseInt(e.target.value)); if (p) loadProviderOptions(p.provider_type); }}><option value="">Select provider</option>{providers.map(p => <option key={p.id} value={p.id}>{p.name}</option>)}</select></div>
- <div className="form-group"><label>Server Name</label><Input value={serverForm.name} onChange={e => setServerForm({...serverForm, name: e.target.value})} /></div>
- {providerOptions && (
- <>
- <div className="form-group"><label>Region</label><select className="form-select" value={serverForm.region} onChange={e => setServerForm({...serverForm, region: e.target.value})}><option value="">Select region</option>{(providerOptions.regions || []).map(r => <option key={r} value={r}>{r}</option>)}</select></div>
- <div className="form-group"><label>Size</label><select className="form-select" value={serverForm.size} onChange={e => setServerForm({...serverForm, size: e.target.value})}><option value="">Select size</option>{(providerOptions.sizes || []).map(s => <option key={s} value={s}>{s}</option>)}</select></div>
- <div className="form-group"><label>Image</label><select className="form-select" value={serverForm.image} onChange={e => setServerForm({...serverForm, image: e.target.value})}><option value="">Select image</option>{(providerOptions.images || []).map(i => <option key={i} value={i}>{i}</option>)}</select></div>
- </>
- )}
- <div className="form-group"><label className="checkbox-label"><input type="checkbox" checked={serverForm.install_agent} onChange={e => setServerForm({...serverForm, install_agent: e.target.checked})} /> Auto-install ServerKit agent</label></div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreateServer(false)}>Cancel</Button>
- <Button onClick={handleCreateServer} disabled={!serverForm.name || !serverForm.provider_id}>Create</Button>
- </div>
- </div>
- </div>
- )}
+ <Modal
+ open={showCreateProvider}
+ onClose={() => setShowCreateProvider(false)}
+ title="Add Cloud Provider"
+ footer={(
+ <>
+ <Button variant="outline" onClick={() => setShowCreateProvider(false)}>Cancel</Button>
+ <Button onClick={handleCreateProvider}>Add</Button>
+ </>
+ )}
+ >
+ <div className="form-group"><label>Provider</label><select className="form-select" value={providerForm.provider_type} onChange={e => setProviderForm({...providerForm, provider_type: e.target.value})}>{Object.entries(providerTypes).map(([k,v]) => <option key={k} value={k}>{v}</option>)}</select></div>
+ <div className="form-group"><label>Name</label><Input value={providerForm.name} onChange={e => setProviderForm({...providerForm, name: e.target.value})} /></div>
+ <div className="form-group"><label>API Key</label><Input type="password" value={providerForm.api_key} onChange={e => setProviderForm({...providerForm, api_key: e.target.value})} /></div>
+ </Modal>
+
+ <Modal
+ open={showCreateServer}
+ onClose={() => setShowCreateServer(false)}
+ title="New Cloud Server"
+ footer={(
+ <>
+ <Button variant="outline" onClick={() => setShowCreateServer(false)}>Cancel</Button>
+ <Button onClick={handleCreateServer} disabled={!serverForm.name || !serverForm.provider_id}>Create</Button>
+ </>
+ )}
+ >
+ <div className="form-group"><label>Provider</label><select className="form-select" value={serverForm.provider_id} onChange={e => { setServerForm({...serverForm, provider_id: parseInt(e.target.value)}); const p = providers.find(x => x.id === parseInt(e.target.value)); if (p) loadProviderOptions(p.provider_type); }}><option value="">Select provider</option>{providers.map(p => <option key={p.id} value={p.id}>{p.name}</option>)}</select></div>
+ <div className="form-group"><label>Server Name</label><Input value={serverForm.name} onChange={e => setServerForm({...serverForm, name: e.target.value})} /></div>
+ {providerOptions && (
+ <>
+ <div className="form-group"><label>Region</label><select className="form-select" value={serverForm.region} onChange={e => setServerForm({...serverForm, region: e.target.value})}><option value="">Select region</option>{(providerOptions.regions || []).map(r => <option key={r} value={r}>{r}</option>)}</select></div>
+ <div className="form-group"><label>Size</label><select className="form-select" value={serverForm.size} onChange={e => setServerForm({...serverForm, size: e.target.value})}><option value="">Select size</option>{(providerOptions.sizes || []).map(s => <option key={s} value={s}>{s}</option>)}</select></div>
+ <div className="form-group"><label>Image</label><select className="form-select" value={serverForm.image} onChange={e => setServerForm({...serverForm, image: e.target.value})}><option value="">Select image</option>{(providerOptions.images || []).map(i => <option key={i} value={i}>{i}</option>)}</select></div>
+ </>
+ )}
+ <div className="form-group"><label className="checkbox-label"><input type="checkbox" checked={serverForm.install_agent} onChange={e => setServerForm({...serverForm, install_agent: e.target.checked})} /> Auto-install ServerKit agent</label></div>
+ </Modal>
{deleteConfirm && (
<ConfirmDialog title="Destroy Server" message={`Destroy "${deleteConfirm.name}"? This action is irreversible.`} onConfirm={() => handleDestroy(deleteConfirm.id)} onCancel={() => setDeleteConfirm(null)} variant="danger" />
diff --git a/frontend/src/pages/CronJobs.jsx b/frontend/src/pages/CronJobs.jsx
index 1b6645fc..48c2b5d4 100644
--- a/frontend/src/pages/CronJobs.jsx
+++ b/frontend/src/pages/CronJobs.jsx
@@ -3,6 +3,7 @@ import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import {
Clock, CheckCircle, Monitor, Activity, Plus, RefreshCw,
Play, Pause, Pencil, Trash2, Search,
@@ -396,15 +397,8 @@ const CronJobs = () => {
)}
{/* Create/Edit Job Modal */}
- {showJobModal && (
- <div className="modal-overlay" onClick={closeJobModal}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>{editingJob ? 'Edit Cron Job' : 'Create Cron Job'}</h2>
- <button className="modal-close" onClick={closeJobModal}>&times;</button>
- </div>
+ <Modal open={showJobModal} onClose={closeJobModal} title={editingJob ? 'Edit Cron Job' : 'Create Cron Job'}>
<form onSubmit={handleSubmitJob}>
- <div className="modal-body">
<div className="form-group">
<Label htmlFor="job-name">Job Name</Label>
<Input
@@ -482,8 +476,7 @@ const CronJobs = () => {
rows={2}
/>
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button type="button" variant="outline" onClick={closeJobModal}>
Cancel
</Button>
@@ -492,19 +485,11 @@ const CronJobs = () => {
</Button>
</div>
</form>
- </div>
- </div>
- )}
+ </Modal>
{/* Run Output Modal */}
- {runOutput && (
- <div className="modal-overlay" onClick={() => setRunOutput(null)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Run Output: {runOutput.jobName}</h2>
- <button className="modal-close" onClick={() => setRunOutput(null)}>&times;</button>
- </div>
- <div className="modal-body">
+ <Modal open={!!runOutput} onClose={() => setRunOutput(null)} title={runOutput ? `Run Output: ${runOutput.jobName}` : ''}>
+ {runOutput && (
<div className="run-output">
<div className="run-output-exit">
<span className="run-output-label">Exit Code</span>
@@ -528,13 +513,11 @@ const CronJobs = () => {
<p className="text-muted">No output produced.</p>
)}
</div>
- </div>
- <div className="modal-footer">
+ )}
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setRunOutput(null)}>Close</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
</div>
);
};
diff --git a/frontend/src/pages/Email.jsx b/frontend/src/pages/Email.jsx
index be602e26..03ff7d67 100644
--- a/frontend/src/pages/Email.jsx
+++ b/frontend/src/pages/Email.jsx
@@ -6,6 +6,7 @@ import { useToast } from '../contexts/ToastContext';
import Spinner from '../components/Spinner';
import EmptyState from '../components/EmptyState';
import ConfirmDialog from '../components/ConfirmDialog';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
@@ -721,21 +722,16 @@ function Email() {
)}
</>
)}
- {showPasswordModal && (
- <div className="modal-overlay" onClick={() => setShowPasswordModal(null)}>
- <div className="modal-content" onClick={e => e.stopPropagation()}>
- <h3>Change Password</h3>
- <div className="form-group">
- <label>New Password</label>
- <Input type="password" value={newPassword} onChange={e => setNewPassword(e.target.value)} />
- </div>
- <div className="form-actions">
- <Button size="sm" variant="outline" onClick={() => setShowPasswordModal(null)}>Cancel</Button>
- <Button size="sm" onClick={handleChangePassword} disabled={actionLoading || !newPassword}>Change</Button>
- </div>
- </div>
+ <Modal open={!!showPasswordModal} onClose={() => setShowPasswordModal(null)} title="Change Password">
+ <div className="form-group">
+ <label>New Password</label>
+ <Input type="password" value={newPassword} onChange={e => setNewPassword(e.target.value)} />
</div>
- )}
+ <div className="form-actions">
+ <Button size="sm" variant="outline" onClick={() => setShowPasswordModal(null)}>Cancel</Button>
+ <Button size="sm" onClick={handleChangePassword} disabled={actionLoading || !newPassword}>Change</Button>
+ </div>
+ </Modal>
</div>
</TabsContent>
diff --git a/frontend/src/pages/FTPServer.jsx b/frontend/src/pages/FTPServer.jsx
index 6b1f9ac4..fb9b2de3 100644
--- a/frontend/src/pages/FTPServer.jsx
+++ b/frontend/src/pages/FTPServer.jsx
@@ -11,6 +11,7 @@ import { useToast } from '../contexts/ToastContext';
import Spinner from '../components/Spinner';
import EmptyState from '../components/EmptyState';
import ConfirmDialog from '../components/ConfirmDialog';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -569,16 +570,7 @@ function FTPServer() {
)}
{/* Install Modal */}
- {showInstallModal && (
- <div className="modal-overlay" onClick={() => setShowInstallModal(false)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Install FTP Server</h2>
- <button className="btn btn-icon" onClick={() => setShowInstallModal(false)}>
- <X size={16} />
- </button>
- </div>
- <div className="modal-body">
+ <Modal open={showInstallModal} onClose={() => setShowInstallModal(false)} title="Install FTP Server">
<div className="form-group">
<Label>Select FTP Server</Label>
<select
@@ -602,8 +594,7 @@ function FTPServer() {
</p>
)}
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowInstallModal(false)}>
Cancel
</Button>
@@ -614,21 +605,10 @@ function FTPServer() {
{actionLoading ? 'Installing...' : 'Install'}
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{/* Create User Modal */}
- {showUserModal && (
- <div className="modal-overlay" onClick={() => setShowUserModal(false)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create FTP User</h2>
- <button className="btn btn-icon" onClick={() => setShowUserModal(false)}>
- <X size={16} />
- </button>
- </div>
- <div className="modal-body">
+ <Modal open={showUserModal} onClose={() => setShowUserModal(false)} title="Create FTP User">
<div className="form-group">
<Label>Username *</Label>
<Input
@@ -656,8 +636,7 @@ function FTPServer() {
placeholder="/home/ftp/username"
/>
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowUserModal(false)}>
Cancel
</Button>
@@ -668,21 +647,10 @@ function FTPServer() {
{actionLoading ? 'Creating...' : 'Create User'}
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{/* Change Password Modal */}
- {showPasswordModal && (
- <div className="modal-overlay" onClick={() => setShowPasswordModal(false)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Change Password</h2>
- <button className="btn btn-icon" onClick={() => setShowPasswordModal(false)}>
- <X size={16} />
- </button>
- </div>
- <div className="modal-body">
+ <Modal open={showPasswordModal} onClose={() => setShowPasswordModal(false)} title="Change Password">
<p>Changing password for user: <strong>{passwordTarget}</strong></p>
<div className="form-group">
<Label>New Password (leave empty to auto-generate)</Label>
@@ -693,8 +661,7 @@ function FTPServer() {
placeholder="Auto-generated if empty"
/>
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowPasswordModal(false)}>
Cancel
</Button>
@@ -705,9 +672,7 @@ function FTPServer() {
{actionLoading ? 'Changing...' : 'Change Password'}
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{/* Confirm Dialog */}
{confirmDialog && (
diff --git a/frontend/src/pages/FileManager.jsx b/frontend/src/pages/FileManager.jsx
index a0e9aeba..fa967a56 100644
--- a/frontend/src/pages/FileManager.jsx
+++ b/frontend/src/pages/FileManager.jsx
@@ -3,6 +3,7 @@ import { api } from '../services/api';
import { useToast } from '../contexts/ToastContext';
import ConfirmDialog from '../components/ConfirmDialog';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import {
Folder, FolderOpen, File, Upload, FolderPlus,
ArrowLeft, ArrowRight, ArrowUp, Search, X, RefreshCw, Eye, EyeOff,
@@ -1291,14 +1292,7 @@ function FileManager() {
/>
{/* Modals */}
- {showNewFileModal && (
- <div className="modal-overlay" onClick={() => setShowNewFileModal(false)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create New File</h2>
- <Button variant="ghost" size="icon" onClick={() => setShowNewFileModal(false)}><X size={20} /></Button>
- </div>
- <div className="modal-body">
+ <Modal open={showNewFileModal} onClose={() => setShowNewFileModal(false)} title="Create New File">
<div className="form-group">
<Label>File Name</Label>
<Input
@@ -1311,23 +1305,13 @@ function FileManager() {
/>
</div>
<p className="text-muted">Will be created in: <code>{currentPath}</code></p>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowNewFileModal(false)}>Cancel</Button>
<Button onClick={handleCreateFile}>Create File</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
- {showNewFolderModal && (
- <div className="modal-overlay" onClick={() => setShowNewFolderModal(false)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create New Folder</h2>
- <Button variant="ghost" size="icon" onClick={() => setShowNewFolderModal(false)}><X size={20} /></Button>
- </div>
- <div className="modal-body">
+ <Modal open={showNewFolderModal} onClose={() => setShowNewFolderModal(false)} title="Create New Folder">
<div className="form-group">
<Label>Folder Name</Label>
<Input
@@ -1340,23 +1324,13 @@ function FileManager() {
/>
</div>
<p className="text-muted">Will be created in: <code>{currentPath}</code></p>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowNewFolderModal(false)}>Cancel</Button>
<Button onClick={handleCreateFolder}>Create Folder</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
- {showRenameModal && (
- <div className="modal-overlay" onClick={() => setShowRenameModal(false)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Rename {renameTarget?.is_dir ? 'Folder' : 'File'}</h2>
- <Button variant="ghost" size="icon" onClick={() => setShowRenameModal(false)}><X size={20} /></Button>
- </div>
- <div className="modal-body">
+ <Modal open={showRenameModal} onClose={() => setShowRenameModal(false)} title={`Rename ${renameTarget?.is_dir ? 'Folder' : 'File'}`}>
<div className="form-group">
<Label>New Name</Label>
<Input
@@ -1367,23 +1341,13 @@ function FileManager() {
onKeyDown={(e) => e.key === 'Enter' && handleRename()}
/>
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowRenameModal(false)}>Cancel</Button>
<Button onClick={handleRename}>Rename</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
- {showPermissionsModal && (
- <div className="modal-overlay" onClick={() => setShowPermissionsModal(false)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Change Permissions</h2>
- <Button variant="ghost" size="icon" onClick={() => setShowPermissionsModal(false)}><X size={20} /></Button>
- </div>
- <div className="modal-body">
+ <Modal open={showPermissionsModal} onClose={() => setShowPermissionsModal(false)} title="Change Permissions">
<div className="form-group">
<Label>Permissions (Octal)</Label>
<Input
@@ -1404,14 +1368,11 @@ function FileManager() {
<li><code>600</code> Owner: rw only (private files)</li>
</ul>
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowPermissionsModal(false)}>Cancel</Button>
<Button onClick={handleChangePermissions}>Apply</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{confirmDialog && (
<ConfirmDialog
diff --git a/frontend/src/pages/Git.jsx b/frontend/src/pages/Git.jsx
index 52186c37..00d8ce94 100644
--- a/frontend/src/pages/Git.jsx
+++ b/frontend/src/pages/Git.jsx
@@ -6,10 +6,11 @@ import Spinner from '../components/Spinner';
import ConfirmDialog from '../components/ConfirmDialog';
import { DangerZone } from '../components/DangerZone';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { Pill, MetricCard, PageTopbar, SegControl, Drawer } from '../components/ds';
import {
AlertCircle, FolderGit2, Webhook, Rocket, Server, Globe, Terminal, Tag,
- X, GitBranch, RefreshCw, Plus, ExternalLink, Lock, Trash2, ChevronRight,
+ GitBranch, RefreshCw, Plus, ExternalLink, Lock, Trash2, ChevronRight,
Clock, AlertTriangle, Settings,
} from 'lucide-react';
import { Button } from '@/components/ui/button';
@@ -1354,14 +1355,7 @@ function Git({ basePath = '/git' }) {
</Drawer>
{/* Install Modal */}
- {showInstallModal && (
- <div className="modal-overlay" onClick={() => setShowInstallModal(false)}>
- <div className="modal modal-lg" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Install Git Server</h2>
- <button className="btn btn-icon" onClick={() => setShowInstallModal(false)}><X size={18} /></button>
- </div>
- <div className="modal-body">
+ <Modal open={showInstallModal} onClose={() => setShowInstallModal(false)} title="Install Git Server" size="lg">
<div className="install-warning">
<AlertTriangle size={20} />
<div>
@@ -1384,26 +1378,16 @@ function Git({ basePath = '/git' }) {
<Label>Admin Password (leave empty to auto-generate)</Label>
<Input type="password" value={installForm.adminPassword} onChange={(e) => setInstallForm({ ...installForm, adminPassword: e.target.value })} placeholder="Auto-generate secure password" />
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowInstallModal(false)}>Cancel</Button>
<Button onClick={handleInstall} disabled={actionLoading || !installForm.adminEmail}>
{actionLoading ? 'Installing...' : 'Install Git Server'}
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{/* Webhook Modal */}
- {showWebhookModal && (
- <div className="modal-overlay" onClick={() => setShowWebhookModal(false)}>
- <div className="modal modal-lg" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Add Webhook</h2>
- <button className="btn btn-icon" onClick={() => setShowWebhookModal(false)}><X size={18} /></button>
- </div>
- <div className="modal-body">
+ <Modal open={showWebhookModal} onClose={() => setShowWebhookModal(false)} title="Add Webhook" size="lg">
<div className="form-group">
<Label>Name <span className="required">*</span></Label>
<Input type="text" value={webhookForm.name} onChange={(e) => setWebhookForm({ ...webhookForm, name: e.target.value })} placeholder="My GitHub Repo" />
@@ -1480,26 +1464,16 @@ function Git({ basePath = '/git' }) {
</>
)}
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowWebhookModal(false)}>Cancel</Button>
<Button onClick={handleCreateWebhook} disabled={actionLoading || !webhookForm.name || !webhookForm.sourceRepoUrl}>
{actionLoading ? 'Creating...' : 'Create Webhook'}
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{/* Webhook Secret Modal */}
- {webhookSecret && (
- <div className="modal-overlay" onClick={() => setWebhookSecret(null)}>
- <div className="modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Webhook Secret</h2>
- <button className="btn btn-icon" onClick={() => setWebhookSecret(null)}><X size={18} /></button>
- </div>
- <div className="modal-body">
+ <Modal open={!!webhookSecret} onClose={() => setWebhookSecret(null)} title="Webhook Secret">
<div className="secret-warning">
<AlertTriangle size={20} />
<span>Save this secret! It will not be shown again.</span>
@@ -1509,23 +1483,19 @@ function Git({ basePath = '/git' }) {
<Button size="sm" variant="outline" onClick={() => { navigator.clipboard.writeText(webhookSecret); toast.success('Secret copied'); }}>Copy</Button>
</div>
<p className="text-muted">Use this secret when configuring the webhook in your repository settings.</p>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button onClick={() => setWebhookSecret(null)}>I&apos;ve Saved It</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{/* Deployment Logs Modal */}
- {showDeploymentLogs && selectedDeployment && (
- <div className="modal-overlay" onClick={() => setShowDeploymentLogs(false)}>
- <div className="modal modal-xl" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Deployment v{selectedDeployment.version} Logs</h2>
- <button className="btn btn-icon" onClick={() => setShowDeploymentLogs(false)}><X size={18} /></button>
- </div>
- <div className="modal-body">
+ <Modal
+ open={showDeploymentLogs && !!selectedDeployment}
+ onClose={() => setShowDeploymentLogs(false)}
+ title={selectedDeployment ? `Deployment v${selectedDeployment.version} Logs` : ''}
+ size="xl"
+ >
+ {selectedDeployment && (<>
<div className="deployment-summary">
<div className="summary-item"><span className="label">Status:</span><Pill kind={getStatusColor(selectedDeployment.status)}>{selectedDeployment.status}</Pill></div>
{selectedDeployment.commit_sha && <div className="summary-item"><span className="label">Commit:</span><code className="git-hash">{selectedDeployment.commit_sha.slice(0, 7)}</code></div>}
@@ -1538,13 +1508,11 @@ function Git({ basePath = '/git' }) {
{selectedDeployment.deploy_output && <div className="log-section"><h4>Deployment Output</h4><pre className="log-output">{selectedDeployment.deploy_output}</pre></div>}
{selectedDeployment.post_script_output && <div className="log-section"><h4>Post-deployment Script Output</h4><pre className="log-output">{selectedDeployment.post_script_output}</pre></div>}
{!selectedDeployment.pre_script_output && !selectedDeployment.deploy_output && !selectedDeployment.post_script_output && <div className="no-logs"><p>No deployment logs available.</p></div>}
- </div>
- <div className="modal-footer">
+ </>)}
+ <div className="modal-actions">
<Button variant="outline" onClick={() => setShowDeploymentLogs(false)}>Close</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{confirmDialog && (
<ConfirmDialog
diff --git a/frontend/src/pages/QueueDetail.jsx b/frontend/src/pages/QueueDetail.jsx
index a03979c6..e1f8a1e3 100644
--- a/frontend/src/pages/QueueDetail.jsx
+++ b/frontend/src/pages/QueueDetail.jsx
@@ -13,6 +13,7 @@ import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
import { Input } from '@/components/ui/input';
@@ -314,15 +315,8 @@ const QueueDetail = () => {
)}
</div>
- {showSend && !viewOnly && (
- <div className="modal-overlay" onClick={() => setShowSend(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Send Message</h2>
- <button className="modal-close" onClick={() => setShowSend(false)}>&times;</button>
- </div>
+ <Modal open={showSend && !viewOnly} onClose={() => setShowSend(false)} title="Send Message">
<form onSubmit={handleSend}>
- <div className="modal-body">
<div className="form-group">
<Label htmlFor="payload">Payload (JSON)</Label>
<Textarea id="payload" value={sendForm.payload} onChange={(e) => setSendForm({ ...sendForm, payload: e.target.value })} rows={6} required />
@@ -337,15 +331,12 @@ const QueueDetail = () => {
<Input id="delay_ms" type="number" value={sendForm.delay_ms} onChange={(e) => setSendForm({ ...sendForm, delay_ms: e.target.value })} />
</div>
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button type="button" variant="outline" onClick={() => setShowSend(false)}>Cancel</Button>
<Button type="submit"><Send size={14} className="mr-2" /> Send</Button>
</div>
</form>
- </div>
- </div>
- )}
+ </Modal>
</div>
);
};
diff --git a/frontend/src/pages/QueueOperations.jsx b/frontend/src/pages/QueueOperations.jsx
index bfee692d..e1eb02d4 100644
--- a/frontend/src/pages/QueueOperations.jsx
+++ b/frontend/src/pages/QueueOperations.jsx
@@ -17,6 +17,7 @@ import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -503,15 +504,8 @@ const QueueOperations = () => {
</div>
{/* Create Group Modal */}
- {showGroupModal && (
- <div className="modal-overlay" onClick={() => setShowGroupModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create Queue Group</h2>
- <button className="modal-close" onClick={() => setShowGroupModal(false)}>&times;</button>
- </div>
+ <Modal open={showGroupModal} onClose={() => setShowGroupModal(false)} title="Create Queue Group">
<form onSubmit={handleCreateGroup}>
- <div className="modal-body">
<div className="form-group">
<Label htmlFor="group-name">Name</Label>
<Input id="group-name" value={groupForm.name} onChange={(e) => setGroupForm({ ...groupForm, name: e.target.value })} required />
@@ -520,26 +514,16 @@ const QueueOperations = () => {
<Label htmlFor="group-description">Description</Label>
<Input id="group-description" value={groupForm.description} onChange={(e) => setGroupForm({ ...groupForm, description: e.target.value })} />
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button type="button" variant="outline" onClick={() => setShowGroupModal(false)}>Cancel</Button>
<Button type="submit">Create Group</Button>
</div>
</form>
- </div>
- </div>
- )}
+ </Modal>
{/* Create Queue Modal */}
- {showQueueModal && (
- <div className="modal-overlay" onClick={() => setShowQueueModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create Queue</h2>
- <button className="modal-close" onClick={() => setShowQueueModal(false)}>&times;</button>
- </div>
+ <Modal open={showQueueModal} onClose={() => setShowQueueModal(false)} title="Create Queue">
<form onSubmit={handleCreateQueue}>
- <div className="modal-body">
<div className="form-group">
<Label htmlFor="queue-group">Group</Label>
<select
@@ -565,26 +549,17 @@ const QueueOperations = () => {
<Label htmlFor="queue-config">Config (JSON)</Label>
<Textarea id="queue-config" value={queueForm.config} onChange={(e) => setQueueForm({ ...queueForm, config: e.target.value })} rows={4} />
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button type="button" variant="outline" onClick={() => setShowQueueModal(false)}>Cancel</Button>
<Button type="submit">Create Queue</Button>
</div>
</form>
- </div>
- </div>
- )}
+ </Modal>
{/* Send Message Modal */}
- {sendTarget && (
- <div className="modal-overlay" onClick={() => setSendTarget(null)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Send Message</h2>
- <button className="modal-close" onClick={() => setSendTarget(null)}>&times;</button>
- </div>
+ <Modal open={!!sendTarget} onClose={() => setSendTarget(null)} title="Send Message">
+ {sendTarget && (
<form onSubmit={handleSendMessage}>
- <div className="modal-body">
<div className="queue-send-destination">
<div>
<Label>Group</Label>
@@ -615,15 +590,13 @@ const QueueOperations = () => {
<Input id="delay_ms" type="number" value={sendForm.delay_ms} onChange={(e) => setSendForm({ ...sendForm, delay_ms: e.target.value })} />
</div>
</div>
- </div>
- <div className="modal-footer">
+ <div className="modal-actions">
<Button type="button" variant="outline" onClick={() => setSendTarget(null)}>Cancel</Button>
<Button type="submit"><Send size={14} className="mr-2" /> Send Message</Button>
</div>
</form>
- </div>
- </div>
- )}
+ )}
+ </Modal>
</div>
);
};
diff --git a/frontend/src/pages/SSLCertificates.jsx b/frontend/src/pages/SSLCertificates.jsx
index c083bd7e..348288d0 100644
--- a/frontend/src/pages/SSLCertificates.jsx
+++ b/frontend/src/pages/SSLCertificates.jsx
@@ -5,6 +5,7 @@ import {
Settings, Download
} from 'lucide-react';
import api from '../services/api';
+import Modal from '@/components/Modal';
import { Pill } from '@/components/ds';
import { useTopbarActions } from '@/hooks/useTopbarActions';
import { useToast } from '../contexts/ToastContext';
@@ -370,13 +371,7 @@ const SSLCertificates = () => {
)}
{/* Obtain Certificate Modal */}
- {showObtainModal && (
- <div className="modal-overlay" onClick={() => setShowObtainModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Obtain SSL Certificate</h2>
- <button className="modal-close" onClick={() => setShowObtainModal(false)}>×</button>
- </div>
+ <Modal open={showObtainModal} onClose={() => setShowObtainModal(false)} title="Obtain SSL Certificate">
<form onSubmit={handleObtainCertificate}>
<div className="ssl-info-box">
<ShieldCheck size={32} />
@@ -445,9 +440,7 @@ const SSLCertificates = () => {
</Button>
</div>
</form>
- </div>
- </div>
- )}
+ </Modal>
</div>
);
};
diff --git a/frontend/src/pages/ServerTemplates.jsx b/frontend/src/pages/ServerTemplates.jsx
index fa516ed1..c73d5185 100644
--- a/frontend/src/pages/ServerTemplates.jsx
+++ b/frontend/src/pages/ServerTemplates.jsx
@@ -6,6 +6,7 @@ import { useAuth } from '../contexts/AuthContext';
import PageLoader from '../components/PageLoader';
import ConfirmDialog from '../components/ConfirmDialog';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { LayoutTemplate } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -231,69 +232,63 @@ const ServerTemplates = () => {
</Tabs>
{/* Create Modal */}
- {showCreateModal && (
- <div className="modal-overlay" onClick={() => setShowCreateModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create Template</h2>
- <button className="modal-close" onClick={() => setShowCreateModal(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <div className="form-group">
- <label>Name</label>
- <Input value={form.name} onChange={e => setForm({...form, name: e.target.value})} />
- </div>
- <div className="form-group">
- <label>Description</label>
- <Textarea value={form.description} onChange={e => setForm({...form, description: e.target.value})} rows={2} />
- </div>
- <div className="form-group">
- <label>Category</label>
- <select className="form-select" value={form.category} onChange={e => setForm({...form, category: e.target.value})}>
- {Object.entries(categoryLabels).map(([k, v]) => <option key={k} value={k}>{v}</option>)}
- </select>
- </div>
- <div className="form-group">
- <label>Packages (one per line)</label>
- <Textarea className="form-input--mono" value={form.packages} onChange={e => setForm({...form, packages: e.target.value})} rows={4} placeholder={"nginx\nphp-fpm\ncertbot"} />
- </div>
- <div className="form-group">
- <label className="checkbox-label">
- <input type="checkbox" checked={form.auto_remediate} onChange={e => setForm({...form, auto_remediate: e.target.checked})} />
- Auto-remediate drift
- </label>
- </div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreateModal(false)}>Cancel</Button>
- <Button onClick={handleCreate} disabled={!form.name}>Create</Button>
- </div>
- </div>
+ <Modal
+ open={showCreateModal}
+ onClose={() => setShowCreateModal(false)}
+ title="Create Template"
+ footer={(
+ <>
+ <Button variant="outline" onClick={() => setShowCreateModal(false)}>Cancel</Button>
+ <Button onClick={handleCreate} disabled={!form.name}>Create</Button>
+ </>
+ )}
+ >
+ <div className="form-group">
+ <label>Name</label>
+ <Input value={form.name} onChange={e => setForm({...form, name: e.target.value})} />
</div>
- )}
+ <div className="form-group">
+ <label>Description</label>
+ <Textarea value={form.description} onChange={e => setForm({...form, description: e.target.value})} rows={2} />
+ </div>
+ <div className="form-group">
+ <label>Category</label>
+ <select className="form-select" value={form.category} onChange={e => setForm({...form, category: e.target.value})}>
+ {Object.entries(categoryLabels).map(([k, v]) => <option key={k} value={k}>{v}</option>)}
+ </select>
+ </div>
+ <div className="form-group">
+ <label>Packages (one per line)</label>
+ <Textarea className="form-input--mono" value={form.packages} onChange={e => setForm({...form, packages: e.target.value})} rows={4} placeholder={"nginx\nphp-fpm\ncertbot"} />
+ </div>
+ <div className="form-group">
+ <label className="checkbox-label">
+ <input type="checkbox" checked={form.auto_remediate} onChange={e => setForm({...form, auto_remediate: e.target.checked})} />
+ Auto-remediate drift
+ </label>
+ </div>
+ </Modal>
{/* Assign Modal */}
- {showAssignModal && selectedTemplate && (
- <div className="modal-overlay" onClick={() => setShowAssignModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Assign {selectedTemplate.name}</h2>
- <button className="modal-close" onClick={() => setShowAssignModal(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <p>Select a server to apply this template:</p>
- <div className="server-select-list">
- {servers.map(server => (
- <div key={server.id} className="server-select-item" onClick={() => handleAssign(selectedTemplate.id, server.id)}>
- <span className={`status-dot status-dot--${server.status === 'online' ? 'success' : 'danger'}`} />
- <span>{server.name}</span>
- </div>
- ))}
- </div>
+ <Modal
+ open={Boolean(showAssignModal && selectedTemplate)}
+ onClose={() => setShowAssignModal(false)}
+ title={selectedTemplate ? `Assign ${selectedTemplate.name}` : 'Assign template'}
+ >
+ {selectedTemplate && (
+ <>
+ <p>Select a server to apply this template:</p>
+ <div className="server-select-list">
+ {servers.map(server => (
+ <div key={server.id} className="server-select-item" onClick={() => handleAssign(selectedTemplate.id, server.id)}>
+ <span className={`status-dot status-dot--${server.status === 'online' ? 'success' : 'danger'}`} />
+ <span>{server.name}</span>
+ </div>
+ ))}
</div>
- </div>
- </div>
- )}
+ </>
+ )}
+ </Modal>
{deleteConfirm && (
<ConfirmDialog
diff --git a/frontend/src/pages/StatusPages.jsx b/frontend/src/pages/StatusPages.jsx
index 7432709a..6cc3eeb9 100644
--- a/frontend/src/pages/StatusPages.jsx
+++ b/frontend/src/pages/StatusPages.jsx
@@ -5,6 +5,7 @@ import { useAuth } from '../contexts/AuthContext';
import PageLoader from '../components/PageLoader';
import ConfirmDialog from '../components/ConfirmDialog';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
@@ -563,168 +564,164 @@ const StatusPages = () => {
)}
</div>
- {showCreatePage && (
- <div className="modal-overlay" onClick={() => setShowCreatePage(false)}>
- <div className="modal status-modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create Status Page</h2>
- <button className="modal-close" onClick={() => setShowCreatePage(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <div className="form-group">
- <label>Name</label>
- <Input value={pageForm.name} onChange={(e) => handlePageNameChange(e.target.value)} autoFocus />
- </div>
- <div className="form-group">
- <label>Slug</label>
- <Input
- value={pageForm.slug}
- onChange={(e) => setPageForm({ ...pageForm, slug: normalizeSlug(e.target.value) })}
- placeholder="my-services"
- />
- <span className="form-help">/status/{pageForm.slug || 'my-services'}</span>
- </div>
- <div className="form-group">
- <label>Description</label>
- <Textarea
- value={pageForm.description}
- onChange={(e) => setPageForm({ ...pageForm, description: e.target.value })}
- rows={3}
- />
- </div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreatePage(false)}>Cancel</Button>
- <Button onClick={handleCreatePage} disabled={!pageForm.name.trim() || !pageForm.slug.trim()}>
- Create
- </Button>
- </div>
- </div>
+ <Modal
+ open={showCreatePage}
+ onClose={() => setShowCreatePage(false)}
+ title="Create Status Page"
+ size="lg"
+ className="status-modal"
+ footer={(
+ <>
+ <Button variant="outline" onClick={() => setShowCreatePage(false)}>Cancel</Button>
+ <Button onClick={handleCreatePage} disabled={!pageForm.name.trim() || !pageForm.slug.trim()}>
+ Create
+ </Button>
+ </>
+ )}
+ >
+ <div className="form-group">
+ <label>Name</label>
+ <Input value={pageForm.name} onChange={(e) => handlePageNameChange(e.target.value)} autoFocus />
</div>
- )}
-
- {showCreateComponent && (
- <div className="modal-overlay" onClick={() => setShowCreateComponent(false)}>
- <div className="modal status-modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Add Component</h2>
- <button className="modal-close" onClick={() => setShowCreateComponent(false)}>&times;</button>
- </div>
- <div className="modal-body status-modal-grid">
- <div className="form-group">
- <label>Name</label>
- <Input value={compForm.name} onChange={(e) => setCompForm({ ...compForm, name: e.target.value })} autoFocus />
- </div>
- <div className="form-group">
- <label>Group</label>
- <Input value={compForm.group} onChange={(e) => setCompForm({ ...compForm, group: e.target.value })} />
- </div>
- <div className="form-group">
- <label>Check Type</label>
- <select
- className="form-select"
- value={compForm.check_type}
- onChange={(e) => setCompForm({ ...compForm, check_type: e.target.value })}
- >
- <option value="http">HTTP</option>
- <option value="tcp">TCP</option>
- <option value="dns">DNS</option>
- <option value="ping">Ping</option>
- </select>
- </div>
- <div className="form-group">
- <label>Target</label>
- <Input
- value={compForm.check_target}
- onChange={(e) => setCompForm({ ...compForm, check_target: e.target.value })}
- placeholder={CHECK_TARGET_PLACEHOLDERS[compForm.check_type]}
- />
- </div>
- <div className="form-group">
- <label>Interval</label>
- <Input
- type="number"
- min="30"
- value={compForm.check_interval}
- onChange={(e) => setCompForm({ ...compForm, check_interval: parseInt(e.target.value, 10) || 60 })}
- />
- </div>
- <div className="form-group">
- <label>Timeout</label>
- <Input
- type="number"
- min="1"
- value={compForm.check_timeout}
- onChange={(e) => setCompForm({ ...compForm, check_timeout: parseInt(e.target.value, 10) || 10 })}
- />
- </div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreateComponent(false)}>Cancel</Button>
- <Button onClick={handleCreateComponent} disabled={!compForm.name.trim() || !compForm.check_target.trim()}>
- Add Component
- </Button>
- </div>
+ <div className="form-group">
+ <label>Slug</label>
+ <Input
+ value={pageForm.slug}
+ onChange={(e) => setPageForm({ ...pageForm, slug: normalizeSlug(e.target.value) })}
+ placeholder="my-services"
+ />
+ <span className="form-help">/status/{pageForm.slug || 'my-services'}</span>
+ </div>
+ <div className="form-group">
+ <label>Description</label>
+ <Textarea
+ value={pageForm.description}
+ onChange={(e) => setPageForm({ ...pageForm, description: e.target.value })}
+ rows={3}
+ />
+ </div>
+ </Modal>
+
+ <Modal
+ open={showCreateComponent}
+ onClose={() => setShowCreateComponent(false)}
+ title="Add Component"
+ size="lg"
+ className="status-modal"
+ footer={(
+ <>
+ <Button variant="outline" onClick={() => setShowCreateComponent(false)}>Cancel</Button>
+ <Button onClick={handleCreateComponent} disabled={!compForm.name.trim() || !compForm.check_target.trim()}>
+ Add Component
+ </Button>
+ </>
+ )}
+ >
+ <div className="status-modal-grid">
+ <div className="form-group">
+ <label>Name</label>
+ <Input value={compForm.name} onChange={(e) => setCompForm({ ...compForm, name: e.target.value })} autoFocus />
+ </div>
+ <div className="form-group">
+ <label>Group</label>
+ <Input value={compForm.group} onChange={(e) => setCompForm({ ...compForm, group: e.target.value })} />
+ </div>
+ <div className="form-group">
+ <label>Check Type</label>
+ <select
+ className="form-select"
+ value={compForm.check_type}
+ onChange={(e) => setCompForm({ ...compForm, check_type: e.target.value })}
+ >
+ <option value="http">HTTP</option>
+ <option value="tcp">TCP</option>
+ <option value="dns">DNS</option>
+ <option value="ping">Ping</option>
+ </select>
+ </div>
+ <div className="form-group">
+ <label>Target</label>
+ <Input
+ value={compForm.check_target}
+ onChange={(e) => setCompForm({ ...compForm, check_target: e.target.value })}
+ placeholder={CHECK_TARGET_PLACEHOLDERS[compForm.check_type]}
+ />
+ </div>
+ <div className="form-group">
+ <label>Interval</label>
+ <Input
+ type="number"
+ min="30"
+ value={compForm.check_interval}
+ onChange={(e) => setCompForm({ ...compForm, check_interval: parseInt(e.target.value, 10) || 60 })}
+ />
+ </div>
+ <div className="form-group">
+ <label>Timeout</label>
+ <Input
+ type="number"
+ min="1"
+ value={compForm.check_timeout}
+ onChange={(e) => setCompForm({ ...compForm, check_timeout: parseInt(e.target.value, 10) || 10 })}
+ />
</div>
</div>
- )}
-
- {showCreateIncident && (
- <div className="modal-overlay" onClick={() => setShowCreateIncident(false)}>
- <div className="modal status-modal" onClick={(e) => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create Incident</h2>
- <button className="modal-close" onClick={() => setShowCreateIncident(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <div className="form-group">
- <label>Title</label>
- <Input value={incidentForm.title} onChange={(e) => setIncidentForm({ ...incidentForm, title: e.target.value })} autoFocus />
- </div>
- <div className="status-modal-grid">
- <div className="form-group">
- <label>Status</label>
- <select
- className="form-select"
- value={incidentForm.status}
- onChange={(e) => setIncidentForm({ ...incidentForm, status: e.target.value })}
- >
- {INCIDENT_STATUS.filter((status) => status.value !== 'resolved').map((status) => (
- <option key={status.value} value={status.value}>{status.label}</option>
- ))}
- </select>
- </div>
- <div className="form-group">
- <label>Impact</label>
- <select
- className="form-select"
- value={incidentForm.impact}
- onChange={(e) => setIncidentForm({ ...incidentForm, impact: e.target.value })}
- >
- {IMPACT_OPTIONS.map((impact) => (
- <option key={impact.value} value={impact.value}>{impact.label}</option>
- ))}
- </select>
- </div>
- </div>
- <div className="form-group">
- <label>Description</label>
- <Textarea
- value={incidentForm.body}
- onChange={(e) => setIncidentForm({ ...incidentForm, body: e.target.value })}
- rows={4}
- />
- </div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreateIncident(false)}>Cancel</Button>
- <Button onClick={handleCreateIncident} disabled={!incidentForm.title.trim()}>
- Create Incident
- </Button>
- </div>
+ </Modal>
+
+ <Modal
+ open={showCreateIncident}
+ onClose={() => setShowCreateIncident(false)}
+ title="Create Incident"
+ size="lg"
+ className="status-modal"
+ footer={(
+ <>
+ <Button variant="outline" onClick={() => setShowCreateIncident(false)}>Cancel</Button>
+ <Button onClick={handleCreateIncident} disabled={!incidentForm.title.trim()}>
+ Create Incident
+ </Button>
+ </>
+ )}
+ >
+ <div className="form-group">
+ <label>Title</label>
+ <Input value={incidentForm.title} onChange={(e) => setIncidentForm({ ...incidentForm, title: e.target.value })} autoFocus />
+ </div>
+ <div className="status-modal-grid">
+ <div className="form-group">
+ <label>Status</label>
+ <select
+ className="form-select"
+ value={incidentForm.status}
+ onChange={(e) => setIncidentForm({ ...incidentForm, status: e.target.value })}
+ >
+ {INCIDENT_STATUS.filter((status) => status.value !== 'resolved').map((status) => (
+ <option key={status.value} value={status.value}>{status.label}</option>
+ ))}
+ </select>
</div>
+ <div className="form-group">
+ <label>Impact</label>
+ <select
+ className="form-select"
+ value={incidentForm.impact}
+ onChange={(e) => setIncidentForm({ ...incidentForm, impact: e.target.value })}
+ >
+ {IMPACT_OPTIONS.map((impact) => (
+ <option key={impact.value} value={impact.value}>{impact.label}</option>
+ ))}
+ </select>
+ </div>
+ </div>
+ <div className="form-group">
+ <label>Description</label>
+ <Textarea
+ value={incidentForm.body}
+ onChange={(e) => setIncidentForm({ ...incidentForm, body: e.target.value })}
+ rows={4}
+ />
</div>
- )}
+ </Modal>
<ConfirmDialog
isOpen={Boolean(deleteConfirm)}
diff --git a/frontend/src/pages/Templates.jsx b/frontend/src/pages/Templates.jsx
index 05365bbb..99a800cb 100644
--- a/frontend/src/pages/Templates.jsx
+++ b/frontend/src/pages/Templates.jsx
@@ -9,6 +9,7 @@ import {
} from 'lucide-react';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { useTopbarActions } from '@/hooks/useTopbarActions';
@@ -854,14 +855,9 @@ const InstallModal = ({ template, onClose, onSuccess }) => {
}
return (
- <div className="modal-overlay" onClick={onClose}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Install {template.name}</h2>
- <button className="modal-close" onClick={onClose}>&times;</button>
- </div>
- <form onSubmit={handleInstall}>
- <div className="modal-body">
+ <Modal open onClose={onClose} title={`Install ${template.name}`} size="lg">
+ <form onSubmit={handleInstall}>
+ <div className="modal-body">
{errors.length > 0 && (
<div className="alert alert-danger">
<ul>
@@ -973,8 +969,7 @@ const InstallModal = ({ template, onClose, onSuccess }) => {
</Button>
</div>
</form>
- </div>
- </div>
+ </Modal>
);
};
diff --git a/frontend/src/pages/WordPress.jsx b/frontend/src/pages/WordPress.jsx
index 76462568..71d8b456 100644
--- a/frontend/src/pages/WordPress.jsx
+++ b/frontend/src/pages/WordPress.jsx
@@ -9,6 +9,7 @@ import EmptyState from '../components/EmptyState';
import { Globe, ChevronRight, Search } from 'lucide-react';
import { Pill, SegControl, ServiceTile } from '@/components/ds';
import { useTopbarActions } from '@/hooks/useTopbarActions';
+import Modal from '@/components/Modal';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -398,16 +399,13 @@ function WordPress() {
})()}
{/* Import Site Modal */}
- {showImportModal && (
- <div className="modal-overlay" onClick={() => !importLoading && setShowImportModal(false)}>
- <div className="modal modal-lg" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h3>Import WordPress Site</h3>
- <button className="modal-close" onClick={() => !importLoading && setShowImportModal(false)}>
- &times;
- </button>
- </div>
- <div className="modal-body">
+ <Modal
+ open={showImportModal}
+ onClose={() => !importLoading && setShowImportModal(false)}
+ title="Import WordPress Site"
+ size="lg"
+ >
+ <div className="modal-body">
<div className="install-warning">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="10"/><path d="M12 8v4M12 16h.01"/></svg>
<div>
@@ -485,21 +483,16 @@ function WordPress() {
{importLoading ? <><Spinner size="sm" /> Importing...</> : 'Import Site'}
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
{/* Create Site Modal */}
- {showCreateModal && (
- <div className="modal-overlay" onClick={() => !createLoading && setShowCreateModal(false)}>
- <div className="modal modal-lg" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h3>Create WordPress Site</h3>
- <button className="modal-close" onClick={() => !createLoading && setShowCreateModal(false)}>
- &times;
- </button>
- </div>
- <div className="modal-body">
+ <Modal
+ open={showCreateModal}
+ onClose={() => !createLoading && setShowCreateModal(false)}
+ title="Create WordPress Site"
+ size="lg"
+ >
+ <div className="modal-body">
<div className="install-warning">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="10"/><path d="M12 8v4M12 16h.01"/></svg>
<div>
@@ -605,9 +598,7 @@ function WordPress() {
{createLoading ? <><Spinner size="sm" /> Creating...</> : 'Create Site'}
</Button>
</div>
- </div>
- </div>
- )}
+ </Modal>
</div>
);
}
diff --git a/frontend/src/pages/WorkspaceDetail.jsx b/frontend/src/pages/WorkspaceDetail.jsx
index 1e8be82c..c1f542f5 100644
--- a/frontend/src/pages/WorkspaceDetail.jsx
+++ b/frontend/src/pages/WorkspaceDetail.jsx
@@ -7,6 +7,7 @@ import { useAuth } from '../contexts/AuthContext';
import Spinner from '../components/Spinner';
import ConfirmDialog from '../components/ConfirmDialog';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { Pill, ServiceTile, PageTopbar } from '@/components/ds';
import { Button } from '@/components/ui/button';
import {
@@ -312,50 +313,48 @@ const WorkspaceDetail = () => {
</div>
</div>
- {sharingApp && (
- <div className="modal-overlay" onClick={() => setSharingApp(null)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Sharing: {sharingApp.name}</h2>
- <button className="modal-close" onClick={() => setSharingApp(null)}>&times;</button>
- </div>
- <div className="modal-body">
- <p className="form-hint">Grant a user access to this application without transferring ownership.</p>
- <div className="ws-rows">
- {grants.length === 0 && <p className="form-hint">Not shared with anyone yet.</p>}
- {grants.map(g => (
- <div key={g.id} className="ws-row">
- <ServiceTile name={g.username || g.email || '?'} size={28} className="ws-row__av" />
- <div className="ws-row__id">
- <strong>{g.username || g.email}</strong>
- <span className="sk-tag">{g.role}</span>
- </div>
- <Button size="sm" variant="destructive" onClick={() => handleRevoke(g.id)}>Revoke</Button>
- </div>
- ))}
- </div>
- <hr />
- <h4>Grant Access</h4>
- <div className="form-group">
- <label>Role for new grants</label>
- <select value={grantRole} onChange={e => setGrantRole(e.target.value)}>
- <option value="editor">Editor · view + operate</option>
- <option value="viewer">Viewer · read-only</option>
- </select>
- </div>
- <div className="ws-pick">
- {allUsers.filter(u => u.id !== sharingApp.user_id && !grants.find(g => g.user_id === u.id)).map(u => (
- <div key={u.id} className="ws-pick__item" onClick={() => handleGrant(u.id)}>
- <ServiceTile name={u.username || u.email || '?'} size={24} className="ws-row__av" />
- <span className="ws-pick__name">{u.username || u.email}</span>
- <span className="ws-pick__plus">+</span>
+ <Modal
+ open={Boolean(sharingApp)}
+ onClose={() => setSharingApp(null)}
+ title={sharingApp ? `Sharing: ${sharingApp.name}` : 'Sharing'}
+ >
+ {sharingApp && (
+ <>
+ <p className="form-hint">Grant a user access to this application without transferring ownership.</p>
+ <div className="ws-rows">
+ {grants.length === 0 && <p className="form-hint">Not shared with anyone yet.</p>}
+ {grants.map(g => (
+ <div key={g.id} className="ws-row">
+ <ServiceTile name={g.username || g.email || '?'} size={28} className="ws-row__av" />
+ <div className="ws-row__id">
+ <strong>{g.username || g.email}</strong>
+ <span className="sk-tag">{g.role}</span>
</div>
- ))}
- </div>
+ <Button size="sm" variant="destructive" onClick={() => handleRevoke(g.id)}>Revoke</Button>
+ </div>
+ ))}
</div>
- </div>
- </div>
- )}
+ <hr />
+ <h4>Grant Access</h4>
+ <div className="form-group">
+ <label>Role for new grants</label>
+ <select value={grantRole} onChange={e => setGrantRole(e.target.value)}>
+ <option value="editor">Editor · view + operate</option>
+ <option value="viewer">Viewer · read-only</option>
+ </select>
+ </div>
+ <div className="ws-pick">
+ {allUsers.filter(u => u.id !== sharingApp.user_id && !grants.find(g => g.user_id === u.id)).map(u => (
+ <div key={u.id} className="ws-pick__item" onClick={() => handleGrant(u.id)}>
+ <ServiceTile name={u.username || u.email || '?'} size={24} className="ws-row__av" />
+ <span className="ws-pick__name">{u.username || u.email}</span>
+ <span className="ws-pick__plus">+</span>
+ </div>
+ ))}
+ </div>
+ </>
+ )}
+ </Modal>
{deleteConfirm && (
<ConfirmDialog
diff --git a/frontend/src/pages/Workspaces.jsx b/frontend/src/pages/Workspaces.jsx
index eb69f5b9..59e9c2b5 100644
--- a/frontend/src/pages/Workspaces.jsx
+++ b/frontend/src/pages/Workspaces.jsx
@@ -4,6 +4,7 @@ import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import Spinner from '../components/Spinner';
import EmptyState from '../components/EmptyState';
+import Modal from '@/components/Modal';
import { LayoutGrid, Plus, ChevronRight, Search } from 'lucide-react';
import { Pill, SegControl, ServiceTile } from '@/components/ds';
import { useTopbarActions } from '@/hooks/useTopbarActions';
@@ -221,51 +222,47 @@ const Workspaces = () => {
</div>
)}
- {showCreateModal && (
- <div className="modal-overlay" onClick={() => setShowCreateModal(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Create Workspace</h2>
- <button className="modal-close" onClick={() => setShowCreateModal(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <div className="form-group">
- <label>Name</label>
- <Input value={form.name} onChange={e => setForm({...form, name: e.target.value})} placeholder="My Team" />
- </div>
- <div className="form-group">
- <label>Description</label>
- <Textarea value={form.description} onChange={e => setForm({...form, description: e.target.value})} rows={2} />
- </div>
- <div className="form-row">
- <div className="form-group">
- <label>Max Servers (0 = unlimited)</label>
- <Input type="number" value={form.max_servers} onChange={e => setForm({...form, max_servers: parseInt(e.target.value) || 0})} />
- </div>
- <div className="form-group">
- <label>Max Users (0 = unlimited)</label>
- <Input type="number" value={form.max_users} onChange={e => setForm({...form, max_users: parseInt(e.target.value) || 0})} />
- </div>
- </div>
- <div className="form-group">
- <label>Brand Color</label>
- <input
- type="color"
- className="workspace-color-input"
- value={form.primary_color}
- onChange={e => setForm({...form, primary_color: e.target.value})}
- aria-label="Workspace brand color"
- />
- <span className="form-hint">Recolors the panel for anyone viewing this workspace. Leave the default for no custom branding.</span>
- </div>
- </div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowCreateModal(false)}>Cancel</Button>
- <Button onClick={handleCreate} disabled={!form.name}>Create</Button>
- </div>
+ <Modal
+ open={showCreateModal}
+ onClose={() => setShowCreateModal(false)}
+ title="Create Workspace"
+ footer={(
+ <>
+ <Button variant="outline" onClick={() => setShowCreateModal(false)}>Cancel</Button>
+ <Button onClick={handleCreate} disabled={!form.name}>Create</Button>
+ </>
+ )}
+ >
+ <div className="form-group">
+ <label>Name</label>
+ <Input value={form.name} onChange={e => setForm({...form, name: e.target.value})} placeholder="My Team" />
+ </div>
+ <div className="form-group">
+ <label>Description</label>
+ <Textarea value={form.description} onChange={e => setForm({...form, description: e.target.value})} rows={2} />
+ </div>
+ <div className="form-row">
+ <div className="form-group">
+ <label>Max Servers (0 = unlimited)</label>
+ <Input type="number" value={form.max_servers} onChange={e => setForm({...form, max_servers: parseInt(e.target.value) || 0})} />
+ </div>
+ <div className="form-group">
+ <label>Max Users (0 = unlimited)</label>
+ <Input type="number" value={form.max_users} onChange={e => setForm({...form, max_users: parseInt(e.target.value) || 0})} />
</div>
</div>
- )}
+ <div className="form-group">
+ <label>Brand Color</label>
+ <input
+ type="color"
+ className="workspace-color-input"
+ value={form.primary_color}
+ onChange={e => setForm({...form, primary_color: e.target.value})}
+ aria-label="Workspace brand color"
+ />
+ <span className="form-hint">Recolors the panel for anyone viewing this workspace. Leave the default for no custom branding.</span>
+ </div>
+ </Modal>
</div>
);
};
diff --git a/frontend/src/styles/pages/_status-pages.scss b/frontend/src/styles/pages/_status-pages.scss
index f65684b1..79b534e0 100644
--- a/frontend/src/styles/pages/_status-pages.scss
+++ b/frontend/src/styles/pages/_status-pages.scss
@@ -504,34 +504,36 @@
}
}
- // ── modal forms (surface chrome is global; add eyebrow labels) ──
- .status-modal {
- max-width: 640px;
+}
- .form-group label {
- font-family: var(--mono);
- font-size: 10px;
- font-weight: $font-weight-semibold;
- letter-spacing: 0.08em;
- text-transform: uppercase;
- color: var(--text-faint);
- }
+// Status-page modal chrome. Hoisted OUT of .status-pages-page: the shared Modal
+// renders through a portal on <body>, so page-scoped rules would never reach it.
+// Surface chrome comes from .sk-modal; these only add the eyebrow form labels
+// and the two-column grid.
+.status-modal {
+ .form-group label {
+ font-family: var(--mono);
+ font-size: 10px;
+ font-weight: $font-weight-semibold;
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ color: var(--text-faint);
+ }
- .form-help {
- font-family: var(--mono);
- font-size: 11px;
- color: var(--text-faint);
- }
+ .form-help {
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--text-faint);
}
+}
- .status-modal-grid {
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: $space-4;
+.status-modal-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: $space-4;
- @media (max-width: 640px) {
- grid-template-columns: 1fr;
- }
+ @media (max-width: 640px) {
+ grid-template-columns: 1fr;
}
}