ui: tidy Database panel — settings shows only Open-folder; DB actions on logbook

Per feedback: New/Open/Rename/Save-copy/Reset made no sense under the settings
database — moved the meaningful DB actions to the logbook (New database / Open
existing / Rename-relocate). The settings section now shows just its path + Open
folder. Also fixed the "Logbook switched…" confirmation rendering twice (dropped
the duplicate render in the SQLite block; kept the shared one). The unused
settings-db handlers/bindings stay for a later re-add.
This commit is contained in:
2026-07-24 18:30:05 +02:00
parent 77a2350240
commit 557fb162c3
+16 -27
View File
@@ -4326,9 +4326,10 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
.then(async () => { setMysqlField({ enabled: false, sqlite_path: '' }); setRestartMsg(t('db.switchedSqlite')); await refreshBackend(); }) .then(async () => { setMysqlField({ enabled: false, sqlite_path: '' }); setRestartMsg(t('db.switchedSqlite')); await refreshBackend(); })
.catch((e: any) => setErr(String(e?.message ?? e))); .catch((e: any) => setErr(String(e?.message ?? e)));
} }
// Route THIS profile's logbook to its own SQLite file (config stays in // Point THIS profile's logbook at a SQLite file (settings stay in the
// opslog.db). db.Open creates+migrates the file if it's new. Pick a name/place. // settings db). A NEW name is created + migrated empty; an existing file is
async function pickSeparateSqlite() { // opened with its QSOs.
async function newLogbook() {
try { try {
const p = await PickSaveDatabase(); const p = await PickSaveDatabase();
if (!p) return; if (!p) return;
@@ -4338,6 +4339,16 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
await refreshBackend(); await refreshBackend();
} catch (e: any) { setErr(String(e?.message ?? e)); } } catch (e: any) { setErr(String(e?.message ?? e)); }
} }
async function openLogbook() {
try {
const p = await PickOpenDatabase();
if (!p) return;
await SaveMySQLSettings({ ...mysqlCfg, enabled: false, sqlite_path: p } as any);
setMysqlField({ enabled: false, sqlite_path: p });
setRestartMsg(t('db.switchedSqliteFile'));
await refreshBackend();
} catch (e: any) { setErr(String(e?.message ?? e)); }
}
function connectMysql() { function connectMysql() {
SaveMySQLSettings(mysqlCfg as any) SaveMySQLSettings(mysqlCfg as any)
.then(async () => { setRestartMsg(t('db.switchedMysql')); await refreshBackend(); }) .then(async () => { setRestartMsg(t('db.switchedMysql')); await refreshBackend(); })
@@ -4360,29 +4371,7 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
<p className="text-[11px] text-muted-foreground">{t('db.appDbHint')}</p> <p className="text-[11px] text-muted-foreground">{t('db.appDbHint')}</p>
<div className="flex flex-wrap gap-2"> <div className="flex flex-wrap gap-2">
<Button variant="outline" size="sm" onClick={revealFolder}><FolderOpen className="size-3.5" /> {t('db.openFolder')}</Button> <Button variant="outline" size="sm" onClick={revealFolder}><FolderOpen className="size-3.5" /> {t('db.openFolder')}</Button>
<Button variant="outline" size="sm" onClick={createNew}><Plus className="size-3.5" /> {t('db.newDb')}</Button>
<Button variant="outline" size="sm" onClick={openExisting}><FolderOpen className="size-3.5" /> {t('db.openExisting')}</Button>
<Button variant="outline" size="sm" onClick={renameDb} title={t('db.renameTip')}><Pencil className="size-3.5" /> {t('db.rename')}</Button>
<Button variant="outline" size="sm" onClick={saveCopy}><Copy className="size-3.5" /> {t('db.saveCopy')}</Button>
{dbSettings.is_custom && <Button variant="ghost" size="sm" onClick={resetDefault}>{t('db.resetDefault')}</Button>}
</div> </div>
{dbMsg && (
<div className="text-xs bg-success-muted border border-success-border text-success-muted-foreground rounded-md px-3 py-3 space-y-2">
<div className="flex items-start gap-2">
<Check className="size-4 mt-0.5 shrink-0" />
<div>
<div className="font-medium">{t('db.savedRestart')}</div>
<div className="font-mono text-[10px] mt-1 break-all opacity-90">{dbMsg}</div>
</div>
</div>
<div className="flex items-center gap-2 pl-6">
<Button size="sm" onClick={() => { RestartApp().catch((e: any) => setErr(String(e?.message ?? e))); }}>
<Power className="size-3.5" /> {t('db.restartNow')}
</Button>
<span className="text-[10px] opacity-80">{t('db.restartHint')}</span>
</div>
</div>
)}
</div> </div>
{/* Logbook (QSOs) — this profile: default SQLite file, a dedicated file, or MySQL. */} {/* Logbook (QSOs) — this profile: default SQLite file, a dedicated file, or MySQL. */}
@@ -4433,11 +4422,11 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
<p className="text-[11px] text-muted-foreground">{t('db.logbookFileHint')}</p> <p className="text-[11px] text-muted-foreground">{t('db.logbookFileHint')}</p>
</div> </div>
<div className="flex flex-wrap gap-2"> <div className="flex flex-wrap gap-2">
<Button variant="outline" size="sm" onClick={pickSeparateSqlite}><FolderOpen className="size-3.5" /> {t('db.chooseFile')}</Button> <Button variant="outline" size="sm" onClick={newLogbook}><Plus className="size-3.5" /> {t('db.newDb')}</Button>
<Button variant="outline" size="sm" onClick={openLogbook}><FolderOpen className="size-3.5" /> {t('db.openExisting')}</Button>
<Button variant="outline" size="sm" onClick={renameLogbook} title={t('db.renameLogbookTip')}><Pencil className="size-3.5" /> {t('db.renameLogbook')}</Button> <Button variant="outline" size="sm" onClick={renameLogbook} title={t('db.renameLogbookTip')}><Pencil className="size-3.5" /> {t('db.renameLogbook')}</Button>
{mysqlCfg.sqlite_path && <Button variant="ghost" size="sm" onClick={useLocalLogbook}>{t('db.useDefaultLogbook')}</Button>} {mysqlCfg.sqlite_path && <Button variant="ghost" size="sm" onClick={useLocalLogbook}>{t('db.useDefaultLogbook')}</Button>}
</div> </div>
{restartMsg && <div className="text-xs text-success-muted-foreground">{restartMsg}</div>}
</div> </div>
)} )}