Skip to content

Commit

Permalink
implement IButtonWidget and IIconWidget in user_status
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
Julien Veyssier committed Sep 7, 2022
1 parent 90bff96 commit 3c34d74
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions apps/user_status/lib/Dashboard/UserStatusWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Services\IInitialState;
use OCP\Dashboard\IAPIWidget;
use OCP\Dashboard\IButtonWidget;
use OCP\Dashboard\IIconWidget;
use OCP\Dashboard\Model\WidgetItem;
use OCP\IDateTimeFormatter;
use OCP\IL10N;
Expand All @@ -44,7 +46,7 @@
*
* @package OCA\UserStatus
*/
class UserStatusWidget implements IAPIWidget {
class UserStatusWidget implements IAPIWidget, IButtonWidget, IIconWidget {
private IL10N $l10n;
private IDateTimeFormatter $dateTimeFormatter;
private IURLGenerator $urlGenerator;
Expand Down Expand Up @@ -108,6 +110,15 @@ public function getIconClass(): string {
return 'icon-user-status';
}

/**
* @inheritDoc
*/
public function getIconUrl(): string {
return $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->imagePath(Application::APP_ID, 'app.svg')
);
}

/**
* @inheritDoc
*/
Expand All @@ -123,7 +134,7 @@ public function load(): void {

$currentUser = $this->userSession->getUser();
if ($currentUser === null) {
$this->initialStateService->provideInitialState(Application::APP_ID, 'dashboard_data', []);
$this->initialStateService->provideInitialState('dashboard_data', []);
return;
}
$currentUserId = $currentUser->getUID();
Expand Down Expand Up @@ -187,4 +198,11 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
);
}, $widgetItemsData);
}

/**
* @inheritDoc
*/
public function getWidgetButtons(string $userId): array {
return [];
}
}

0 comments on commit 3c34d74

Please sign in to comment.