Skip to content

Commit

Permalink
Merge pull request #40511 from nextcloud/fix/dashboard-widgets-api
Browse files Browse the repository at this point in the history
Fix dashboard widgets api
  • Loading branch information
provokateurin authored Sep 20, 2023
2 parents 9a70c1e + 6c84098 commit 716c5e0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/lib/Controller/DashboardApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function getWidgetItemsV2(array $sinceIds = [], int $limit = 7, array $wi
* @NoAdminRequired
* @NoCSRFRequired
*
* @return DataResponse<Http::STATUS_OK, DashboardWidget[], array{}>
* @return DataResponse<Http::STATUS_OK, array<string, DashboardWidget>, array{}>
*/
public function getWidgets(): DataResponse {
$widgets = $this->dashboardManager->getWidgets();
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/Widget"
}
}
Expand Down
7 changes: 5 additions & 2 deletions lib/private/Dashboard/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Manager implements IManager {
/** @var array */
private $lazyWidgets = [];

/** @var IWidget[] */
private $widgets = [];
/** @var array<string, IWidget> */
private array $widgets = [];

private ContainerInterface $serverContainer;
private ?IAppManager $appManager = null;
Expand Down Expand Up @@ -134,6 +134,9 @@ public function loadLazyPanels(): void {
$this->lazyWidgets = [];
}

/**
* @return array<string, IWidget>
*/
public function getWidgets(): array {
$this->loadLazyPanels();
return $this->widgets;
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Dashboard/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function lazyRegisterWidget(string $widgetClass, string $appId): void;
/**
* @since 20.0.0
*
* @return IWidget[]
* @return array<string, IWidget>
*/
public function getWidgets(): array;
}

0 comments on commit 716c5e0

Please sign in to comment.