Reload the page when an app needs an update after being enabled

This commit is contained in:
Joas Schilling 2015-10-02 12:15:07 +02:00 committed by Thomas Müller
parent 0577eed14e
commit 69d68fbe8e
2 changed files with 11 additions and 2 deletions

View File

@ -28,8 +28,9 @@ OCP\JSON::callCheck();
$groups = isset($_POST['groups']) ? (array)$_POST['groups'] : null; $groups = isset($_POST['groups']) ? (array)$_POST['groups'] : null;
try { try {
OC_App::enable(OC_App::cleanAppId((string)$_POST['appid']), $groups); $app = OC_App::cleanAppId((string)$_POST['appid']);
OC_JSON::success(); OC_App::enable($app, $groups);
OC_JSON::success(['data' => ['update_required' => \OC_App::shouldUpgrade($app)]]);
} catch (Exception $e) { } catch (Exception $e) {
\OCP\Util::writeLog('core', $e->getMessage(), \OCP\Util::ERROR); \OCP\Util::writeLog('core', $e->getMessage(), \OCP\Util::ERROR);
OC_JSON::error(array("data" => array("message" => $e->getMessage()) )); OC_JSON::error(array("data" => array("message" => $e->getMessage()) ));

View File

@ -245,6 +245,14 @@ OC.Settings.Apps = OC.Settings.Apps || {
element.val(t('settings','Enable')); element.val(t('settings','Enable'));
appItem.addClass('appwarning'); appItem.addClass('appwarning');
} else { } 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(); OC.Settings.Apps.rebuildNavigation();
appItem.data('active',true); appItem.data('active',true);
element.data('active',true); element.data('active',true);