From 69d68fbe8e2f9771a9542d11bdaf10b129a04fcf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 2 Oct 2015 12:15:07 +0200 Subject: Reload the page when an app needs an update after being enabled --- settings/ajax/enableapp.php | 5 +++-- settings/js/apps.js | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index 55298430e28..af80193ebc4 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -28,8 +28,9 @@ OCP\JSON::callCheck(); $groups = isset($_POST['groups']) ? (array)$_POST['groups'] : null; try { - OC_App::enable(OC_App::cleanAppId((string)$_POST['appid']), $groups); - OC_JSON::success(); + $app = OC_App::cleanAppId((string)$_POST['appid']); + OC_App::enable($app, $groups); + OC_JSON::success(['data' => ['update_required' => \OC_App::shouldUpgrade($app)]]); } catch (Exception $e) { \OCP\Util::writeLog('core', $e->getMessage(), \OCP\Util::ERROR); OC_JSON::error(array("data" => array("message" => $e->getMessage()) )); diff --git a/settings/js/apps.js b/settings/js/apps.js index f775ecad620..2a6876c53df 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -245,6 +245,14 @@ OC.Settings.Apps = OC.Settings.Apps || { element.val(t('settings','Enable')); appItem.addClass('appwarning'); } else { + if (result.data.update_required) { + OC.Notification.show(t('settings', 'The app needs to be updated, please reload the page')); + + setTimeout(function() { + location.reload(); + }, 5000); + } + OC.Settings.Apps.rebuildNavigation(); appItem.data('active',true); element.data('active',true); -- cgit v1.2.3 From 264d123396725288b4d2b1ef766dded03096fb0c Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 2 Oct 2015 14:12:29 +0200 Subject: Use OC.Dialogs for modal reload message --- settings/js/apps.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/settings/js/apps.js b/settings/js/apps.js index 2a6876c53df..325653ccbdc 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -246,7 +246,7 @@ OC.Settings.Apps = OC.Settings.Apps || { appItem.addClass('appwarning'); } else { if (result.data.update_required) { - OC.Notification.show(t('settings', 'The app needs to be updated, please reload the page')); + OC.Settings.Apps.showReloadMessage(); setTimeout(function() { location.reload(); @@ -398,6 +398,20 @@ OC.Settings.Apps = OC.Settings.Apps || { .text(''); }, + showReloadMessage: function(appId) { + OC.dialogs.info( + t( + 'settings', + 'The app needs to be updated. This page will be reloaded in 5 seconds.' + ), + t('settings','App update'), + function (result) { + window.location.reload(); + }, + true + ); + }, + filter: function(query) { query = query.toLowerCase(); $('#apps-list').find('.section').addClass('hidden'); -- cgit v1.2.3 From 999196b9fb2a16822ca0fb6effebbdf52adc374b Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 6 Oct 2015 11:34:06 +0200 Subject: fix wording --- settings/js/apps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/js/apps.js b/settings/js/apps.js index 325653ccbdc..d51c642c9c9 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -402,7 +402,7 @@ OC.Settings.Apps = OC.Settings.Apps || { OC.dialogs.info( t( 'settings', - 'The app needs to be updated. This page will be reloaded in 5 seconds.' + 'The app has been enabled but needs to be updated. You will be redirected to the update page in 5 seconds.' ), t('settings','App update'), function (result) { -- cgit v1.2.3