Move Admin Settings also to info.xml

More cleanup of the Settings apps. Makes the manager cleaner and a
proper manager.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2020-01-31 16:55:17 +01:00
parent 78c7e6f2c5
commit bfaf3fff33
No known key found for this signature in database
GPG Key ID: F941078878347C0C
14 changed files with 45 additions and 79 deletions

View File

@ -18,6 +18,11 @@
</dependencies>
<settings>
<admin>OCA\Settings\Settings\Admin\Mail</admin>
<admin>OCA\Settings\Settings\Admin\Overview</admin>
<admin>OCA\Settings\Settomgs\Admin\Security</admin>
<admin>OCA\Settings\Settings\Admin\Server</admin>
<admin>OCA\Settings\Settings\Admin\Sharing</admin>
<admin-section>OCA\Settings\Sections\Admin\Additional</admin-section>
<admin-section>OCA\Settings\Sections\Admin\Groupware</admin-section>
<admin-section>OCA\Settings\Sections\Admin\Overview</admin-section>

View File

@ -13,11 +13,6 @@ return array(
'OCA\\Settings\\Activity\\SecurityProvider' => $baseDir . '/../lib/Activity/SecurityProvider.php',
'OCA\\Settings\\Activity\\SecuritySetting' => $baseDir . '/../lib/Activity/SecuritySetting.php',
'OCA\\Settings\\Activity\\Setting' => $baseDir . '/../lib/Activity/Setting.php',
'OCA\\Settings\\Admin\\Mail' => $baseDir . '/../lib/Settings/Admin/Mail.php',
'OCA\\Settings\\Admin\\Overview' => $baseDir . '/../lib/Settings/Admin/Overview.php',
'OCA\\Settings\\Admin\\Security' => $baseDir . '/../lib/Settings/Admin/Security.php',
'OCA\\Settings\\Admin\\Server' => $baseDir . '/../lib/Settings/Admin/Server.php',
'OCA\\Settings\\Admin\\Sharing' => $baseDir . '/../lib/Settings/Admin/Sharing.php',
'OCA\\Settings\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => $baseDir . '/../lib/BackgroundJobs/VerifyUserData.php',
'OCA\\Settings\\Controller\\AdminSettingsController' => $baseDir . '/../lib/Controller/AdminSettingsController.php',
@ -45,6 +40,11 @@ return array(
'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php',
'OCA\\Settings\\Sections\\Personal\\Security' => $baseDir . '/../lib/Sections/Personal/Security.php',
'OCA\\Settings\\Sections\\Personal\\SyncClients' => $baseDir . '/../lib/Sections/Personal/SyncClients.php',
'OCA\\Settings\\Settings\\Admin\\Mail' => $baseDir . '/../lib/Settings/Admin/Mail.php',
'OCA\\Settings\\Settings\\Admin\\Overview' => $baseDir . '/../lib/Settings/Admin/Overview.php',
'OCA\\Settings\\Settings\\Admin\\Security' => $baseDir . '/../lib/Settings/Admin/Security.php',
'OCA\\Settings\\Settings\\Admin\\Server' => $baseDir . '/../lib/Settings/Admin/Server.php',
'OCA\\Settings\\Settings\\Admin\\Sharing' => $baseDir . '/../lib/Settings/Admin/Sharing.php',
'OCA\\Settings\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php',
'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php',
'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php',

View File

@ -28,11 +28,6 @@ class ComposerStaticInitSettings
'OCA\\Settings\\Activity\\SecurityProvider' => __DIR__ . '/..' . '/../lib/Activity/SecurityProvider.php',
'OCA\\Settings\\Activity\\SecuritySetting' => __DIR__ . '/..' . '/../lib/Activity/SecuritySetting.php',
'OCA\\Settings\\Activity\\Setting' => __DIR__ . '/..' . '/../lib/Activity/Setting.php',
'OCA\\Settings\\Admin\\Mail' => __DIR__ . '/..' . '/../lib/Settings/Admin/Mail.php',
'OCA\\Settings\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Settings/Admin/Overview.php',
'OCA\\Settings\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Settings/Admin/Security.php',
'OCA\\Settings\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Settings/Admin/Server.php',
'OCA\\Settings\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Settings/Admin/Sharing.php',
'OCA\\Settings\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__ . '/..' . '/../lib/BackgroundJobs/VerifyUserData.php',
'OCA\\Settings\\Controller\\AdminSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AdminSettingsController.php',
@ -60,6 +55,11 @@ class ComposerStaticInitSettings
'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php',
'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Sections/Personal/Security.php',
'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__ . '/..' . '/../lib/Sections/Personal/SyncClients.php',
'OCA\\Settings\\Settings\\Admin\\Mail' => __DIR__ . '/..' . '/../lib/Settings/Admin/Mail.php',
'OCA\\Settings\\Settings\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Settings/Admin/Overview.php',
'OCA\\Settings\\Settings\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Settings/Admin/Security.php',
'OCA\\Settings\\Settings\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Settings/Admin/Server.php',
'OCA\\Settings\\Settings\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Settings/Admin/Sharing.php',
'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',

View File

@ -27,7 +27,7 @@
*
*/
namespace OCA\Settings\Admin;
namespace OCA\Settings\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;

View File

@ -23,7 +23,7 @@
*
*/
namespace OCA\Settings\Admin;
namespace OCA\Settings\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;

View File

@ -25,7 +25,7 @@
*
*/
namespace OCA\Settings\Admin;
namespace OCA\Settings\Settings\Admin;
use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
use OCP\AppFramework\Http\TemplateResponse;

View File

@ -25,7 +25,7 @@
*
*/
namespace OCA\Settings\Admin;
namespace OCA\Settings\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;

View File

@ -27,7 +27,7 @@
*
*/
namespace OCA\Settings\Admin;
namespace OCA\Settings\Settings\Admin;
use OC\Share\Share;
use OCP\AppFramework\Http\TemplateResponse;

View File

@ -29,7 +29,7 @@
namespace OCA\Settings\Tests\Settings\Admin;
use OCA\Settings\Admin\Mail;
use OCA\Settings\Settings\Admin\Mail;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use Test\TestCase;

View File

@ -30,7 +30,7 @@ namespace OCA\Settings\Tests\Settings\Admin;
use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
use OC\Encryption\Manager;
use OCA\Settings\Admin\Security;
use OCA\Settings\Settings\Admin\Security;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IInitialStateService;
use OCP\IUserManager;

View File

@ -29,7 +29,7 @@
namespace OCA\Settings\Tests\Settings\Admin;
use OCA\Settings\Admin\Server;
use OCA\Settings\Settings\Admin\Server;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use Test\TestCase;

View File

@ -28,7 +28,7 @@
namespace OCA\Settings\Tests\Settings\Admin;
use OCA\Settings\Admin\Sharing;
use OCA\Settings\Settings\Admin\Sharing;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Constants;
use OCP\IConfig;

View File

@ -227,51 +227,6 @@ class Manager implements IManager {
return $sections;
}
/**
* @param string $section
* @param Closure $filter
*
* @return ISection[]
*/
private function getBuiltInAdminSettings($section, Closure $filter = null): array {
$forms = [];
if ($section === 'overview') {
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Admin\Overview::class);
if ($filter === null || $filter($form)) {
$forms[$form->getPriority()] = [$form];
}
}
if ($section === 'server') {
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Admin\Server::class);
if ($filter === null || $filter($form)) {
$forms[$form->getPriority()] = [$form];
}
$form = $this->container->query(\OCA\Settings\Admin\Mail::class);
if ($filter === null || $filter($form)) {
$forms[$form->getPriority()] = [$form];
}
}
if ($section === 'security') {
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Admin\Security::class);
if ($filter === null || $filter($form)) {
$forms[$form->getPriority()] = [$form];
}
}
if ($section === 'sharing') {
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Admin\Sharing::class);
if ($filter === null || $filter($form)) {
$forms[$form->getPriority()] = [$form];
}
}
return $forms;
}
/**
* @inheritdoc
*/
@ -280,13 +235,12 @@ class Manager implements IManager {
$subAdminSettingsFilter = function(ISettings $settings) {
return $settings instanceof ISubAdminSettings;
};
$settings = $this->getBuiltInAdminSettings($section, $subAdminSettingsFilter);
$appSettings = $this->getSettings('admin', $section, $subAdminSettingsFilter);
} else {
$settings = $this->getBuiltInAdminSettings($section);
$appSettings = $this->getSettings('admin', $section);
}
$settings = [];
foreach ($appSettings as $setting) {
if (!isset($settings[$setting->getPriority()])) {
$settings[$setting->getPriority()] = [];

View File

@ -102,15 +102,16 @@ class ManagerTest extends TestCase {
}
public function testGetAdminSettings() {
$section = $this->createMock(Sharing::class);
$section->expects($this->once())
->method('getPriority')
$section = $this->createMock(ISettings::class);
$section->method('getPriority')
->willReturn(13);
$this->container->expects($this->once())
->method('query')
->with(Sharing::class)
$section->method('getSection')
->willReturn('sharing');
$this->container->method('query')
->with('myAdminClass')
->willReturn($section);
$this->manager->registerSetting('admin', 'myAdminClass');
$settings = $this->manager->getAdminSettings('sharing');
$this->assertEquals([
@ -119,12 +120,16 @@ class ManagerTest extends TestCase {
}
public function testGetAdminSettingsAsSubAdmin() {
$section = $this->createMock(Sharing::class);
$this->container->expects($this->once())
->method('query')
->with(Sharing::class)
$section = $this->createMock(ISettings::class);
$section->method('getPriority')
->willReturn(13);
$section->method('getSection')
->willReturn('sharing');
$this->container->method('query')
->with('myAdminClass')
->willReturn($section);
$this->manager->registerSetting('admin', 'myAdminClass');
$settings = $this->manager->getAdminSettings('sharing', true);
$this->assertEquals([], $settings);
@ -132,14 +137,16 @@ class ManagerTest extends TestCase {
public function testGetSubAdminSettingsAsSubAdmin() {
$section = $this->createMock(ISubAdminSettings::class);
$section->expects($this->once())
->method('getPriority')
$section->method('getPriority')
->willReturn(13);
$section->method('getSection')
->willReturn('sharing');
$this->container->expects($this->once())
->method('query')
->with(Sharing::class)
->with('mySubAdminClass')
->willReturn($section);
$this->manager->registerSetting('admin', 'mySubAdminClass');
$settings = $this->manager->getAdminSettings('sharing', true);
$this->assertEquals([