From 126d90cd68ee2ec6d83836b2dd4c3eb43fd1f375 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Fri, 17 Jul 2026 04:11:12 +0800 Subject: [PATCH] Expose remote vault pairing in sync plugin --- plugins/sync/frontend/src/SyncSettings.svelte | 18 ++++++++++++++++-- plugins/sync/locales/en.json | 3 +++ plugins/sync/locales/ru.json | 3 +++ scripts/smoke-sync-plugin.js | 9 +++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/plugins/sync/frontend/src/SyncSettings.svelte b/plugins/sync/frontend/src/SyncSettings.svelte index c81cf00..ae305db 100644 --- a/plugins/sync/frontend/src/SyncSettings.svelte +++ b/plugins/sync/frontend/src/SyncSettings.svelte @@ -13,6 +13,7 @@ let connectionOk = null let serverUrl = '' + let vaultId = '' let username = '' let password = '' let syncInterval = 5 @@ -44,6 +45,7 @@ const saved = await api.settings.read() if (saved) { serverUrl = saved.serverUrl || '' + vaultId = saved.vaultId || '' username = saved.username || '' autoSync = !!saved.autoSync syncInterval = saved.syncInterval || 5 @@ -56,6 +58,7 @@ settings = await syncAPI().status() if (settings) { if (settings.serverUrl) serverUrl = settings.serverUrl + if (settings.vaultId) vaultId = settings.vaultId if (settings.syncInterval != null) syncInterval = settings.syncInterval if (settings.syncInterval > 0) autoSync = true if (settings.lastError) console.warn('[verstak.sync] last sync failed:', settings.lastError) @@ -78,7 +81,7 @@ resultMsg = '' try { if (api?.settings?.writeAll) { - await api.settings.writeAll({ serverUrl, username, autoSync, syncInterval }) + await api.settings.writeAll({ serverUrl, vaultId, username, autoSync, syncInterval }) } await syncAPI().setInterval(autoSync ? syncInterval : 0) resultMsg = tr('ui.settingsSaved', null, 'Settings saved.') @@ -112,7 +115,7 @@ errorMsg = '' connectionResult = '' try { - await syncAPI().configure(serverUrl, username, password) + await syncAPI().configure(serverUrl, username, password, vaultId) connectionResult = tr('ui.connectedSuccessfully', null, 'Connected successfully.') connectionOk = true username = '' @@ -235,6 +238,11 @@ {tr('ui.lastSyncError', null, 'The last synchronization did not finish. Try again.')} {/if} + {#if settings && settings.lastWarning && !errorMsg} +
+ {tr('ui.unresolvedFilesWarning', null, 'Some files are not synchronized yet. Resolve the file warning and run sync again.')} +
+ {/if}

{tr('ui.server', null, 'Server')}

@@ -244,6 +252,12 @@ e.target.style.cssText = INPUT_FOCUS_STYLE} on:blur={e => e.target.style.cssText = INPUT_STYLE} bind:value={serverUrl} placeholder="https://example.com" />
+
+ + e.target.style.cssText = INPUT_FOCUS_STYLE} on:blur={e => e.target.style.cssText = INPUT_STYLE} bind:value={vaultId} /> +
{tr('ui.remoteVaultHint', null, 'Leave empty for this vault. Enter an existing remote vault ID to restore it on this device.')}
+
+
e.target.style.cssText = INPUT_FOCUS_STYLE} on:blur={e => e.target.style.cssText = INPUT_STYLE} bind:value={username} /> diff --git a/plugins/sync/locales/en.json b/plugins/sync/locales/en.json index 4237cb9..d63133d 100644 --- a/plugins/sync/locales/en.json +++ b/plugins/sync/locales/en.json @@ -24,9 +24,12 @@ "ui.keyReset": "Sync key reset. Connect again to pair this device.", "ui.syncConflicts": "Sync conflicts", "ui.lastSyncError": "The last synchronization did not finish. Try again.", + "ui.unresolvedFilesWarning": "Some files are not synchronized yet. Resolve the file warning and run sync again.", "ui.syncConflictItem": "A synchronization conflict needs attention.", "ui.server": "Server", "ui.serverUrl": "Server URL", + "ui.remoteVaultId": "Remote vault ID (optional)", + "ui.remoteVaultHint": "Leave empty for this vault. Enter an existing remote vault ID to restore it on this device.", "ui.username": "Username", "ui.password": "Password", "ui.testConnection": "Test Connection", diff --git a/plugins/sync/locales/ru.json b/plugins/sync/locales/ru.json index 721370b..87d895a 100644 --- a/plugins/sync/locales/ru.json +++ b/plugins/sync/locales/ru.json @@ -24,9 +24,12 @@ "ui.keyReset": "Ключ синхронизации сброшен. Подключитесь снова, чтобы связать устройство.", "ui.syncConflicts": "Конфликты синхронизации", "ui.lastSyncError": "Последняя синхронизация не завершилась. Повторите попытку.", + "ui.unresolvedFilesWarning": "Некоторые файлы ещё не синхронизированы. Устраните предупреждение по файлу и повторите синхронизацию.", "ui.syncConflictItem": "Конфликт синхронизации требует внимания.", "ui.server": "Сервер", "ui.serverUrl": "URL сервера", + "ui.remoteVaultId": "ID удалённого хранилища (необязательно)", + "ui.remoteVaultHint": "Оставьте пустым для этого хранилища. Укажите ID существующего удалённого хранилища, чтобы восстановить его на этом устройстве.", "ui.username": "Имя пользователя", "ui.password": "Пароль", "ui.testConnection": "Проверить подключение", diff --git a/scripts/smoke-sync-plugin.js b/scripts/smoke-sync-plugin.js index 966e669..69848a7 100644 --- a/scripts/smoke-sync-plugin.js +++ b/scripts/smoke-sync-plugin.js @@ -27,5 +27,14 @@ if (!source.includes('conflictDetails')) { if (!source.includes('Sync conflicts')) { throw new Error('SyncSettings must label the conflict details section'); } +if (!source.includes('syncAPI().configure(serverUrl, username, password, vaultId)')) { + throw new Error('SyncSettings must pass the optional remote vault ID during pairing'); +} +if (!source.includes('settings.lastWarning')) { + throw new Error('SyncSettings must render unresolved scanner warnings'); +} +if (!source.includes("tr('ui.remoteVaultHint'")) { + throw new Error('SyncSettings must explain remote vault restoration'); +} console.log('sync plugin smoke passed');