Skip to content

Commit

Permalink
Merge pull request #19526 from owncloud/issue-16251-reload-app-settin…
Browse files Browse the repository at this point in the history
…gs-when-app-needs-update

Reload the page when an app needs an update after being enabled
  • Loading branch information
DeepDiver1975 committed Oct 6, 2015
2 parents 319e61f + 999196b commit 6651aa1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions settings/ajax/enableapp.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
$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()) ));
Expand Down
22 changes: 22 additions & 0 deletions settings/js/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.Settings.Apps.showReloadMessage();

setTimeout(function() {
location.reload();
}, 5000);
}

OC.Settings.Apps.rebuildNavigation();
appItem.data('active',true);
element.data('active',true);
Expand Down Expand Up @@ -390,6 +398,20 @@ OC.Settings.Apps = OC.Settings.Apps || {
.text('');
},

showReloadMessage: function(appId) {
OC.dialogs.info(
t(
'settings',
'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) {
window.location.reload();
},
true
);
},

filter: function(query) {
query = query.toLowerCase();
$('#apps-list').find('.section').addClass('hidden');
Expand Down

0 comments on commit 6651aa1

Please sign in to comment.