Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2024-05-18 - Disabled and Loading States for Async Actions
**Learning:** Adding explicit loading and disabled states to asynchronous action buttons (like "Refresh") provides immediate feedback, reducing user confusion and preventing double-submissions.
**Action:** Always ensure that buttons triggering network requests visually indicate the loading state and are disabled until the request completes.

## 2026-07-06 - Async Button Loading States
**Learning:** Asynchronous action buttons (e.g., Refresh, Submit) in this app require explicit visual loading states (updating textContent and disabled=true) to prevent double-submissions and improve UX.
**Action:** Always implement disabled and text state changes on buttons triggering network requests, restoring them in a finally block.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ๋ณ€๊ฒฝ ์‚ฌํ•ญ (CHANGELOG)

## [Unreleased]
### ์ถ”๊ฐ€๋œ ๊ธฐ๋Šฅ (Added)
- `demo.js` ๋‚ด์˜ ๋น„๋™๊ธฐ ๋ฒ„ํŠผ(์ œ์ถœ, ์žฌ์‹œ๋„, ์ƒˆ๋กœ๊ณ ์นจ)์— ๋ช…์‹œ์ ์ธ ์‹œ๊ฐ์  ๋กœ๋”ฉ ์ƒํƒœ(๋ฒ„ํŠผ ๋น„ํ™œ์„ฑํ™” ๋ฐ ํ…์ŠคํŠธ ๋ณ€๊ฒฝ)๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ค‘๋ณต ์ œ์ถœ์„ ๋ฐฉ์ง€ํ•˜๊ณ  ์‚ฌ์šฉ์ž ๊ฒฝํ—˜(UX)์„ ํ–ฅ์ƒ์‹œ์ผฐ์Šต๋‹ˆ๋‹ค.
12 changes: 12 additions & 0 deletions src/main/resources/static/assets/viewer/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ async function retryActiveJob() {
const jobId = activeJobDetail.jobId;
setStatus("Requesting operator retry...");
el.retryJobBtn.disabled = true;
const originalText = el.retryJobBtn.textContent;
el.retryJobBtn.textContent = "Retrying...";
try {
const res = await fetch(`/api/v1/convert/jobs/${encodeURIComponent(jobId)}/retry`, {
method: "POST",
Expand Down Expand Up @@ -308,6 +310,7 @@ async function retryActiveJob() {
setError("Network error while requesting retry. Retry when the service is reachable.");
} finally {
el.retryJobBtn.disabled = false;
el.retryJobBtn.textContent = originalText;
}
}

Expand Down Expand Up @@ -380,6 +383,9 @@ async function refreshKpis() {
}

async function refreshKpiEvidence() {
el.refreshEvidenceBtn.disabled = true;
const originalText = el.refreshEvidenceBtn.textContent;
el.refreshEvidenceBtn.textContent = "Refreshing...";
try {
const { res, data } = await fetchJson(KPI_EXPORTS_ENDPOINT);
if (!res.ok) {
Expand All @@ -390,6 +396,9 @@ async function refreshKpiEvidence() {
renderKpiEvidence(data);
} catch (err) {
el.kpiExportStatus.textContent = "Snapshot evidence is unavailable while the service is unreachable.";
} finally {
el.refreshEvidenceBtn.disabled = false;
el.refreshEvidenceBtn.textContent = originalText;
}
}

Expand Down Expand Up @@ -436,6 +445,8 @@ async function submitDocument(event) {
}

el.submitBtn.disabled = true;
const originalText = el.submitBtn.textContent;
el.submitBtn.textContent = "Submitting...";
setStatus("Submitting document...");

try {
Expand Down Expand Up @@ -479,6 +490,7 @@ async function submitDocument(event) {
setError("Network error while submitting. Retry when the service is reachable.");
} finally {
el.submitBtn.disabled = false;
el.submitBtn.textContent = originalText;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ void demoScriptUsesExistingApiAndSessionHistory() throws Exception {
assertTrue(script.contains("X-Clearfolio-Tenant-Id"));
assertTrue(script.contains("X-Clearfolio-Permissions"));
assertTrue(script.contains("deadLettered"));
assertTrue(script.contains("Refreshing..."));
assertTrue(script.contains("Submitting..."));
assertTrue(script.contains("Retrying..."));
}
}

Expand Down
Loading