From 1b774d74ea236e5c276211ee4916484f931eedba Mon Sep 17 00:00:00 2001 From: Private Maker Date: Wed, 20 Sep 2023 18:18:57 +0000 Subject: [PATCH 1/2] make Settings of Personal and Admin into own views resolves #40490 Signed-off-by: Private Maker --- .../Controller/AdminSettingsController.php | 3 +- .../lib/Controller/CommonSettingsTrait.php | 46 +++++++++------ .../Controller/PersonalSettingsController.php | 3 +- apps/settings/templates/settings/admin.php | 56 +++++++++++++++++++ .../settings/{frame.php => personal.php} | 43 ++------------ 5 files changed, 96 insertions(+), 55 deletions(-) create mode 100644 apps/settings/templates/settings/admin.php rename apps/settings/templates/settings/{frame.php => personal.php} (62%) diff --git a/apps/settings/lib/Controller/AdminSettingsController.php b/apps/settings/lib/Controller/AdminSettingsController.php index 2e5d2fce953b1..acb6d79fda459 100644 --- a/apps/settings/lib/Controller/AdminSettingsController.php +++ b/apps/settings/lib/Controller/AdminSettingsController.php @@ -7,6 +7,7 @@ * @author Lukas Reschke * @author Robin Appelman * @author Kate Döen + * @author Private Maker * * @license GNU AGPL version 3 or any later version * @@ -68,7 +69,7 @@ public function __construct( * settings for the given section. The user will be gretted by an error message. */ public function index(string $section): TemplateResponse { - return $this->getIndexResponse('admin', $section); + return $this->getAdminResponse($section); } /** diff --git a/apps/settings/lib/Controller/CommonSettingsTrait.php b/apps/settings/lib/Controller/CommonSettingsTrait.php index 8ca62b9d1b3a6..5fcec824ac853 100644 --- a/apps/settings/lib/Controller/CommonSettingsTrait.php +++ b/apps/settings/lib/Controller/CommonSettingsTrait.php @@ -9,6 +9,7 @@ * @author Morris Jobke * @author Robin Appelman * @author Roeland Jago Douma + * @author Private Maker * * @license GNU AGPL version 3 or any later version * @@ -133,28 +134,41 @@ private function formatSettings(array $settings): array { return ['content' => $html]; } - private function getIndexResponse(string $type, string $section): TemplateResponse { - if ($type === 'personal') { - if ($section === 'theming') { - $this->navigationManager->setActiveEntry('accessibility_settings'); - } else { - $this->navigationManager->setActiveEntry('settings'); - } - } elseif ($type === 'admin') { - $this->navigationManager->setActiveEntry('admin_settings'); + private function getPersonalResponse(string $section): TemplateResponse { + $templateParams = []; + $templateParams = array_merge($templateParams, $this->getNavigationParameters('personal', $section)); + $templateParams = array_merge($templateParams, $this->getSettings($section)); + $activeSection = $this->settingsManager->getSection('personal', $section); + + if ($activeSection) { + $templateParams['pageTitle'] = $activeSection->getName(); + $templateParams['activeSectionId'] = $activeSection->getID(); } - $templateParams = []; - $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); + if ($section === 'theming') { + $this->navigationManager->setActiveEntry('accessibility_settings'); + } else { + $this->navigationManager->setActiveEntry('settings'); + } + + return new TemplateResponse('settings', 'settings/personal', $templateParams); + } + + private function getAdminResponse(string $section): TemplateResponse { + $templateParams = []; + $templateParams = array_merge($templateParams, $this->getNavigationParameters('admin', $section)); $templateParams = array_merge($templateParams, $this->getSettings($section)); - $activeSection = $this->settingsManager->getSection($type, $section); - if ($activeSection) { + $activeSection = $this->settingsManager->getSection('admin', $section); + + if ($activeSection) { $templateParams['pageTitle'] = $activeSection->getName(); $templateParams['activeSectionId'] = $activeSection->getID(); - } + } - return new TemplateResponse('settings', 'settings/frame', $templateParams); - } + $this->navigationManager->setActiveEntry('admin_settings'); + + return new TemplateResponse('settings', 'settings/admin', $templateParams); + } abstract protected function getSettings($section); } diff --git a/apps/settings/lib/Controller/PersonalSettingsController.php b/apps/settings/lib/Controller/PersonalSettingsController.php index 09340117610c6..1cc64a974ccd9 100644 --- a/apps/settings/lib/Controller/PersonalSettingsController.php +++ b/apps/settings/lib/Controller/PersonalSettingsController.php @@ -7,6 +7,7 @@ * @author Joas Schilling * @author Robin Appelman * @author Kate Döen + * @author Private Maker * * @license GNU AGPL version 3 or any later version * @@ -64,7 +65,7 @@ public function __construct( * @NoSubAdminRequired */ public function index(string $section): TemplateResponse { - return $this->getIndexResponse('personal', $section); + return $this->getPersonalResponse($section); } /** diff --git a/apps/settings/templates/settings/admin.php b/apps/settings/templates/settings/admin.php new file mode 100644 index 0000000000000..b0c70efa8bf96 --- /dev/null +++ b/apps/settings/templates/settings/admin.php @@ -0,0 +1,56 @@ + + * + * @author Arthur Schiwon + * @author Private Maker + * + * @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 . + * + */ + +style('settings', 'settings'); +script('settings', 'settings'); +\OCP\Util::addScript('settings', 'legacy-admin'); +script('core', 'setupchecks'); +script('files', 'jquery.fileupload'); +?> + + +
+ +
diff --git a/apps/settings/templates/settings/frame.php b/apps/settings/templates/settings/personal.php similarity index 62% rename from apps/settings/templates/settings/frame.php rename to apps/settings/templates/settings/personal.php index b2b2f04ebe0f2..5d9ed017f2118 100644 --- a/apps/settings/templates/settings/frame.php +++ b/apps/settings/templates/settings/personal.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016 Arthur Schiwon * * @author Arthur Schiwon + * @author Private Maker * * @license GNU AGPL version 3 or any later version * @@ -26,17 +27,13 @@ \OCP\Util::addScript('settings', 'legacy-admin'); script('core', 'setupchecks'); script('files', 'jquery.fileupload'); - ?>
From bb2353ae4a18e95dc4ca6346ad696c0e371453e5 Mon Sep 17 00:00:00 2001 From: Private Maker Date: Thu, 21 Sep 2023 18:13:50 +0000 Subject: [PATCH 2/2] add test files for apps/settings changes #40490 Signed-off-by: Private Maker --- apps/settings/composer/composer/installed.php | 4 +- .../Controller/PersonalSettingsController.php | 4 - apps/settings/templates/settings/admin.php | 9 +- .../AdminSettingsControllerTest.php | 5 +- .../PersonalSettingsControllerTest.php | 110 ++++++++++++++++++ 5 files changed, 120 insertions(+), 12 deletions(-) create mode 100644 apps/settings/tests/Controller/PersonalSettingsControllerTest.php diff --git a/apps/settings/composer/composer/installed.php b/apps/settings/composer/composer/installed.php index 1a66c7f2416b6..230e2aa13ab57 100644 --- a/apps/settings/composer/composer/installed.php +++ b/apps/settings/composer/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'b1797842784b250fb01ed5e3bf130705eb94751b', + 'reference' => '1b774d74ea236e5c276211ee4916484f931eedba', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'b1797842784b250fb01ed5e3bf130705eb94751b', + 'reference' => '1b774d74ea236e5c276211ee4916484f931eedba', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), diff --git a/apps/settings/lib/Controller/PersonalSettingsController.php b/apps/settings/lib/Controller/PersonalSettingsController.php index 1cc64a974ccd9..5bdb05ba653db 100644 --- a/apps/settings/lib/Controller/PersonalSettingsController.php +++ b/apps/settings/lib/Controller/PersonalSettingsController.php @@ -48,15 +48,11 @@ public function __construct( INavigationManager $navigationManager, ISettingsManager $settingsManager, IUserSession $userSession, - IGroupManager $groupManager, - ISubAdmin $subAdmin ) { parent::__construct($appName, $request); $this->navigationManager = $navigationManager; $this->settingsManager = $settingsManager; $this->userSession = $userSession; - $this->subAdmin = $subAdmin; - $this->groupManager = $groupManager; } /** diff --git a/apps/settings/templates/settings/admin.php b/apps/settings/templates/settings/admin.php index b0c70efa8bf96..22e60b2343c2b 100644 --- a/apps/settings/templates/settings/admin.php +++ b/apps/settings/templates/settings/admin.php @@ -22,6 +22,8 @@ * */ +use OCP\IURLGenerator; + style('settings', 'settings'); script('settings', 'settings'); \OCP\Util::addScript('settings', 'legacy-admin'); @@ -33,9 +35,10 @@