refactor: Port dashboard app to IAppConfig

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
pull/55396/head
Carl Schwan 1 week ago
parent 09d7ddadf1
commit 76736cf9d7
  1. 4
      apps/dashboard/lib/Controller/DashboardApiController.php
  2. 4
      apps/dashboard/lib/Service/DashboardService.php
  3. 5
      apps/dashboard/tests/DashboardServiceTest.php
  4. 10
      build/psalm-baseline.xml

@ -17,6 +17,7 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Services\IAppConfig;
use OCP\Dashboard\IAPIWidget;
use OCP\Dashboard\IAPIWidgetV2;
use OCP\Dashboard\IButtonWidget;
@ -43,6 +44,7 @@ class DashboardApiController extends OCSController {
string $appName,
IRequest $request,
private IManager $dashboardManager,
private IAppConfig $appConfig,
private IConfig $config,
private ?string $userId,
private DashboardService $service,
@ -56,7 +58,7 @@ class DashboardApiController extends OCSController {
*/
private function getShownWidgets(array $widgetIds): array {
if (empty($widgetIds)) {
$systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar');
$systemDefault = $this->appConfig->getAppValueString('layout', 'recommendations,spreed,mail,calendar');
$widgetIds = explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault));
}

@ -11,12 +11,14 @@ namespace OCA\Dashboard\Service;
use JsonException;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\AppFramework\Services\IAppConfig;
use OCP\IConfig;
use OCP\IUserManager;
class DashboardService {
public function __construct(
private IConfig $config,
private IAppConfig $appConfig,
private ?string $userId,
private IUserManager $userManager,
private IAccountManager $accountManager,
@ -28,7 +30,7 @@ class DashboardService {
* @return list<string>
*/
public function getLayout(): array {
$systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar');
$systemDefault = $this->appConfig->getAppValueString('layout', 'recommendations,spreed,mail,calendar');
return array_values(array_filter(explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault)), fn (string $value) => $value !== ''));
}

@ -12,6 +12,7 @@ namespace OCA\Dashboard\Tests;
use OC\Accounts\Account;
use OCA\Dashboard\Service\DashboardService;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Services\IAppConfig;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
@ -21,6 +22,7 @@ use Test\TestCase;
class DashboardServiceTest extends TestCase {
private IConfig&MockObject $config;
private IAppConfig&MockObject $appConfig;
private IUserManager&MockObject $userManager;
private IAccountManager&MockObject $accountManager;
private DashboardService $service;
@ -29,11 +31,13 @@ class DashboardServiceTest extends TestCase {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->accountManager = $this->createMock(IAccountManager::class);
$this->service = new DashboardService(
$this->config,
$this->appConfig,
'alice',
$this->userManager,
$this->accountManager,
@ -87,6 +91,7 @@ class DashboardServiceTest extends TestCase {
public function testGetBirthdateNoUserId(): void {
$service = new DashboardService(
$this->config,
$this->appConfig,
null,
$this->userManager,
$this->accountManager,

@ -113,16 +113,6 @@
<code><![CDATA[$this->path]]></code>
</DeprecatedProperty>
</file>
<file src="apps/dashboard/lib/Controller/DashboardApiController.php">
<DeprecatedMethod>
<code><![CDATA[getAppValue]]></code>
</DeprecatedMethod>
</file>
<file src="apps/dashboard/lib/Service/DashboardService.php">
<DeprecatedMethod>
<code><![CDATA[getAppValue]]></code>
</DeprecatedMethod>
</file>
<file src="apps/dav/appinfo/v1/caldav.php">
<DeprecatedMethod>
<code><![CDATA[exec]]></code>

Loading…
Cancel
Save