// Issues & Warnings view — surfaces all validation problems before migration import { state } from './state.js'; import { escHtml, formatDate } from './utils.js'; import { navigate } from './router.js'; export function renderIssues() { const outlet = document.getElementById('router-outlet'); const templates = state.templates || []; const blocked = templates.filter(t => t.blockers && t.blockers.length > 0); const warnings = templates.filter(t => (!t.blockers || t.blockers.length === 0) && t.warnings && t.warnings.length > 0 ); if (!state.auth.adobe || !state.auth.docusign) { outlet.innerHTML = `
â„šī¸Connect both platforms to see validation results.
`; return; } if (!blocked.length && !warnings.length) { outlet.innerHTML = `
🎉
All templates are ready!
No blockers or warnings found across ${templates.length} template${templates.length !== 1 ? 's' : ''}.
`; return; } outlet.innerHTML = ` ${blocked.length ? `
đŸšĢ Blockers — ${blocked.length} template${blocked.length > 1 ? 's' : ''} will fail migration
${blocked.map(t => _blockerItem(t)).join('')}
` : ''} ${warnings.length ? `
⚠ Warnings — ${warnings.length} template${warnings.length > 1 ? 's' : ''} will migrate with caveats
${warnings.map(t => _warningItem(t)).join('')}
` : ''} `; // Migrate Anyway buttons document.querySelectorAll('.btn-migrate-anyway').forEach(btn => { btn.addEventListener('click', () => { import('./migration.js').then(m => m.showOptionsModal([btn.dataset.id])); }); }); // View Template links document.querySelectorAll('.btn-view-template').forEach(btn => { btn.addEventListener('click', () => navigate(`#/templates/${btn.dataset.id}`)); }); } function _blockerItem(t) { const blockers = t.blockers || []; return `
đŸšĢ
${escHtml(t.name)}
${blockers.map(b => `
â€ĸ ${escHtml(b)}
`).join('')}
Modified ${formatDate(t.adobe_modified)}
`; } function _warningItem(t) { const warnings = t.warnings || []; return `
âš ī¸
${escHtml(t.name)}
${warnings.slice(0, 3).map(w => `
â€ĸ ${escHtml(w)}
`).join('')} ${warnings.length > 3 ? `
â€Ļ +${warnings.length - 3} more
` : ''}
Modified ${formatDate(t.adobe_modified)}
`; }