]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move Admin Settings also to info.xml 19243/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 31 Jan 2020 15:55:17 +0000 (16:55 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 31 Jan 2020 15:55:17 +0000 (16:55 +0100)
More cleanup of the Settings apps. Makes the manager cleaner and a
proper manager.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
14 files changed:
apps/settings/appinfo/info.xml
apps/settings/composer/composer/autoload_classmap.php
apps/settings/composer/composer/autoload_static.php
apps/settings/lib/Settings/Admin/Mail.php
apps/settings/lib/Settings/Admin/Overview.php
apps/settings/lib/Settings/Admin/Security.php
apps/settings/lib/Settings/Admin/Server.php
apps/settings/lib/Settings/Admin/Sharing.php
apps/settings/tests/Settings/Admin/MailTest.php
apps/settings/tests/Settings/Admin/SecurityTest.php
apps/settings/tests/Settings/Admin/ServerTest.php
apps/settings/tests/Settings/Admin/SharingTest.php
lib/private/Settings/Manager.php
tests/lib/Settings/ManagerTest.php

index f2325c3afca73f89c9e30ca11f68f0f6113b876c..2513b9a20faa83ba0b3b5225b447691cd1b61953 100644 (file)
        </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>
index c68f3d85279868c6b5bca97a9a4e84357bcc1a2f..841a1aa21eb4378ae8c50b5e1d1471a0b7bf197d 100644 (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',
index 41b2ad27271a5afd1a45092b976b47b181aa7e19..bac850545f3d29bc2639f3412e160981d282b503 100644 (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',
index 387fb5f475bf575344b2e72d74df1b865d7cb7fe..4ad22cbc21643a91f07064fc1ee4f1cb6af60fb1 100644 (file)
@@ -27,7 +27,7 @@
  *
  */
 
-namespace OCA\Settings\Admin;
+namespace OCA\Settings\Settings\Admin;
 
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\IConfig;
index 4fd9d673c5ba3157c12a4a6e9787b1ed60ee7ea5..3399a425ee8fc87e82128cbb9f619705e9772231 100644 (file)
@@ -23,7 +23,7 @@
  *
  */
 
-namespace OCA\Settings\Admin;
+namespace OCA\Settings\Settings\Admin;
 
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\IConfig;
index 8a804f054fc27d5d92b4c14b12345173a41cfc2a..e5e00928faac2c97fa636e09e1ac92c39382108c 100644 (file)
@@ -25,7 +25,7 @@
  *
  */
 
-namespace OCA\Settings\Admin;
+namespace OCA\Settings\Settings\Admin;
 
 use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
 use OCP\AppFramework\Http\TemplateResponse;
index 543e7dbc5929eb382760233c138cae00f0f671f4..6216af4aada06d47c2978a8bb96fff415e1daef3 100644 (file)
@@ -25,7 +25,7 @@
  *
  */
 
-namespace OCA\Settings\Admin;
+namespace OCA\Settings\Settings\Admin;
 
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\IConfig;
index 591d6a64b8b895da0bc90b8ab771b8b444704912..c151e7be4e1adaa479df090c740ebdec09e57106 100644 (file)
@@ -27,7 +27,7 @@
  *
  */
 
-namespace OCA\Settings\Admin;
+namespace OCA\Settings\Settings\Admin;
 
 use OC\Share\Share;
 use OCP\AppFramework\Http\TemplateResponse;
index fba084133983d5f90fdb6d944f8c356ac1686a37..adb7e2fdbd69d819152a8d37096901f952415fda 100644 (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;
index 69941594c1549bc7985723539db34d55bb07220b..a8a140b2c5d1049264de75ee9a86c19cc11865cf 100644 (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;
index 525e43f7d61cbbe0ae827dc814b1ec50488af3e7..aeb37f8d6cc88ed70e712a5dcecdb198ab8bd4ea 100644 (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;
index 6bfca5bbc0411073fb2fba72bf1c5509f513ee30..d662c1864dbedb5e7d23263ca2af5799c3c89e17 100644 (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;
index 8018ecaba6176ba72acd77e69cca11c800584d2f..ed1d2f45cd7f41d0023739db09c66e390e0a5fd5 100644 (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()] = [];
index 06eafb6528bee64f2626d580c22ab94b882a5174..bce547c9a29a223f57de8a2a6cb2c06f34d1595d 100644 (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([