Skip to content

Commit 20e5368

Browse files
committed
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>
1 parent 26f50ca commit 20e5368

14 files changed

Lines changed: 113 additions & 61 deletions

File tree

apps/settings/appinfo/info.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<admin>OCA\Settings\Settings\Admin\Sharing</admin>
3636
<admin>OCA\Settings\Settings\Admin\Security</admin>
3737
<admin>OCA\Settings\Settings\Admin\Delegation</admin>
38-
<delegation>OCA\Settings\Settings\Admin\Users</delegation>
3938
<admin-section>OCA\Settings\Sections\Admin\Additional</admin-section>
4039
<admin-section>OCA\Settings\Sections\Admin\Delegation</admin-section>
4140
<admin-section>OCA\Settings\Sections\Admin\Groupware</admin-section>
@@ -45,6 +44,8 @@
4544
<admin-section>OCA\Settings\Sections\Admin\Security</admin-section>
4645
<admin-section>OCA\Settings\Sections\Admin\Server</admin-section>
4746
<admin-section>OCA\Settings\Sections\Admin\Sharing</admin-section>
47+
<admin-delegation>OCA\Settings\Settings\Admin\Users</admin-delegation>
48+
<admin-delegation-section>OCA\Settings\Sections\Admin\Users</admin-delegation-section>
4849
<personal>OCA\Settings\Settings\Personal\Additional</personal>
4950
<personal>OCA\Settings\Settings\Personal\PersonalInfo</personal>
5051
<personal>OCA\Settings\Settings\Personal\ServerDevNotice</personal>

apps/settings/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
'OCA\\Settings\\Sections\\Admin\\Security' => $baseDir . '/../lib/Sections/Admin/Security.php',
6161
'OCA\\Settings\\Sections\\Admin\\Server' => $baseDir . '/../lib/Sections/Admin/Server.php',
6262
'OCA\\Settings\\Sections\\Admin\\Sharing' => $baseDir . '/../lib/Sections/Admin/Sharing.php',
63+
'OCA\\Settings\\Sections\\Admin\\Users' => $baseDir . '/../lib/Sections/Admin/Users.php',
6364
'OCA\\Settings\\Sections\\Personal\\Availability' => $baseDir . '/../lib/Sections/Personal/Availability.php',
6465
'OCA\\Settings\\Sections\\Personal\\Calendar' => $baseDir . '/../lib/Sections/Personal/Calendar.php',
6566
'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php',

apps/settings/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class ComposerStaticInitSettings
7575
'OCA\\Settings\\Sections\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Sections/Admin/Security.php',
7676
'OCA\\Settings\\Sections\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Sections/Admin/Server.php',
7777
'OCA\\Settings\\Sections\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Sections/Admin/Sharing.php',
78+
'OCA\\Settings\\Sections\\Admin\\Users' => __DIR__ . '/..' . '/../lib/Sections/Admin/Users.php',
7879
'OCA\\Settings\\Sections\\Personal\\Availability' => __DIR__ . '/..' . '/../lib/Sections/Personal/Availability.php',
7980
'OCA\\Settings\\Sections\\Personal\\Calendar' => __DIR__ . '/..' . '/../lib/Sections/Personal/Calendar.php',
8081
'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php',
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\Settings\Sections\Admin;
11+
12+
use OCP\IL10N;
13+
use OCP\Settings\IIconSection;
14+
15+
class Users implements IIconSection {
16+
public function __construct(
17+
private IL10N $l,
18+
) {
19+
}
20+
21+
public function getID(): string {
22+
return 'usersdelegation';
23+
}
24+
25+
public function getName(): string {
26+
return $this->l->t('Users');
27+
}
28+
29+
public function getPriority(): int {
30+
return 55;
31+
}
32+
33+
public function getIcon(): string {
34+
return '';
35+
}
36+
}

apps/settings/lib/Settings/Admin/Users.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,27 @@
1010
namespace OCA\Settings\Settings\Admin;
1111

1212
use OCP\AppFramework\Http\TemplateResponse;
13-
use OCP\IL10N;
1413
use OCP\Settings\IDelegatedSettings;
1514

1615
/**
1716
* Empty settings class, used only for admin delegation.
1817
*/
1918
class Users implements IDelegatedSettings {
20-
21-
public function __construct(
22-
protected string $appName,
23-
private IL10N $l10n,
24-
) {
25-
}
26-
27-
/**
28-
* Empty template response
29-
*/
3019
public function getForm(): TemplateResponse {
31-
32-
return new /** @template-extends TemplateResponse<\OCP\AppFramework\Http::STATUS_OK, array{}> */ class($this->appName, '') extends TemplateResponse {
33-
public function render(): string {
34-
return '';
35-
}
36-
};
20+
throw new \Exception('Admin delegation settings should never be rendered');
3721
}
3822

3923
public function getSection(): ?string {
40-
return 'admindelegation';
24+
return 'usersdelegation';
4125
}
4226

43-
/**
44-
* @return int whether the form should be rather on the top or bottom of
45-
* the admin section. The forms are arranged in ascending order of the
46-
* priority values. It is required to return a value between 0 and 100.
47-
*
48-
* E.g.: 70
49-
*/
5027
public function getPriority(): int {
5128
return 0;
5229
}
5330

54-
public function getName(): string {
55-
return $this->l10n->t('Users');
31+
public function getName(): ?string {
32+
/* Use section name alone */
33+
return null;
5634
}
5735

5836
public function getAuthorizedAppConfig(): array {

apps/webhook_listeners/appinfo/info.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
</commands>
3333

3434
<settings>
35-
<delegation>OCA\WebhookListeners\Settings\Admin</delegation>
35+
<admin-delegation>OCA\WebhookListeners\Settings\Admin</admin-delegation>
36+
<admin-delegation-section>OCA\WebhookListeners\Settings\AdminSection</admin-delegation-section>
3637
</settings>
3738
</info>

apps/webhook_listeners/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
'OCA\\WebhookListeners\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
2121
'OCA\\WebhookListeners\\Service\\PHPMongoQuery' => $baseDir . '/../lib/Service/PHPMongoQuery.php',
2222
'OCA\\WebhookListeners\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
23+
'OCA\\WebhookListeners\\Settings\\AdminSection' => $baseDir . '/../lib/Settings/AdminSection.php',
2324
);

apps/webhook_listeners/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ComposerStaticInitWebhookListeners
3535
'OCA\\WebhookListeners\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
3636
'OCA\\WebhookListeners\\Service\\PHPMongoQuery' => __DIR__ . '/..' . '/../lib/Service/PHPMongoQuery.php',
3737
'OCA\\WebhookListeners\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
38+
'OCA\\WebhookListeners\\Settings\\AdminSection' => __DIR__ . '/..' . '/../lib/Settings/AdminSection.php',
3839
);
3940

4041
public static function getInitializer(ClassLoader $loader)

apps/webhook_listeners/lib/Settings/Admin.php

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,32 @@
99

1010
namespace OCA\WebhookListeners\Settings;
1111

12-
use OCP\AppFramework\Http;
12+
use OCA\WebhookListeners\AppInfo\Application;
1313
use OCP\AppFramework\Http\TemplateResponse;
14-
use OCP\IL10N;
1514
use OCP\Settings\IDelegatedSettings;
1615

1716
/**
1817
* Empty settings class, used only for admin delegation for now as there is no UI
1918
*/
2019
class Admin implements IDelegatedSettings {
21-
22-
public function __construct(
23-
protected string $appName,
24-
private IL10N $l10n,
25-
) {
26-
}
27-
2820
/**
2921
* Empty template response
3022
*/
3123
public function getForm(): TemplateResponse {
32-
33-
return new /** @template-extends TemplateResponse<Http::STATUS_OK, array{}> */ class($this->appName, '') extends TemplateResponse {
34-
public function render(): string {
35-
return '';
36-
}
37-
};
24+
throw new \Exception('Admin delegation settings should never be rendered');
3825
}
3926

40-
public function getSection(): ?string {
41-
return 'admindelegation';
27+
public function getSection(): string {
28+
return Application::APP_ID . '-admin';
4229
}
4330

44-
/**
45-
* @return int whether the form should be rather on the top or bottom of
46-
* the admin section. The forms are arranged in ascending order of the
47-
* priority values. It is required to return a value between 0 and 100.
48-
*
49-
* E.g.: 70
50-
*/
5131
public function getPriority(): int {
5232
return 0;
5333
}
5434

55-
public function getName(): string {
56-
return $this->l10n->t('Webhooks');
35+
public function getName(): ?string {
36+
/* Use section name alone */
37+
return null;
5738
}
5839

5940
public function getAuthorizedAppConfig(): array {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\WebhookListeners\Settings;
11+
12+
use OCA\WebhookListeners\AppInfo\Application;
13+
use OCP\IL10N;
14+
use OCP\Settings\IIconSection;
15+
16+
class AdminSection implements IIconSection {
17+
public function __construct(
18+
private IL10N $l,
19+
) {
20+
}
21+
22+
public function getID(): string {
23+
return Application::APP_ID . '-admin';
24+
}
25+
26+
public function getName(): string {
27+
return $this->l->t('Webhooks');
28+
}
29+
30+
public function getPriority(): int {
31+
return 56;
32+
}
33+
34+
public function getIcon(): string {
35+
return '';
36+
}
37+
}

0 commit comments

Comments
 (0)