Skip to content

Commit d36fc65

Browse files
authored
Merge pull request #55396 from nextcloud/carl/dashboard-appconfig
refactor: Port dashboard app to IAppConfig
2 parents 52aed03 + 76736cf commit d36fc65

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

apps/dashboard/lib/Controller/DashboardApiController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
1818
use OCP\AppFramework\Http\DataResponse;
1919
use OCP\AppFramework\OCSController;
20+
use OCP\AppFramework\Services\IAppConfig;
2021
use OCP\Dashboard\IAPIWidget;
2122
use OCP\Dashboard\IAPIWidgetV2;
2223
use OCP\Dashboard\IButtonWidget;
@@ -43,6 +44,7 @@ public function __construct(
4344
string $appName,
4445
IRequest $request,
4546
private IManager $dashboardManager,
47+
private IAppConfig $appConfig,
4648
private IConfig $config,
4749
private ?string $userId,
4850
private DashboardService $service,
@@ -56,7 +58,7 @@ public function __construct(
5658
*/
5759
private function getShownWidgets(array $widgetIds): array {
5860
if (empty($widgetIds)) {
59-
$systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar');
61+
$systemDefault = $this->appConfig->getAppValueString('layout', 'recommendations,spreed,mail,calendar');
6062
$widgetIds = explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault));
6163
}
6264

apps/dashboard/lib/Service/DashboardService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
use JsonException;
1212
use OCP\Accounts\IAccountManager;
1313
use OCP\Accounts\PropertyDoesNotExistException;
14+
use OCP\AppFramework\Services\IAppConfig;
1415
use OCP\IConfig;
1516
use OCP\IUserManager;
1617

1718
class DashboardService {
1819
public function __construct(
1920
private IConfig $config,
21+
private IAppConfig $appConfig,
2022
private ?string $userId,
2123
private IUserManager $userManager,
2224
private IAccountManager $accountManager,
@@ -28,7 +30,7 @@ public function __construct(
2830
* @return list<string>
2931
*/
3032
public function getLayout(): array {
31-
$systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar');
33+
$systemDefault = $this->appConfig->getAppValueString('layout', 'recommendations,spreed,mail,calendar');
3234
return array_values(array_filter(explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault)), fn (string $value) => $value !== ''));
3335
}
3436

apps/dashboard/tests/DashboardServiceTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OC\Accounts\Account;
1313
use OCA\Dashboard\Service\DashboardService;
1414
use OCP\Accounts\IAccountManager;
15+
use OCP\AppFramework\Services\IAppConfig;
1516
use OCP\IConfig;
1617
use OCP\IUser;
1718
use OCP\IUserManager;
@@ -21,6 +22,7 @@
2122
class DashboardServiceTest extends TestCase {
2223

2324
private IConfig&MockObject $config;
25+
private IAppConfig&MockObject $appConfig;
2426
private IUserManager&MockObject $userManager;
2527
private IAccountManager&MockObject $accountManager;
2628
private DashboardService $service;
@@ -29,11 +31,13 @@ protected function setUp(): void {
2931
parent::setUp();
3032

3133
$this->config = $this->createMock(IConfig::class);
34+
$this->appConfig = $this->createMock(IAppConfig::class);
3235
$this->userManager = $this->createMock(IUserManager::class);
3336
$this->accountManager = $this->createMock(IAccountManager::class);
3437

3538
$this->service = new DashboardService(
3639
$this->config,
40+
$this->appConfig,
3741
'alice',
3842
$this->userManager,
3943
$this->accountManager,
@@ -87,6 +91,7 @@ public function testGetBirthdateUserNotFound(): void {
8791
public function testGetBirthdateNoUserId(): void {
8892
$service = new DashboardService(
8993
$this->config,
94+
$this->appConfig,
9095
null,
9196
$this->userManager,
9297
$this->accountManager,

build/psalm-baseline.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,6 @@
113113
<code><![CDATA[$this->path]]></code>
114114
</DeprecatedProperty>
115115
</file>
116-
<file src="apps/dashboard/lib/Controller/DashboardApiController.php">
117-
<DeprecatedMethod>
118-
<code><![CDATA[getAppValue]]></code>
119-
</DeprecatedMethod>
120-
</file>
121-
<file src="apps/dashboard/lib/Service/DashboardService.php">
122-
<DeprecatedMethod>
123-
<code><![CDATA[getAppValue]]></code>
124-
</DeprecatedMethod>
125-
</file>
126116
<file src="apps/dav/appinfo/v1/caldav.php">
127117
<DeprecatedMethod>
128118
<code><![CDATA[exec]]></code>

0 commit comments

Comments
 (0)