Browse Source

feat: Add admin-delegation-section as well for completeness

Also renamed delegation into admin-delegation in xml schema.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/55261/head
Côme Chilliet 3 weeks ago
parent
commit
20e536839a
No known key found for this signature in database GPG Key ID: A3E2F658B28C760A
  1. 3
      apps/settings/appinfo/info.xml
  2. 1
      apps/settings/composer/composer/autoload_classmap.php
  3. 1
      apps/settings/composer/composer/autoload_static.php
  4. 36
      apps/settings/lib/Sections/Admin/Users.php
  5. 32
      apps/settings/lib/Settings/Admin/Users.php
  6. 3
      apps/webhook_listeners/appinfo/info.xml
  7. 1
      apps/webhook_listeners/composer/composer/autoload_classmap.php
  8. 1
      apps/webhook_listeners/composer/composer/autoload_static.php
  9. 33
      apps/webhook_listeners/lib/Settings/Admin.php
  10. 37
      apps/webhook_listeners/lib/Settings/AdminSection.php
  11. 9
      lib/private/App/AppManager.php
  12. 7
      lib/private/App/InfoParser.php
  13. 5
      resources/app-info-shipped.xsd
  14. 5
      resources/app-info.xsd

3
apps/settings/appinfo/info.xml

@ -35,7 +35,6 @@
<admin>OCA\Settings\Settings\Admin\Sharing</admin>
<admin>OCA\Settings\Settings\Admin\Security</admin>
<admin>OCA\Settings\Settings\Admin\Delegation</admin>
<delegation>OCA\Settings\Settings\Admin\Users</delegation>
<admin-section>OCA\Settings\Sections\Admin\Additional</admin-section>
<admin-section>OCA\Settings\Sections\Admin\Delegation</admin-section>
<admin-section>OCA\Settings\Sections\Admin\Groupware</admin-section>
@ -45,6 +44,8 @@
<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>
<admin-delegation>OCA\Settings\Settings\Admin\Users</admin-delegation>
<admin-delegation-section>OCA\Settings\Sections\Admin\Users</admin-delegation-section>
<personal>OCA\Settings\Settings\Personal\Additional</personal>
<personal>OCA\Settings\Settings\Personal\PersonalInfo</personal>
<personal>OCA\Settings\Settings\Personal\ServerDevNotice</personal>

1
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',

1
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',

36
apps/settings/lib/Sections/Admin/Users.php

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Sections\Admin;
use OCP\IL10N;
use OCP\Settings\IIconSection;
class Users implements IIconSection {
public function __construct(
private IL10N $l,
) {
}
public function getID(): string {
return 'usersdelegation';
}
public function getName(): string {
return $this->l->t('Users');
}
public function getPriority(): int {
return 55;
}
public function getIcon(): string {
return '';
}
}

32
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 {

3
apps/webhook_listeners/appinfo/info.xml

@ -32,6 +32,7 @@
</commands>
<settings>
<delegation>OCA\WebhookListeners\Settings\Admin</delegation>
<admin-delegation>OCA\WebhookListeners\Settings\Admin</admin-delegation>
<admin-delegation-section>OCA\WebhookListeners\Settings\AdminSection</admin-delegation-section>
</settings>
</info>

1
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',
);

1
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)

33
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<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';
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 {

37
apps/webhook_listeners/lib/Settings/AdminSection.php

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\WebhookListeners\Settings;
use OCA\WebhookListeners\AppInfo\Application;
use OCP\IL10N;
use OCP\Settings\IIconSection;
class AdminSection implements IIconSection {
public function __construct(
private IL10N $l,
) {
}
public function getID(): string {
return Application::APP_ID . '-admin';
}
public function getName(): string {
return $this->l->t('Webhooks');
}
public function getPriority(): int {
return 56;
}
public function getIcon(): string {
return '';
}
}

9
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'])) {

7
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']];

5
resources/app-info-shipped.xsd

@ -415,7 +415,10 @@
maxOccurs="unbounded"/>
<xs:element name="personal-section" type="php-class" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="delegation" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="admin-delegation" type="php-class" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="admin-delegation-section" type="php-class" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

5
resources/app-info.xsd

@ -411,7 +411,10 @@
maxOccurs="unbounded"/>
<xs:element name="personal-section" type="php-class" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="delegation" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="admin-delegation" type="php-class" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="admin-delegation-section" type="php-class" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

Loading…
Cancel
Save