From 20e536839af29c8c207b1bb0967d710af07f9036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 25 Sep 2025 17:46:02 +0200 Subject: [PATCH] feat: Add admin-delegation-section as well for completeness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also renamed delegation into admin-delegation in xml schema. Signed-off-by: Côme Chilliet --- apps/settings/appinfo/info.xml | 3 +- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + apps/settings/lib/Sections/Admin/Users.php | 36 ++++++++++++++++++ apps/settings/lib/Settings/Admin/Users.php | 32 +++------------- apps/webhook_listeners/appinfo/info.xml | 3 +- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + apps/webhook_listeners/lib/Settings/Admin.php | 33 ++++------------- .../lib/Settings/AdminSection.php | 37 +++++++++++++++++++ lib/private/App/AppManager.php | 9 ++++- lib/private/App/InfoParser.php | 7 +++- resources/app-info-shipped.xsd | 5 ++- resources/app-info.xsd | 5 ++- 14 files changed, 113 insertions(+), 61 deletions(-) create mode 100644 apps/settings/lib/Sections/Admin/Users.php create mode 100644 apps/webhook_listeners/lib/Settings/AdminSection.php diff --git a/apps/settings/appinfo/info.xml b/apps/settings/appinfo/info.xml index 3d598ee41fd..69489e8ef2a 100644 --- a/apps/settings/appinfo/info.xml +++ b/apps/settings/appinfo/info.xml @@ -35,7 +35,6 @@ OCA\Settings\Settings\Admin\Sharing OCA\Settings\Settings\Admin\Security OCA\Settings\Settings\Admin\Delegation - OCA\Settings\Settings\Admin\Users OCA\Settings\Sections\Admin\Additional OCA\Settings\Sections\Admin\Delegation OCA\Settings\Sections\Admin\Groupware @@ -45,6 +44,8 @@ OCA\Settings\Sections\Admin\Security OCA\Settings\Sections\Admin\Server OCA\Settings\Sections\Admin\Sharing + OCA\Settings\Settings\Admin\Users + OCA\Settings\Sections\Admin\Users OCA\Settings\Settings\Personal\Additional OCA\Settings\Settings\Personal\PersonalInfo OCA\Settings\Settings\Personal\ServerDevNotice diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index b12f345e05b..8c90376d79c 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -60,6 +60,7 @@ return array( '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\\Admin\\Users' => $baseDir . '/../lib/Sections/Admin/Users.php', 'OCA\\Settings\\Sections\\Personal\\Availability' => $baseDir . '/../lib/Sections/Personal/Availability.php', 'OCA\\Settings\\Sections\\Personal\\Calendar' => $baseDir . '/../lib/Sections/Personal/Calendar.php', 'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index e6e2ed9f45c..cf6ebfacba8 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -75,6 +75,7 @@ class ComposerStaticInitSettings '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\\Admin\\Users' => __DIR__ . '/..' . '/../lib/Sections/Admin/Users.php', 'OCA\\Settings\\Sections\\Personal\\Availability' => __DIR__ . '/..' . '/../lib/Sections/Personal/Availability.php', 'OCA\\Settings\\Sections\\Personal\\Calendar' => __DIR__ . '/..' . '/../lib/Sections/Personal/Calendar.php', 'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php', diff --git a/apps/settings/lib/Sections/Admin/Users.php b/apps/settings/lib/Sections/Admin/Users.php new file mode 100644 index 00000000000..d5e080331e8 --- /dev/null +++ b/apps/settings/lib/Sections/Admin/Users.php @@ -0,0 +1,36 @@ +l->t('Users'); + } + + public function getPriority(): int { + return 55; + } + + public function getIcon(): string { + return ''; + } +} diff --git a/apps/settings/lib/Settings/Admin/Users.php b/apps/settings/lib/Settings/Admin/Users.php index c569890a0dc..8e45216b9c4 100644 --- a/apps/settings/lib/Settings/Admin/Users.php +++ b/apps/settings/lib/Settings/Admin/Users.php @@ -10,49 +10,27 @@ declare(strict_types=1); namespace OCA\Settings\Settings\Admin; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IL10N; use OCP\Settings\IDelegatedSettings; /** * Empty settings class, used only for admin delegation. */ class Users implements IDelegatedSettings { - - public function __construct( - protected string $appName, - private IL10N $l10n, - ) { - } - - /** - * Empty template response - */ public function getForm(): TemplateResponse { - - return new /** @template-extends TemplateResponse<\OCP\AppFramework\Http::STATUS_OK, array{}> */ class($this->appName, '') extends TemplateResponse { - public function render(): string { - return ''; - } - }; + throw new \Exception('Admin delegation settings should never be rendered'); } public function getSection(): ?string { - return 'admindelegation'; + return 'usersdelegation'; } - /** - * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. - * - * E.g.: 70 - */ public function getPriority(): int { return 0; } - public function getName(): string { - return $this->l10n->t('Users'); + public function getName(): ?string { + /* Use section name alone */ + return null; } public function getAuthorizedAppConfig(): array { diff --git a/apps/webhook_listeners/appinfo/info.xml b/apps/webhook_listeners/appinfo/info.xml index 99b72dfd9f1..260f176bd5d 100644 --- a/apps/webhook_listeners/appinfo/info.xml +++ b/apps/webhook_listeners/appinfo/info.xml @@ -32,6 +32,7 @@ - OCA\WebhookListeners\Settings\Admin + OCA\WebhookListeners\Settings\Admin + OCA\WebhookListeners\Settings\AdminSection diff --git a/apps/webhook_listeners/composer/composer/autoload_classmap.php b/apps/webhook_listeners/composer/composer/autoload_classmap.php index 3a8e2fe16ae..959b4c1d2ae 100644 --- a/apps/webhook_listeners/composer/composer/autoload_classmap.php +++ b/apps/webhook_listeners/composer/composer/autoload_classmap.php @@ -20,4 +20,5 @@ return array( 'OCA\\WebhookListeners\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php', 'OCA\\WebhookListeners\\Service\\PHPMongoQuery' => $baseDir . '/../lib/Service/PHPMongoQuery.php', 'OCA\\WebhookListeners\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php', + 'OCA\\WebhookListeners\\Settings\\AdminSection' => $baseDir . '/../lib/Settings/AdminSection.php', ); diff --git a/apps/webhook_listeners/composer/composer/autoload_static.php b/apps/webhook_listeners/composer/composer/autoload_static.php index d63fe31af47..b9b367315f6 100644 --- a/apps/webhook_listeners/composer/composer/autoload_static.php +++ b/apps/webhook_listeners/composer/composer/autoload_static.php @@ -35,6 +35,7 @@ class ComposerStaticInitWebhookListeners 'OCA\\WebhookListeners\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php', 'OCA\\WebhookListeners\\Service\\PHPMongoQuery' => __DIR__ . '/..' . '/../lib/Service/PHPMongoQuery.php', 'OCA\\WebhookListeners\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php', + 'OCA\\WebhookListeners\\Settings\\AdminSection' => __DIR__ . '/..' . '/../lib/Settings/AdminSection.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/apps/webhook_listeners/lib/Settings/Admin.php b/apps/webhook_listeners/lib/Settings/Admin.php index 64ed53426f9..f076f348c0d 100644 --- a/apps/webhook_listeners/lib/Settings/Admin.php +++ b/apps/webhook_listeners/lib/Settings/Admin.php @@ -9,51 +9,32 @@ declare(strict_types=1); namespace OCA\WebhookListeners\Settings; -use OCP\AppFramework\Http; +use OCA\WebhookListeners\AppInfo\Application; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IL10N; use OCP\Settings\IDelegatedSettings; /** * Empty settings class, used only for admin delegation for now as there is no UI */ class Admin implements IDelegatedSettings { - - public function __construct( - protected string $appName, - private IL10N $l10n, - ) { - } - /** * Empty template response */ public function getForm(): TemplateResponse { - - return new /** @template-extends TemplateResponse */ class($this->appName, '') extends TemplateResponse { - public function render(): string { - return ''; - } - }; + throw new \Exception('Admin delegation settings should never be rendered'); } - public function getSection(): ?string { - return 'admindelegation'; + public function getSection(): string { + return Application::APP_ID . '-admin'; } - /** - * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. - * - * E.g.: 70 - */ public function getPriority(): int { return 0; } - public function getName(): string { - return $this->l10n->t('Webhooks'); + public function getName(): ?string { + /* Use section name alone */ + return null; } public function getAuthorizedAppConfig(): array { diff --git a/apps/webhook_listeners/lib/Settings/AdminSection.php b/apps/webhook_listeners/lib/Settings/AdminSection.php new file mode 100644 index 00000000000..84670ebb2d8 --- /dev/null +++ b/apps/webhook_listeners/lib/Settings/AdminSection.php @@ -0,0 +1,37 @@ +l->t('Webhooks'); + } + + public function getPriority(): int { + return 56; + } + + public function getIcon(): string { + return ''; + } +} diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index c5e80d3901c..4702aec37c1 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -523,11 +523,16 @@ class AppManager implements IAppManager { $settingsManager->registerSection('personal', $section); } } - if (!empty($info['settings']['delegation'])) { - foreach ($info['settings']['delegation'] as $setting) { + if (!empty($info['settings']['admin-delegation'])) { + foreach ($info['settings']['admin-delegation'] as $setting) { $settingsManager->registerSetting(ISettingsManager::SETTINGS_DELEGATION, $setting); } } + if (!empty($info['settings']['admin-delegation-section'])) { + foreach ($info['settings']['admin-delegation-section'] as $section) { + $settingsManager->registerSection(ISettingsManager::SETTINGS_DELEGATION, $section); + } + } } if (!empty($info['collaboration']['plugins'])) { diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php index 807eb49ed4b..677f45d7ae0 100644 --- a/lib/private/App/InfoParser.php +++ b/lib/private/App/InfoParser.php @@ -184,8 +184,11 @@ class InfoParser { if (isset($array['settings']['personal-section']) && !is_array($array['settings']['personal-section'])) { $array['settings']['personal-section'] = [$array['settings']['personal-section']]; } - if (isset($array['settings']['delegation']) && !is_array($array['settings']['delegation'])) { - $array['settings']['delegation'] = [$array['settings']['delegation']]; + if (isset($array['settings']['admin-delegation']) && !is_array($array['settings']['admin-delegation'])) { + $array['settings']['admin-delegation'] = [$array['settings']['admin-delegation']]; + } + if (isset($array['settings']['admin-delegation-section']) && !is_array($array['settings']['admin-delegation-section'])) { + $array['settings']['admin-delegation-section'] = [$array['settings']['admin-delegation-section']]; } if (isset($array['navigations']['navigation']) && $this->isNavigationItem($array['navigations']['navigation'])) { $array['navigations']['navigation'] = [$array['navigations']['navigation']]; diff --git a/resources/app-info-shipped.xsd b/resources/app-info-shipped.xsd index 09c0d378841..db51ec15c78 100644 --- a/resources/app-info-shipped.xsd +++ b/resources/app-info-shipped.xsd @@ -415,7 +415,10 @@ maxOccurs="unbounded"/> - + + diff --git a/resources/app-info.xsd b/resources/app-info.xsd index b406a9c5f88..cee16b0cedc 100644 --- a/resources/app-info.xsd +++ b/resources/app-info.xsd @@ -411,7 +411,10 @@ maxOccurs="unbounded"/> - + +