App management: Show proper message when no updates are available

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2017-10-03 18:15:14 +02:00
parent 6f7fb2e87b
commit a3502c5c67
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 32 additions and 7 deletions

View File

@ -62,11 +62,13 @@ OC.Settings.Apps = OC.Settings.Apps || {
var updateCategory = $.grep(jsondata, function(element, index) {
return element.ident === 'updates'
});
if (updateCategory.length === 1) {
OC.Settings.Apps.State.availableUpdates = updateCategory[0].counter;
}
$('#apps-categories').html(html);
$('#app-category-' + OC.Settings.Apps.State.currentCategory).addClass('active');
if (updateCategory.length === 1) {
console.log(updateCategory);
OC.Settings.Apps.State.availableUpdates = updateCategory[0].counter;
OC.Settings.Apps.refreshUpdateCounter();
}
},
complete: function() {
$('#app-navigation').removeClass('icon-loading');
@ -143,8 +145,13 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
});
} else {
$('#apps-list').addClass('hidden');
$('#apps-list-empty').removeClass('hidden').find('h2').text(t('settings', 'No apps found for your version'));
if (categoryId === 'updates') {
OC.Settings.Apps.showEmptyUpdates();
} else {
$('#apps-list').addClass('hidden');
$('#apps-list-empty').removeClass('hidden').find('h2').text(t('settings', 'No apps found for your version'));
$('#app-list-empty-icon').addClass('icon-search').removeClass('icon-download');
}
}
$('.enable.needs-download').tooltip({
@ -518,6 +525,12 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
},
showEmptyUpdates: function() {
$('#apps-list').addClass('hidden');
$('#apps-list-empty').removeClass('hidden').find('h2').text(t('settings', 'No app updates available'));
$('#app-list-empty-icon').removeClass('icon-search').addClass('icon-download');
},
updateApp:function(appId, element) {
var oldButtonText = element.val();
element.val(t('settings','Updating....'));
@ -542,6 +555,13 @@ OC.Settings.Apps = OC.Settings.Apps || {
OC.Settings.Apps.State.availableUpdates--;
OC.Settings.Apps.refreshUpdateCounter();
if (OC.Settings.Apps.State.currentCategory === 'updates') {
$('#app-' + appId).remove();
if (OC.Settings.Apps.State.availableUpdates === 0) {
OC.Settings.Apps.showEmptyUpdates();
}
}
}
},'json');
},
@ -652,7 +672,12 @@ OC.Settings.Apps = OC.Settings.Apps || {
},
refreshUpdateCounter: function() {
$('#app-category-updates').find('.app-navigation-entry-utils-counter').html(OC.Settings.Apps.State.availableUpdates);
var $updateCount = $('#app-category-updates').find('.app-navigation-entry-utils-counter');
if (OC.Settings.Apps.State.availableUpdates > 0) {
$updateCount.html(OC.Settings.Apps.State.availableUpdates);
} else {
$updateCount.empty();
}
},
showErrorMessage: function(appId, message) {

View File

@ -208,7 +208,7 @@ script(
</svg>
<div id="apps-list"></div>
<div id="apps-list-empty" class="hidden emptycontent emptycontent-search">
<div class="icon-search"></div>
<div id="app-list-empty-icon" class="icon-search"></div>
<h2><?php p($l->t('No apps found for your version')) ?></h2>
</div>
</div>