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:
@@ -4326,9 +4326,10 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
|
||||
.then(async () => { setMysqlField({ enabled: false, sqlite_path: '' }); setRestartMsg(t('db.switchedSqlite')); await refreshBackend(); })
|
||||
.catch((e: any) => setErr(String(e?.message ?? e)));
|
||||
}
|
||||
// Route THIS profile's logbook to its own SQLite file (config stays in
|
||||
// opslog.db). db.Open creates+migrates the file if it's new. Pick a name/place.
|
||||
async function pickSeparateSqlite() {
|
||||
// Point THIS profile's logbook at a SQLite file (settings stay in the
|
||||
// settings db). A NEW name is created + migrated empty; an existing file is
|
||||
// opened with its QSOs.
|
||||
async function newLogbook() {
|
||||
try {
|
||||
const p = await PickSaveDatabase();
|
||||
if (!p) return;
|
||||
@@ -4338,6 +4339,16 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
|
||||
await refreshBackend();
|
||||
} 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() {
|
||||
SaveMySQLSettings(mysqlCfg as any)
|
||||
.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>
|
||||
<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={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>
|
||||
{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>
|
||||
|
||||
{/* 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>
|
||||
</div>
|
||||
<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>
|
||||
{mysqlCfg.sqlite_path && <Button variant="ghost" size="sm" onClick={useLocalLogbook}>{t('db.useDefaultLogbook')}</Button>}
|
||||
</div>
|
||||
{restartMsg && <div className="text-xs text-success-muted-foreground">{restartMsg}</div>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user