diff --git a/api/app.py b/api/app.py index e508170..b4d502c 100644 --- a/api/app.py +++ b/api/app.py @@ -629,6 +629,13 @@ def get_pending_config(): }) +@app.route('/api/config/pending', methods=['DELETE']) +def cancel_pending_config(): + """Discard pending configuration changes without restarting any containers.""" + _clear_pending_restart() + return jsonify({'message': 'Pending changes discarded'}) + + @app.route('/api/config/apply', methods=['POST']) def apply_pending_config(): """Apply pending configuration by restarting containers via docker compose up -d.""" diff --git a/webui/src/App.jsx b/webui/src/App.jsx index b57c40d..1d3299c 100644 --- a/webui/src/App.jsx +++ b/webui/src/App.jsx @@ -35,9 +35,10 @@ import Vault from './pages/Vault'; import ContainerDashboard from './components/ContainerDashboard'; import CellNetwork from './pages/CellNetwork'; -function PendingRestartBanner({ pending, onApply }) { +function PendingRestartBanner({ pending, onApply, onCancel }) { const [confirming, setConfirming] = useState(false); const [applying, setApplying] = useState(false); + const [cancelling, setCancelling] = useState(false); const handleApply = async () => { setApplying(true); @@ -49,6 +50,15 @@ function PendingRestartBanner({ pending, onApply }) { } }; + const handleCancel = async () => { + setCancelling(true); + try { + await onCancel(); + } finally { + setCancelling(false); + } + }; + return ( <>
@@ -66,14 +76,23 @@ function PendingRestartBanner({ pending, onApply }) { )}
- +
+ + +
@@ -147,7 +166,11 @@ function App() { const handleApply = useCallback(async () => { await cellAPI.applyPending(); - // Optimistically clear the banner; containers are restarting + setPending({ needs_restart: false, changes: [] }); + }, []); + + const handleCancel = useCallback(async () => { + await cellAPI.cancelPending(); setPending({ needs_restart: false, changes: [] }); }, []); @@ -209,7 +232,7 @@ function App() { )} {isOnline && pending.needs_restart && ( - + )} diff --git a/webui/src/services/api.js b/webui/src/services/api.js index e4947fe..79e12b7 100644 --- a/webui/src/services/api.js +++ b/webui/src/services/api.js @@ -44,6 +44,7 @@ export const cellAPI = { exportConfig: (format = 'json') => api.get('/api/config/export', { params: { format } }), importConfig: (config, format = 'json') => api.post('/api/config/import', { config, format }), getPending: () => api.get('/api/config/pending'), + cancelPending: () => api.delete('/api/config/pending'), applyPending: () => api.post('/api/config/apply'), };