diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-28 12:38:11 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-28 12:38:11 +0100 |
commit | 03df1b4c51d8a02613a81e9ac9da1fc91ce66623 (patch) | |
tree | 7efd0ba2b6d42cacf38dc49947cbe0e0dcf15b50 | |
parent | 74f1b09f3d9d350a3374a35391b79722e81533e9 (diff) | |
download | nextcloud-server-03df1b4c51d8a02613a81e9ac9da1fc91ce66623.tar.gz nextcloud-server-03df1b4c51d8a02613a81e9ac9da1fc91ce66623.zip |
Move admin sections to settings app
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | apps/settings/appinfo/info.xml | 6 | ||||
-rw-r--r-- | apps/settings/composer/composer/autoload_classmap.php | 6 | ||||
-rw-r--r-- | apps/settings/composer/composer/autoload_static.php | 6 | ||||
-rw-r--r-- | apps/settings/lib/Sections/Admin/Additional.php | 59 | ||||
-rw-r--r-- | apps/settings/lib/Sections/Admin/Groupware.php | 59 | ||||
-rw-r--r-- | apps/settings/lib/Sections/Admin/Overview.php | 59 | ||||
-rw-r--r-- | apps/settings/lib/Sections/Admin/Security.php | 59 | ||||
-rw-r--r-- | apps/settings/lib/Sections/Admin/Server.php | 59 | ||||
-rw-r--r-- | apps/settings/lib/Sections/Admin/Sharing.php | 59 | ||||
-rw-r--r-- | lib/private/Settings/Manager.php | 13 | ||||
-rw-r--r-- | tests/lib/Settings/ManagerTest.php | 87 |
11 files changed, 374 insertions, 98 deletions
diff --git a/apps/settings/appinfo/info.xml b/apps/settings/appinfo/info.xml index d774988f4a9..61bfe454caa 100644 --- a/apps/settings/appinfo/info.xml +++ b/apps/settings/appinfo/info.xml @@ -18,6 +18,12 @@ </dependencies> <settings> + <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> + <admin-section>OCA\Settings\Sections\Admin\Security</admin-section> + <admin-section>OCA\Settings\Sections\Admin\Server</admin-section> + <admin-section>OCA\Settings\Sections\Admin\Sharing</admin-section> <personal-section>OCA\Settings\Sections\Personal\PersonalInfo</personal-section> <personal-section>OCA\Settings\Sections\Personal\Security</personal-section> <personal-section>OCA\Settings\Sections\Personal\SyncClients</personal-section> diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index ac7bd9577e0..52c4f4de477 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -41,6 +41,12 @@ return array( 'OCA\\Settings\\Personal\\Security' => $baseDir . '/../lib/Settings/Personal/Security.php', 'OCA\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php', 'OCA\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php', + 'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir . '/../lib/Sections/Admin/Additional.php', + 'OCA\\Settings\\Sections\\Admin\\Groupware' => $baseDir . '/../lib/Sections/Admin/Groupware.php', + 'OCA\\Settings\\Sections\\Admin\\Overview' => $baseDir . '/../lib/Sections/Admin/Overview.php', + 'OCA\\Settings\\Sections\\Admin\\Security' => $baseDir . '/../lib/Sections/Admin/Security.php', + 'OCA\\Settings\\Sections\\Admin\\Server' => $baseDir . '/../lib/Sections/Admin/Server.php', + 'OCA\\Settings\\Sections\\Admin\\Sharing' => $baseDir . '/../lib/Sections/Admin/Sharing.php', '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', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 36ae0f3a5d0..3c81d42c97c 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -56,6 +56,12 @@ class ComposerStaticInitSettings 'OCA\\Settings\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security.php', 'OCA\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php', 'OCA\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php', + 'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php', + 'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__ . '/..' . '/../lib/Sections/Admin/Groupware.php', + 'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Sections/Admin/Overview.php', + 'OCA\\Settings\\Sections\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Sections/Admin/Security.php', + 'OCA\\Settings\\Sections\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Sections/Admin/Server.php', + 'OCA\\Settings\\Sections\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Sections/Admin/Sharing.php', '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', diff --git a/apps/settings/lib/Sections/Admin/Additional.php b/apps/settings/lib/Sections/Admin/Additional.php new file mode 100644 index 00000000000..ebe9297572a --- /dev/null +++ b/apps/settings/lib/Sections/Admin/Additional.php @@ -0,0 +1,59 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Settings\Sections\Admin; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Settings\IIconSection; + +class Additional implements IIconSection { + + /** @var IL10N */ + private $l; + + /** @var IURLGenerator */ + private $urlGenerator; + + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { + $this->l = $l; + $this->urlGenerator = $urlGenerator; + } + + public function getIcon(): string { + return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg'); + } + + public function getID(): string { + return 'additional'; + } + + public function getName(): string { + return $this->l->t('Additional settings'); + } + + public function getPriority(): int { + return 98; + } +} diff --git a/apps/settings/lib/Sections/Admin/Groupware.php b/apps/settings/lib/Sections/Admin/Groupware.php new file mode 100644 index 00000000000..5f26b003041 --- /dev/null +++ b/apps/settings/lib/Sections/Admin/Groupware.php @@ -0,0 +1,59 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Settings\Sections\Admin; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Settings\IIconSection; + +class Groupware implements IIconSection { + + /** @var IL10N */ + private $l; + + /** @var IURLGenerator */ + private $urlGenerator; + + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { + $this->l = $l; + $this->urlGenerator = $urlGenerator; + } + + public function getIcon(): string { + return $this->urlGenerator->imagePath('core', 'places/contacts.svg'); + } + + public function getID(): string { + return 'groupware'; + } + + public function getName(): string { + return $this->l->t('Groupware'); + } + + public function getPriority(): int { + return 50; + } +} diff --git a/apps/settings/lib/Sections/Admin/Overview.php b/apps/settings/lib/Sections/Admin/Overview.php new file mode 100644 index 00000000000..c5dd8174c89 --- /dev/null +++ b/apps/settings/lib/Sections/Admin/Overview.php @@ -0,0 +1,59 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Settings\Sections\Admin; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Settings\IIconSection; + +class Overview implements IIconSection { + + /** @var IL10N */ + private $l; + + /** @var IURLGenerator */ + private $urlGenerator; + + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { + $this->l = $l; + $this->urlGenerator = $urlGenerator; + } + + public function getIcon(): string { + return $this->urlGenerator->imagePath('settings', 'admin.svg'); + } + + public function getID(): string { + return 'overview'; + } + + public function getName(): string { + return $this->l->t('Overview'); + } + + public function getPriority(): int { + return 0; + } +} diff --git a/apps/settings/lib/Sections/Admin/Security.php b/apps/settings/lib/Sections/Admin/Security.php new file mode 100644 index 00000000000..e674d6f0458 --- /dev/null +++ b/apps/settings/lib/Sections/Admin/Security.php @@ -0,0 +1,59 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Settings\Sections\Admin; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Settings\IIconSection; + +class Security implements IIconSection { + + /** @var IL10N */ + private $l; + + /** @var IURLGenerator */ + private $urlGenerator; + + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { + $this->l = $l; + $this->urlGenerator = $urlGenerator; + } + + public function getIcon(): string { + return $this->urlGenerator->imagePath('core', 'actions/password.svg'); + } + + public function getID(): string { + return 'security'; + } + + public function getName(): string { + return $this->l->t('Security'); + } + + public function getPriority(): int { + return 10; + } +} diff --git a/apps/settings/lib/Sections/Admin/Server.php b/apps/settings/lib/Sections/Admin/Server.php new file mode 100644 index 00000000000..d30f0a8132b --- /dev/null +++ b/apps/settings/lib/Sections/Admin/Server.php @@ -0,0 +1,59 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Settings\Sections\Admin; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Settings\IIconSection; + +class Server implements IIconSection { + + /** @var IL10N */ + private $l; + + /** @var IURLGenerator */ + private $urlGenerator; + + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { + $this->l = $l; + $this->urlGenerator = $urlGenerator; + } + + public function getIcon(): string { + return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg'); + } + + public function getID(): string { + return 'server'; + } + + public function getName(): string { + return $this->l->t('Basic settings'); + } + + public function getPriority(): int { + return 1; + } +} diff --git a/apps/settings/lib/Sections/Admin/Sharing.php b/apps/settings/lib/Sections/Admin/Sharing.php new file mode 100644 index 00000000000..0eeb95c87d5 --- /dev/null +++ b/apps/settings/lib/Sections/Admin/Sharing.php @@ -0,0 +1,59 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Settings\Sections\Admin; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Settings\IIconSection; + +class Sharing implements IIconSection { + + /** @var IL10N */ + private $l; + + /** @var IURLGenerator */ + private $urlGenerator; + + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { + $this->l = $l; + $this->urlGenerator = $urlGenerator; + } + + public function getIcon(): string { + return $this->urlGenerator->imagePath('core', 'actions/share.svg'); + } + + public function getID(): string { + return 'sharing'; + } + + public function getName(): string { + return $this->l->t('Sharing'); + } + + public function getPriority(): int { + return 5; + } +} diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 46a047e53c6..87ef74aabaa 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -208,19 +208,8 @@ class Manager implements IManager { * @inheritdoc */ public function getAdminSections(): array { - if ($this->l === null) { - $this->l = $this->l10nFactory->get('lib'); - } - // built-in sections - $sections = [ - 0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))], - 1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], - 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], - 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], - 50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts.svg'))], - 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], - ]; + $sections = []; $appSections = $this->getSections('admin'); diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index 2ba3b2e7b57..3980990c7b1 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -69,51 +69,14 @@ class ManagerTest extends TestCase { } public function testGetAdminSections() { - $this->l10nFactory - ->expects($this->once()) - ->method('get') - ->with('lib') - ->willReturn($this->l10n); - $this->l10n - ->expects($this->any()) - ->method('t') - ->will($this->returnArgument(0)); - $this->manager->registerSection('admin', \OCA\WorkflowEngine\Settings\Section::class); - $this->url->expects($this->exactly(6)) - ->method('imagePath') - ->willReturnMap([ - ['settings', 'admin.svg', '0'], - ['core', 'actions/settings-dark.svg', '1'], - ['core', 'actions/share.svg', '2'], - ['core', 'actions/password.svg', '3'], - ['core', 'places/contacts.svg', '5'], - ['settings', 'help.svg', '4'], - ]); - $this->assertEquals([ - 0 => [new Section('overview', 'Overview', 0, '0')], - 1 => [new Section('server', 'Basic settings', 0, '1')], - 5 => [new Section('sharing', 'Sharing', 0, '2')], - 10 => [new Section('security', 'Security', 0, '3')], - 50 => [new Section('groupware', 'Groupware', 0, '5')], 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], - 98 => [new Section('additional', 'Additional settings', 0, '1')], ], $this->manager->getAdminSections()); } public function testGetPersonalSections() { - $this->l10nFactory - ->expects($this->once()) - ->method('get') - ->with('lib') - ->willReturn($this->l10n); - $this->l10n - ->expects($this->any()) - ->method('t') - ->will($this->returnArgument(0)); - $this->manager->registerSection('personal', \OCA\WorkflowEngine\Settings\Section::class); $this->assertEquals([ @@ -122,35 +85,7 @@ class ManagerTest extends TestCase { } public function testGetAdminSectionsEmptySection() { - $this->l10nFactory - ->expects($this->once()) - ->method('get') - ->with('lib') - ->willReturn($this->l10n); - $this->l10n - ->expects($this->any()) - ->method('t') - ->will($this->returnArgument(0)); - - $this->url->expects($this->exactly(6)) - ->method('imagePath') - ->willReturnMap([ - ['settings', 'admin.svg', '0'], - ['core', 'actions/settings-dark.svg', '1'], - ['core', 'actions/share.svg', '2'], - ['core', 'actions/password.svg', '3'], - ['core', 'places/contacts.svg', '5'], - ['settings', 'help.svg', '4'], - ]); - - $this->assertEquals([ - 0 => [new Section('overview', 'Overview', 0, '0')], - 1 => [new Section('server', 'Basic settings', 0, '1')], - 5 => [new Section('sharing', 'Sharing', 0, '2')], - 10 => [new Section('security', 'Security', 0, '3')], - 50 => [new Section('groupware', 'Groupware', 0, '5')], - 98 => [new Section('additional', 'Additional settings', 0, '1')], - ], $this->manager->getAdminSections()); + $this->assertEquals([], $this->manager->getAdminSections()); } public function testGetPersonalSectionsEmptySection() { @@ -253,32 +188,12 @@ class ManagerTest extends TestCase { $this->manager->registerSection('personal', \OCA\WorkflowEngine\Settings\Section::class); $this->manager->registerSection('admin', \OCA\WorkflowEngine\Settings\Section::class); - $this->url->expects($this->exactly(6)) - ->method('imagePath') - ->willReturnMap([ - ['core', 'actions/user.svg', '1'], - ['settings', 'password.svg', '2'], - ['core', 'clients/phone.svg', '3'], - ['settings', 'admin.svg', '0'], - ['core', 'actions/settings-dark.svg', '1'], - ['core', 'actions/share.svg', '2'], - ['core', 'actions/password.svg', '3'], - ['core', 'places/contacts.svg', '5'], - ['settings', 'help.svg', '4'], - ]); - $this->assertEquals([ 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], ], $this->manager->getPersonalSections()); $this->assertEquals([ - 0 => [new Section('overview', 'Overview', 0, '0')], - 1 => [new Section('server', 'Basic settings', 0, '1')], - 5 => [new Section('sharing', 'Sharing', 0, '2')], - 10 => [new Section('security', 'Security', 0, '3')], - 50 => [new Section('groupware', 'Groupware', 0, '5')], 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], - 98 => [new Section('additional', 'Additional settings', 0, '1')], ], $this->manager->getAdminSections()); } } |