Stay on the same category when refreshing the page on the apps list
This commit is contained in:
parent
5181e5c29a
commit
a9a6d4c182
4 changed files with 31 additions and 8 deletions
|
@ -96,11 +96,13 @@ class AppSettingsController extends Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
|
* @param int $category
|
||||||
* @return TemplateResponse
|
* @return TemplateResponse
|
||||||
*/
|
*/
|
||||||
public function viewApps() {
|
public function viewApps($category = 0) {
|
||||||
$params = [];
|
$params = [];
|
||||||
$params['experimentalEnabled'] = $this->config->getSystemValue('appstore.experimental.enabled', false);
|
$params['experimentalEnabled'] = $this->config->getSystemValue('appstore.experimental.enabled', false);
|
||||||
|
$params['category'] = $category;
|
||||||
$this->navigationManager->setActiveEntry('core_apps');
|
$this->navigationManager->setActiveEntry('core_apps');
|
||||||
|
|
||||||
$templateResponse = new TemplateResponse($this->appName, 'apps', $params, 'user');
|
$templateResponse = new TemplateResponse($this->appName, 'apps', $params, 'user');
|
||||||
|
|
|
@ -40,7 +40,8 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
}
|
}
|
||||||
|
|
||||||
var categories = [
|
var categories = [
|
||||||
{displayName: 'Enabled', id: '0'}
|
{displayName: t('settings', 'Enabled'), id: '0'},
|
||||||
|
{displayName: t('settings', 'Not enabled'), id: '1'}
|
||||||
];
|
];
|
||||||
|
|
||||||
var source = $("#categories-template").html();
|
var source = $("#categories-template").html();
|
||||||
|
@ -48,7 +49,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
var html = template(categories);
|
var html = template(categories);
|
||||||
$('#apps-categories').html(html);
|
$('#apps-categories').html(html);
|
||||||
|
|
||||||
OC.Settings.Apps.loadCategory(0);
|
OC.Settings.Apps.loadCategory(parseInt($('#app-navigation').attr('data-category'), 10));
|
||||||
|
|
||||||
this._loadCategoriesCall = $.ajax(OC.generateUrl('settings/apps/categories'), {
|
this._loadCategoriesCall = $.ajax(OC.generateUrl('settings/apps/categories'), {
|
||||||
data:{},
|
data:{},
|
||||||
|
@ -398,14 +399,14 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
.text('');
|
.text('');
|
||||||
},
|
},
|
||||||
|
|
||||||
showReloadMessage: function(appId) {
|
showReloadMessage: function() {
|
||||||
OC.dialogs.info(
|
OC.dialogs.info(
|
||||||
t(
|
t(
|
||||||
'settings',
|
'settings',
|
||||||
'The app has been enabled but needs to be updated. You will be redirected to the update page 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'),
|
t('settings','App update'),
|
||||||
function (result) {
|
function () {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
|
@ -443,6 +444,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
$(document).on('click', 'ul#apps-categories li', function () {
|
$(document).on('click', 'ul#apps-categories li', function () {
|
||||||
var categoryId = $(this).data('categoryId');
|
var categoryId = $(this).data('categoryId');
|
||||||
OC.Settings.Apps.loadCategory(categoryId);
|
OC.Settings.Apps.loadCategory(categoryId);
|
||||||
|
OC.Util.History.pushState('category=' + categoryId);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.app-description-toggle-show', function () {
|
$(document).on('click', '.app-description-toggle-show', function () {
|
||||||
|
@ -508,7 +510,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '#enable-experimental-apps', function () {
|
$(document).on('click', '#enable-experimental-apps', function () {
|
||||||
var state = $(this).prop('checked')
|
var state = $(this).prop('checked');
|
||||||
$.ajax(OC.generateUrl('settings/apps/experimental'), {
|
$.ajax(OC.generateUrl('settings/apps/experimental'), {
|
||||||
data: {state: state},
|
data: {state: state},
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
|
@ -127,7 +127,7 @@ script(
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="app-navigation" class="icon-loading">
|
<div id="app-navigation" class="icon-loading" data-category="<?php p($_['category']);?>">
|
||||||
<ul id="apps-categories">
|
<ul id="apps-categories">
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -223,9 +223,28 @@ class AppSettingsControllerTest extends TestCase {
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
$policy->addAllowedImageDomain('https://apps.owncloud.com');
|
$policy->addAllowedImageDomain('https://apps.owncloud.com');
|
||||||
|
|
||||||
$expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false], 'user');
|
$expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 0], 'user');
|
||||||
$expected->setContentSecurityPolicy($policy);
|
$expected->setContentSecurityPolicy($policy);
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->appSettingsController->viewApps());
|
$this->assertEquals($expected, $this->appSettingsController->viewApps());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testViewAppsNotEnabled() {
|
||||||
|
$this->config
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('appstore.experimental.enabled', false);
|
||||||
|
$this->navigationManager
|
||||||
|
->expects($this->once())
|
||||||
|
->method('setActiveEntry')
|
||||||
|
->with('core_apps');
|
||||||
|
|
||||||
|
$policy = new ContentSecurityPolicy();
|
||||||
|
$policy->addAllowedImageDomain('https://apps.owncloud.com');
|
||||||
|
|
||||||
|
$expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 1], 'user');
|
||||||
|
$expected->setContentSecurityPolicy($policy);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $this->appSettingsController->viewApps(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue