manage: update state tooltips; add filter option

* update state is shown in tooltips that fade out in 10 sec except for .update-problem and .can-update
* when updates are found a filtering option is revealed; when it's checked only entries with updates are shown; when all updates are installed the option automatically hides
This commit is contained in:
tophf 2017-04-09 19:04:00 +03:00
parent 311d036dee
commit 2a7231a887
4 changed files with 84 additions and 17 deletions

View File

@ -282,6 +282,10 @@
"message": "Only edited styles", "message": "Only edited styles",
"description": "Checkbox to show only locally edited styles" "description": "Checkbox to show only locally edited styles"
}, },
"manageOnlyUpdates": {
"message": "Only with updates",
"description": "Checkbox to show only styles that have updates after check-all-styles-for-updates was performed"
},
"manageNewUI": { "manageNewUI": {
"message": "New manage UI layout", "message": "New manage UI layout",
"description": "Label for the checkbox that toggles the new UI on manage page" "description": "Label for the checkbox that toggles the new UI on manage page"

View File

@ -215,7 +215,7 @@ summary {
width: 60px; width: 60px;
height: 20px; height: 20px;
white-space: nowrap; white-space: nowrap;
font-size: 0; z-index: 999;
} }
.newUI .actions > * { .newUI .actions > * {
@ -244,10 +244,44 @@ summary {
display: inline; display: inline;
} }
.newUI .can-update .update,
.newUI .no-update.update-problem .check-update {
cursor: pointer;
}
.update-problem .check-update svg { .update-problem .check-update svg {
fill: darkred; fill: darkred;
} }
.updater-icons > :not(.check-update):after {
content: attr(title);
position: absolute;
margin-top: 18px;
margin-left: -36px;
padding: 1ex 1.5ex;
border: 1px solid #ded597;
background-color: #fffbd6;
border-radius: 4px;
box-shadow: 2px 3px 10px rgba(0,0,0,.25);
font-size: 90%;
animation: fadeout 10s;
animation-fill-mode: both;
z-index: 999;
}
.update-problem .check-update:after {
background-color: red;
border: 1px solid #d40000;
color: white;
animation: none;
}
.can-update .update:after {
background-color: #c0fff0;
border: 1px solid #89cac9;
animation: none;
}
.newUI .applies-to { .newUI .applies-to {
padding-top: .25rem; padding-top: .25rem;
padding-bottom: .25rem; padding-bottom: .25rem;
@ -400,8 +434,13 @@ fieldset {
margin: 1em 0; margin: 1em 0;
} }
fieldset > * {
display: block;
}
.enabled-only > .disabled, .enabled-only > .disabled,
.edited-only > .updatable { .edited-only > .updatable,
.updates-only > .entry:not(.can-update) {
display: none; display: none;
} }

View File

@ -129,17 +129,10 @@
<h1 id="manage-heading" i18n-text="manageHeading"></h1> <h1 id="manage-heading" i18n-text="manageHeading"></h1>
<fieldset> <fieldset>
<legend id="filters" i18n-text="manageFilters"></legend> <legend id="filters" i18n-text="manageFilters"></legend>
<div> <label><input id="manage.onlyEnabled" type="checkbox"><span i18n-text="manageOnlyEnabled"></span></label>
<input id="manage.onlyEnabled" type="checkbox"> <label><input id="manage.onlyEdited" type="checkbox"><span i18n-text="manageOnlyEdited"></span></label>
<label id="manage.onlyEnabled-label" for="manage.onlyEnabled" i18n-text="manageOnlyEnabled"></label> <label id="onlyUpdates" class="hidden"><input type="checkbox"><span i18n-text="manageOnlyUpdates"></span></label>
</div> <input id="search" type="search" i18n-placeholder="searchStyles">
<div>
<input id="manage.onlyEdited" type="checkbox">
<label id="manage.onlyEdited-label" for="manage.onlyEdited" i18n-text="manageOnlyEdited"></label>
</div>
<div>
<input id="search" type="search" i18n-placeholder="searchStyles">
</div>
</fieldset> </fieldset>
<p> <p>
<button id="check-all-updates" i18n-text="checkAllUpdates"></button> <button id="check-all-updates" i18n-text="checkAllUpdates"></button>

View File

@ -70,6 +70,7 @@ function initGlobalEvents() {
for (const [className, checkbox] of [ for (const [className, checkbox] of [
['enabled-only', $('#manage.onlyEnabled')], ['enabled-only', $('#manage.onlyEnabled')],
['edited-only', $('#manage.onlyEdited')], ['edited-only', $('#manage.onlyEdited')],
['updates-only', $('#onlyUpdates input')],
]) { ]) {
// will be triggered by setupLivePrefs immediately // will be triggered by setupLivePrefs immediately
checkbox.onchange = () => installed.classList.toggle(className, checkbox.checked); checkbox.onchange = () => installed.classList.toggle(className, checkbox.checked);
@ -269,8 +270,7 @@ Object.assign(handleEvent, {
}, },
toggle(event, entry) { toggle(event, entry) {
enableStyle(entry.styleId, this.matches('.enable') || this.checked) enableStyle(entry.styleId, this.matches('.enable') || this.checked);
.then(handleUpdate);
}, },
check(event, entry) { check(event, entry) {
@ -336,6 +336,7 @@ function handleUpdate(style, {reason, quiet} = {}) {
element.classList.add('update-done'); element.classList.add('update-done');
element.classList.remove('can-update', 'updatable'); element.classList.remove('can-update', 'updatable');
$('.update-note', element).innerHTML = t('updateCompleted'); $('.update-note', element).innerHTML = t('updateCompleted');
renderUpdatesOnlyFilter();
} }
} }
installed.insertBefore(element, findNextElement(style)); installed.insertBefore(element, findNextElement(style));
@ -398,6 +399,8 @@ function applyUpdateAll() {
button.scrollIntoView(false); button.scrollIntoView(false);
button.click(); button.click();
}); });
renderUpdatesOnlyFilter({show: false});
} }
@ -410,7 +413,7 @@ function checkUpdateAll() {
btnApply.classList.add('hidden'); btnApply.classList.add('hidden');
noUpdates.classList.add('hidden'); noUpdates.classList.add('hidden');
Promise.all($$('.updatable').map(checkUpdate)) Promise.all($$('.updatable:not(.can-update)').map(checkUpdate))
.then(updatables => { .then(updatables => {
btnCheck.disabled = false; btnCheck.disabled = false;
const numUpdatable = updatables.filter(u => u).length; const numUpdatable = updatables.filter(u => u).length;
@ -418,6 +421,7 @@ function checkUpdateAll() {
btnApply.classList.remove('hidden'); btnApply.classList.remove('hidden');
btnApply.originalLabel = btnApply.originalLabel || btnApply.textContent; btnApply.originalLabel = btnApply.originalLabel || btnApply.textContent;
btnApply.textContent = btnApply.originalLabel + ` (${numUpdatable})`; btnApply.textContent = btnApply.originalLabel + ` (${numUpdatable})`;
renderUpdatesOnlyFilter({check: true});
} else { } else {
noUpdates.classList.remove('hidden'); noUpdates.classList.remove('hidden');
setTimeout(() => { setTimeout(() => {
@ -436,7 +440,7 @@ function checkUpdateAll() {
function checkUpdate(element) { function checkUpdate(element) {
$('.update-note', element).innerHTML = t('checkingForUpdate'); $('.update-note', element).innerHTML = t('checkingForUpdate');
$('.check-update', element).title = ''; $('.check-update', element).title = '';
element.classList.remove('checking-update', 'no-update', 'can-update', 'update-problem'); element.classList.remove('checking-update', 'no-update', 'update-problem');
element.classList.add('checking-update'); element.classList.add('checking-update');
return new Updater(element).run(); // eslint-disable-line no-use-before-define return new Updater(element).run(); // eslint-disable-line no-use-before-define
} }
@ -506,6 +510,7 @@ class Updater {
this.element.classList.add('can-update'); this.element.classList.add('can-update');
this.element.updatedCode = json; this.element.updatedCode = json;
$('.update-note', this.element).innerHTML = ''; $('.update-note', this.element).innerHTML = '';
$('#onlyUpdates').classList.remove('hidden');
} else { } else {
this.element.classList.add('no-update'); this.element.classList.add('no-update');
this.element.classList.toggle('update-problem', Boolean(message)); this.element.classList.toggle('update-problem', Boolean(message));
@ -513,6 +518,10 @@ class Updater {
if (newUI.enabled) { if (newUI.enabled) {
$('.check-update', this.element).title = message; $('.check-update', this.element).title = message;
} }
// don't hide if check-all is running
if (!$('#check-all-updates').disabled) {
$('#onlyUpdates').classList.toggle('hidden', !$('.can-update'));
}
} }
} }
@ -537,6 +546,28 @@ class Updater {
} }
function renderUpdatesOnlyFilter({show, check} = {}) {
const numUpdatable = $$('.can-update').length;
const canUpdate = numUpdatable > 0;
const checkbox = $('#onlyUpdates input');
show = show !== undefined ? show : canUpdate;
check = check !== undefined ? show && check : checkbox.checked && canUpdate;
$('#onlyUpdates').classList.toggle('hidden', !show);
checkbox.checked = check;
checkbox.dispatchEvent(new Event('change'));
const btnApply = $('#apply-all-updates');
if (!btnApply.matches('.hidden')) {
if (canUpdate) {
btnApply.textContent = btnApply.originalLabel + ` (${numUpdatable})`;
} else {
btnApply.classList.add('hidden');
}
}
}
function searchStyles({immediately, container}) { function searchStyles({immediately, container}) {
const query = $('#search').value.toLocaleLowerCase(); const query = $('#search').value.toLocaleLowerCase();
if (query == (searchStyles.lastQuery || '') && !immediately && !container) { if (query == (searchStyles.lastQuery || '') && !immediately && !container) {