// Settings view — verification defaults, migration defaults, connection info import { api } from './api.js'; import { escHtml } from './utils.js'; import { disconnectPlatform, showDocusignAccountPicker, switchAccount } from './auth.js'; import { navigate } from './router.js'; import { resetQuickStart } from './help.js'; const SETTINGS_KEY = 'migrator_settings'; export function loadSettings() { try { return JSON.parse(localStorage.getItem(SETTINGS_KEY)) || {}; } catch { return {}; } } export function saveSettings(settings) { localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings)); } export function renderSettings() { const outlet = document.getElementById('router-outlet'); const s = loadSettings(); outlet.innerHTML = `
Verification
Default recipient for test envelopes
Test Recipient Name
Pre-filled in the Send Test dialog on the Verification screen
Test Recipient Email
Pre-filled in the Send Test dialog
Auto-Void Timer (hours)
Reminder to void test envelopes after this many hours (display only — no automatic action)
Migration Defaults
Pre-set options in the migration options modal
Overwrite Existing by Default
When on, the Overwrite Existing toggle in the migration modal starts enabled
Include Documents by Default
Embed PDFs in the Docusign template payload
Connections
Current platform connection status and account actions
Loading…
Help & Onboarding
Make it easy to get oriented again or share the app with a first-time tester
Open Full Help
See the in-app guide with the recommended first-time flow and screen-by-screen overview.
Show Quick Start Again
Re-enable the Templates quick-start card if you dismissed it earlier.
`; // Wire toggles document.querySelectorAll('.toggle').forEach(btn => { btn.addEventListener('click', () => { btn.classList.toggle('on'); btn.setAttribute('aria-checked', btn.classList.contains('on')); }); }); // Save document.getElementById('btn-save-settings')?.addEventListener('click', () => { const updated = { testRecipientName: document.getElementById('set-recipient-name')?.value.trim() || '', testRecipientEmail: document.getElementById('set-recipient-email')?.value.trim() || '', autoVoidHours: parseInt(document.getElementById('set-auto-void')?.value) || 24, defaultOverwrite: document.getElementById('set-overwrite')?.classList.contains('on') || false, defaultIncludeDocs: document.getElementById('set-include-docs')?.classList.contains('on') !== false, }; saveSettings(updated); const confirm = document.getElementById('save-confirm'); if (confirm) { confirm.style.display = 'inline'; setTimeout(() => { confirm.style.display = 'none'; }, 2500); } }); document.getElementById('btn-open-help')?.addEventListener('click', () => { navigate('#/help'); }); document.getElementById('btn-reset-quick-start')?.addEventListener('click', () => { resetQuickStart(); navigate('#/templates'); }); // Load connection info _loadConnInfo(); } async function _loadConnInfo() { const connEl = document.getElementById('settings-conn-info'); if (!connEl) return; try { const data = await api.auth.status(); connEl.innerHTML = `
Adobe Sign ${data.adobe ? `Connected${data.adobe_account_name ? ` — ${escHtml(data.adobe_account_name)}` : ''}` : 'Not connected'} ${data.adobe ? '● Connected' : '○ Disconnected'}
Docusign ${data.docusign ? (data.docusign_account_selection_required ? 'Connected — account selection required' : `Connected${data.docusign_account_name ? ` — ${escHtml(data.docusign_account_name)}` : ''}`) : 'Not connected'}
Adobe Actions
Docusign Actions
Adobe Auth Mode ${escHtml(data.adobe_auth_mode || '—')}
Docusign Auth Mode ${escHtml(data.docusign_auth_mode || '—')}
Browser Session ID ${escHtml(data.session_id || '—')}
Admin Access ${data.is_admin ? 'Yes — this session can view all audit logs.' : 'No — this session can only view its own audit logs.'}
Switch Account Note Use Choose Account or Switch Docusign Account to select from the DocuSign accounts available to this login. The picker is sorted alphabetically and supports search.
Adobe Account ID ${escHtml(data.adobe_account_id || '—')}
Docusign Account ID ${escHtml(data.docusign_account_id || '—')}
API Environment ${escHtml(data.base_url || '—')}
`; } catch (e) { connEl.innerHTML = `
Failed to load connection info: ${escHtml(e.message)}
`; return; } document.getElementById('btn-disconnect-adobe')?.addEventListener('click', async () => { await disconnectPlatform('adobe'); await _loadConnInfo(); }); document.getElementById('btn-disconnect-docusign')?.addEventListener('click', async () => { await disconnectPlatform('docusign'); await _loadConnInfo(); }); document.getElementById('btn-switch-docusign')?.addEventListener('click', async () => { await switchAccount('docusign'); }); document.getElementById('btn-choose-docusign-account')?.addEventListener('click', async () => { await showDocusignAccountPicker({ forceRefresh: true }); }); if (data.docusign && data.docusign_account_selection_required) { await showDocusignAccountPicker(); } }