Skip to content

Commit a410dc1

Browse files
authored
SS-1973 fix flickering text (#558)
1 parent 308e905 commit a410dc1

4 files changed

Lines changed: 53 additions & 13 deletions

File tree

static/css/serve-elements.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,29 @@ a.app-card-orcid-link.active::after {
388388
display: block;
389389
}
390390

391+
.app-details-orcid-link {
392+
display: inline-flex !important;
393+
align-items: flex-start;
394+
gap: 0.35rem;
395+
line-height: 1.625;
396+
text-decoration: none !important;
397+
}
398+
399+
.app-details-orcid-link::after,
400+
.app-details-orcid-link:hover::after,
401+
.app-details-orcid-link:focus::after,
402+
.app-details-orcid-link.active::after {
403+
content: none !important;
404+
}
405+
406+
.app-details-orcid-icon {
407+
width: 1rem;
408+
height: 1rem;
409+
display: block;
410+
flex-shrink: 0;
411+
margin-top: 0.3rem;
412+
}
413+
391414
.orcid-id-link {
392415
color: var(--serve-lime) !important;
393416
text-decoration: none !important;

static/js/adaptive-polling.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
if (stopped || document.hidden) {
1717
return;
1818
}
19-
timer = window.setTimeout(run, delay);
19+
const safeDelay = Number.isFinite(delay) && delay > 0 ? delay : errorDelay;
20+
timer = window.setTimeout(run, safeDelay);
2021
};
2122

2223
const run = async () => {

templates/apps/deployment_progress.html

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
4545
<div class="small text-muted mb-4" id="progress-next-step">
4646
We will open the app details page automatically when everything is ready.
4747
</div>
48-
<div class="small text-warning d-none mb-4" id="progress-poll-warning">
49-
Could not load the latest deployment update. Retrying automatically.
50-
</div>
5148

5249
<div class="d-flex flex-wrap gap-2">
5350
<a href="{{ form_url }}" class="btn btn-outline-secondary">Back to form</a>
@@ -75,6 +72,7 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
7572
const ACTIVE_STATUS_POLL_MS = 3000;
7673
const STABLE_STATUS_POLL_MS = 30000;
7774
const ERROR_STATUS_POLL_MS = 10000;
75+
const REQUIRED_ERROR_POLLS = 3;
7876
const TERMINAL_STEP_STATUSES = new Set(["success", "warning", "failed", "skipped"]);
7977
const STEP_ROW_CLASS_BY_STATUS = {
8078
failed: "is-failed",
@@ -107,6 +105,7 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
107105
let consecutiveSuccessPolls = 0;
108106
let consecutiveErrorPolls = 0;
109107
let stepRevealTimer = null;
108+
let pageIsUnloading = false;
110109
let latestServerData = {
111110
deployment: {
112111
status: "{{ deployment.status|default:'pending'|escapejs }}",
@@ -132,13 +131,17 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
132131
}
133132
}
134133

135-
function updatePollWarning(isVisible) {
136-
const warning = document.getElementById("progress-poll-warning");
137-
if (warning) {
138-
warning.classList.toggle("d-none", !isVisible);
134+
function showInlinePollError() {
135+
const inline = document.getElementById("progress-inline");
136+
if (inline) {
137+
inline.textContent = "Could not load the latest deployment update. Retrying automatically.";
139138
}
140139
}
141140

141+
function shouldIgnorePollError(error) {
142+
return pageIsUnloading || document.hidden || error?.name === "AbortError";
143+
}
144+
142145
function copyProgressData(data = {}) {
143146
return {
144147
deployment: {...(data.deployment || {})},
@@ -378,6 +381,7 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
378381
}
379382
if (!successRedirectTimer) {
380383
successRedirectTimer = window.setTimeout(() => {
384+
progressPoller?.stop();
381385
window.location.assign(detailUrl);
382386
}, SUCCESS_REDIRECT_DELAY_MS);
383387
}
@@ -503,7 +507,6 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
503507
})
504508
.then(data => {
505509
consecutiveErrorPolls = 0;
506-
updatePollWarning(false);
507510
const fresh = copyProgressData(data);
508511

509512
if (isProgressSuccessful(fresh)) {
@@ -527,9 +530,14 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
527530
return canSlowPoll ? STABLE_STATUS_POLL_MS : ACTIVE_STATUS_POLL_MS;
528531
})
529532
.catch(error => {
533+
if (shouldIgnorePollError(error)) {
534+
return ERROR_STATUS_POLL_MS;
535+
}
530536
console.error("Error fetching deployment progress:", error);
531537
consecutiveErrorPolls += 1;
532-
updatePollWarning(consecutiveErrorPolls >= 2);
538+
if (consecutiveErrorPolls >= REQUIRED_ERROR_POLLS) {
539+
showInlinePollError();
540+
}
533541
throw error;
534542
});
535543
}
@@ -547,11 +555,19 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
547555
displayedProgressData = copyProgressData(latestServerData);
548556
renderProgress(displayedProgressData);
549557
maybeRedirectToDetails(displayedProgressData);
558+
window.serveDeploymentProgressPoller?.stop();
550559
progressPoller = ServeAdaptivePolling.createPoller({
551560
poll: refreshProgress,
552561
getDelay: delay => delay,
553562
errorDelay: ERROR_STATUS_POLL_MS
554563
});
564+
window.serveDeploymentProgressPoller = progressPoller;
565+
});
566+
567+
window.addEventListener("pagehide", () => {
568+
pageIsUnloading = true;
569+
progressPoller?.stop();
570+
window.serveDeploymentProgressPoller?.stop();
555571
});
556572
</script>
557573
{% endblock %}

templates/common/app_details.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ <h2 class="h5 mb-0">Creators</h2>
194194
<a href="https://orcid.org/{{ creator.person_or_org.identifiers.0.identifier }}"
195195
target="_blank"
196196
rel="noopener"
197-
class="value-label fw-normal text-dark card-username text-decoration-none"
197+
class="value-label fw-normal text-dark card-username text-decoration-none app-details-orcid-link"
198198
data-bs-toggle="tooltip"
199199
data-bs-placement="top"
200200
title="{% if creator.affiliations %}{% for aff in creator.affiliations %}{{ aff.name }}{% if not forloop.last %}, {% endif %}{% endfor %}{% else %}No affiliations{% endif %}">
201-
<img src="/static/images/orcid_16x16.png" alt="ORCID" width="16" height="16" class="me-1">
202-
{{ creator.person_or_org.name }}
201+
<img src="{% static 'images/orcid-vector.svg' %}" alt="ORCID" width="16" height="16" class="app-details-orcid-icon">
202+
<span>{{ creator.person_or_org.name }}</span>
203203
</a>
204204
{% else %}
205205
<span class="value-label fw-normal text-dark card-username"

0 commit comments

Comments
 (0)