Skip to content

Commit e6d0502

Browse files
committed
fix: improve report template modal scrolling and allow renaming
Make the template editor modal content panes reliably scroll for large markdown bodies and allow editing template names in edit mode, with old-name cleanup on save when renamed. Made-with: Cursor
1 parent 3d9dc7b commit e6d0502

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

internal/modules/gobot/ui/app.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ const state = {
184184
_shellWired: false,
185185
_r2BrowserWired: false,
186186
_metricsTimer: null,
187+
reportTemplateOriginalName: '',
187188
};
188189

189190
// ── Router ────────────────────────────────────────────────────────────────────
@@ -7801,7 +7802,9 @@ async function openReportTemplateModal(name = '') {
78017802
if (!modal || !title || !nameInput || !contentInput) return;
78027803

78037804
nameInput.value = name;
7804-
nameInput.readOnly = name !== '';
7805+
// Allow renaming existing templates.
7806+
nameInput.readOnly = false;
7807+
state.reportTemplateOriginalName = name || '';
78057808
contentInput.value = '';
78067809
title.textContent = name ? '📝 Edit Template' : '➕ New Template';
78077810

@@ -7832,12 +7835,14 @@ function updateTemplatePreview() {
78327835

78337836
function closeReportTemplateModal() {
78347837
const modal = document.getElementById('modal-report-template');
7838+
state.reportTemplateOriginalName = '';
78357839
if (modal) modal.style.display = 'none';
78367840
}
78377841

78387842
async function saveReportTemplate() {
78397843
const name = document.getElementById('report-template-name').value.trim();
78407844
const content = document.getElementById('report-template-content').value;
7845+
const originalName = String(state.reportTemplateOriginalName || '').trim();
78417846

78427847
if (!name || !content) {
78437848
showToast('error', 'Validation', 'Name and content are required');
@@ -7857,6 +7862,19 @@ async function saveReportTemplate() {
78577862
throw new Error(data.error || 'Failed to save template');
78587863
}
78597864

7865+
// If this was a rename, remove the old template key.
7866+
if (originalName && originalName !== name) {
7867+
try {
7868+
const delHeaders = await buildAuthHeaders();
7869+
await fetch(`${API}/api/report-templates/${encodeURIComponent(originalName)}`, {
7870+
method: 'DELETE',
7871+
headers: delHeaders,
7872+
});
7873+
} catch (_) {
7874+
// Best effort: keep successful save even if old key cleanup fails.
7875+
}
7876+
}
7877+
78607878
showToast('success', 'Template Saved', `Template "${name}" saved successfully`);
78617879
closeReportTemplateModal();
78627880
renderReportTemplates();

internal/modules/gobot/ui/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,29 +649,29 @@ <h1 class="view-title">📝 Report Templates</h1>
649649

650650
<!-- Modal: Report Template Editor -->
651651
<div id="modal-report-template" class="auth-gate" style="display:none" aria-modal="true" role="dialog">
652-
<div class="auth-card" style="width: 95%; max-width: 1200px; padding: 24px; height: 90vh; display: flex; flex-direction: column;">
652+
<div class="auth-card" style="width: 95%; max-width: 1200px; padding: 24px; height: 90vh; display: flex; flex-direction: column; overflow: hidden;">
653653
<div class="view-header" style="margin-bottom: 20px; flex-shrink: 0;">
654654
<h2 class="view-title" id="report-template-modal-title">📝 Edit Template</h2>
655655
<div class="view-subtitle">Markdown format supported with real-time preview</div>
656656
</div>
657657

658-
<div class="auth-form" style="display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0;">
658+
<div class="auth-form" style="display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; overflow: hidden;">
659659
<div style="flex-shrink: 0;">
660660
<label class="auth-label" for="report-template-name">Template Name</label>
661661
<input class="search-input auth-input" id="report-template-name" type="text" placeholder="e.g. pentest-report" required />
662662
</div>
663663

664-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; flex: 1; min-height: 0;">
665-
<div style="display: flex; flex-direction: column;">
664+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; flex: 1; min-height: 0; overflow: hidden;">
665+
<div style="display: flex; flex-direction: column; min-height: 0;">
666666
<label class="auth-label">Markdown Editor</label>
667667
<textarea id="report-template-content" class="search-input auth-input"
668-
style="flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.5; padding: 12px; resize: none; background: #010409;"
668+
style="flex: 1; min-height: 0; overflow-y: auto; font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.5; padding: 12px; resize: none; background: #010409;"
669669
placeholder="# My Report Template..." oninput="updateTemplatePreview()"></textarea>
670670
</div>
671-
<div style="display: flex; flex-direction: column;">
671+
<div style="display: flex; flex-direction: column; min-height: 0;">
672672
<label class="auth-label">Live Preview</label>
673673
<div id="report-template-preview" class="search-input"
674-
style="flex: 1; overflow-y: auto; padding: 16px; background: #0d1117; border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); font-size: 14px;"></div>
674+
style="flex: 1; min-height: 0; overflow-y: auto; padding: 16px; background: #0d1117; border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); font-size: 14px;"></div>
675675
</div>
676676
</div>
677677

0 commit comments

Comments
 (0)