diff options
author | Julius Härtl <jus@bitgrid.net> | 2017-10-04 14:23:51 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-10-10 12:34:38 +0200 |
commit | bee9ef83c65689990dba852b1944b5cf472eae43 (patch) | |
tree | 1bc25ac5d2742ea30217bb7a29bc4a065da53d30 /settings | |
parent | a3502c5c670456e1c3ea2476b31f681a37839e8d (diff) | |
download | nextcloud-server-bee9ef83c65689990dba852b1944b5cf472eae43.tar.gz nextcloud-server-bee9ef83c65689990dba852b1944b5cf472eae43.zip |
App management: Do not show udpdate category if no updates are available
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'settings')
-rw-r--r-- | settings/js/apps.js | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js index ea6bd6ea5c6..6406e37cbcb 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -42,7 +42,6 @@ OC.Settings.Apps = OC.Settings.Apps || { var categories = [ {displayName: t('settings', 'Your apps'), ident: 'installed', id: '0'}, - {displayName: t('settings', 'Updates'), ident: 'updates', id: '3'}, {displayName: t('settings', 'Enabled apps'), ident: 'enabled', id: '1'}, {displayName: t('settings', 'Disabled apps'), ident: 'disabled', id: '2'} ]; @@ -65,7 +64,6 @@ OC.Settings.Apps = OC.Settings.Apps || { $('#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(); } @@ -130,6 +128,7 @@ OC.Settings.Apps = OC.Settings.Apps || { } var firstExperimental = false; + var hasNewUpdates = false; _.each(appList, function(app) { if(app.level === 0 && firstExperimental === false) { firstExperimental = true; @@ -139,11 +138,20 @@ OC.Settings.Apps = OC.Settings.Apps || { } if (app.update) { + hasNewUpdates = true; var $update = $('#app-' + app.id + ' .update'); $update.removeClass('hidden'); $update.val(t('settings', 'Update to %s').replace(/%s/g, app.update)); } }); + // reload updates if a list with new updates is loaded + if (hasNewUpdates) { + OC.Settings.Apps.reloadUpdates(); + } else { + // hide update category after all updates are installed + // and the user is switching away from the empty updates view + OC.Settings.Apps.refreshUpdateCounter(); + } } else { if (categoryId === 'updates') { OC.Settings.Apps.showEmptyUpdates(); @@ -671,12 +679,30 @@ OC.Settings.Apps = OC.Settings.Apps || { }); }, + reloadUpdates: function() { + if (this._loadUpdatesCall) { + this._loadUpdatesCall.abort(); + } + this._loadUpdatesCall = $.ajax(OC.generateUrl('settings/apps/list?category=updates'), { + type:'GET', + success: function (apps) { + OC.Settings.Apps.State.availableUpdates = apps.apps.length; + OC.Settings.Apps.refreshUpdateCounter(); + } + }); + }, + refreshUpdateCounter: function() { - var $updateCount = $('#app-category-updates').find('.app-navigation-entry-utils-counter'); + var $appCategoryUpdates = $('#app-category-updates'); + var $updateCount = $appCategoryUpdates.find('.app-navigation-entry-utils-counter'); if (OC.Settings.Apps.State.availableUpdates > 0) { $updateCount.html(OC.Settings.Apps.State.availableUpdates); + $appCategoryUpdates.show(); } else { $updateCount.empty(); + if (OC.Settings.Apps.State.currentCategory !== 'updates') { + $appCategoryUpdates.hide(); + } } }, @@ -727,6 +753,7 @@ OC.Settings.Apps = OC.Settings.Apps || { filter: function(query) { var $appList = $('#apps-list'), $emptyList = $('#apps-list-empty'); + $('#app-list-empty-icon').addClass('icon-search').removeClass('icon-download'); $appList.removeClass('hidden'); $appList.find('.section').removeClass('hidden'); $emptyList.addClass('hidden'); |