()
| 86 | else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); } |
| 87 | }; |
| 88 | const save = async () => { |
| 89 | if (!snapshot || pending.current || !count || invalid) return; |
| 90 | pending.current = true; setSaving(true); setError(''); setNotice(''); |
| 91 | const ticket = ++generation.current; |
| 92 | try { |
| 93 | const next = await service.saveConfiguration(snapshot.revision, draft); |
| 94 | if (ticket === generation.current) { |
| 95 | setSnapshot(next); setDraft({}); setConfirmClose(false); |
| 96 | setNotice(next.settings.some(setting => setting.pendingRestart) ? 'Saved. Restart CBM to apply pending settings throughout.' : 'Saved. Changes apply at the times shown below.'); |
| 97 | } |
| 98 | } catch (failure) { if (ticket === generation.current) setError(failure instanceof Error ? failure.message : 'Could not save configuration. Your edits are retained.'); } |
| 99 | finally { pending.current = false; if (ticket === generation.current) setSaving(false); } |
| 100 | }; |
| 101 | const navigate = (action: () => void) => { if (count) { setError('Save or discard your daemon changes before opening another settings panel.'); return; } action(); }; |
| 102 | const panel = <div className={`cbm-config-dialog${embedded ? ' cbm-config-embedded' : ''}`} ref={dialog} role={embedded ? 'region' : 'dialog'} aria-modal={embedded ? undefined : true} aria-labelledby="cbm-config-title" tabIndex={embedded ? undefined : -1} onKeyDown={embedded ? undefined : keyDown}> |
| 103 | <header className="cbm-config-heading"><div><h2 id="cbm-config-title">{embedded ? 'Configuration' : CONFIG_TEXT.title}</h2><p>Daemon settings and browser preferences</p></div>{!embedded && <button type="button" onClick={close} disabled={saving} aria-label={CONFIG_TEXT.close}>×</button>}</header> |
no test coverage detected