show installation error inline, allow retrying (#1309)

This commit is contained in:
tophf 2021-08-12 16:44:02 +03:00 committed by GitHub
parent 434e7ff6c6
commit 304dcb1489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -229,6 +229,28 @@ search-result-meta [data-type="rating"][data-class="none"] dd {
cursor: help;
}
[data-error],
[data-error]:hover {
border: calc(var(--pad) / 2) solid red;
border-radius: var(--pad);
padding: calc(var(--pad) / 2);
background: hsl(0, 90%, 85%);
}
[data-error]::after {
content: attr(data-error);
display: block;
color: hsl(0, 100%, 8%);
font-weight: bold;
padding-top: var(--pad);
hyphens: auto;
}
[data-error] .search-result-description {
display: none;
}
[data-error] .search-result-meta {
background: hsla(0, 100%, 90%, .80);
}
.search-results-nav {
flex-direction: row;
text-align: center;

View File

@ -421,6 +421,7 @@
saveScrollPosition(entry);
installButton.disabled = true;
entry.style.setProperty('pointer-events', 'none', 'important');
delete entry.dataset.error;
if (!isUsw) {
// FIXME: move this to background page and create an API like installUSOStyle
result.pingbackTimer = setTimeout(download, PINGBACK_DELAY,
@ -434,7 +435,8 @@
const style = await API.usercss.install({sourceCode, updateUrl});
renderFullInfo(entry, style);
} catch (reason) {
error(`Error while downloading usoID:${id}\nReason: ${reason}`);
entry.dataset.error = `${t('genericError')}: ${reason}`;
entry.scrollIntoView({behavior: 'smooth', block: 'nearest'});
}
$remove('.lds-spinner', entry);
installButton.disabled = false;