Skip to content

Commit

Permalink
chore(dashboard): remove obsolete js widget
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <[email protected]>
  • Loading branch information
st3iny committed Aug 9, 2024
1 parent 6969d6e commit 590c49b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 371 deletions.
12 changes: 2 additions & 10 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
use OCA\Mail\Contracts\ITrustedSenderService;
use OCA\Mail\Contracts\IUserPreferences;
use OCA\Mail\Dashboard\ImportantMailWidget;
use OCA\Mail\Dashboard\ImportantMailWidgetV2;
use OCA\Mail\Dashboard\UnreadMailWidget;
use OCA\Mail\Dashboard\UnreadMailWidgetV2;
use OCA\Mail\Events\BeforeImapClientCreated;
use OCA\Mail\Events\DraftMessageCreatedEvent;
use OCA\Mail\Events\DraftSavedEvent;
Expand Down Expand Up @@ -70,7 +68,6 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Dashboard\IAPIWidgetV2;
use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\IServerContainer;
use OCP\Search\IFilteringProvider;
Expand Down Expand Up @@ -150,13 +147,8 @@ public function register(IRegistrationContext $context): void {
$context->registerMiddleWare(ErrorMiddleware::class);
$context->registerMiddleWare(ProvisioningMiddleware::class);

if (interface_exists(IAPIWidgetV2::class)) {
$context->registerDashboardWidget(ImportantMailWidgetV2::class);
$context->registerDashboardWidget(UnreadMailWidgetV2::class);
} else {
$context->registerDashboardWidget(ImportantMailWidget::class);
$context->registerDashboardWidget(UnreadMailWidget::class);
}
$context->registerDashboardWidget(ImportantMailWidget::class);
$context->registerDashboardWidget(UnreadMailWidget::class);

if (interface_exists(IFilteringProvider::class)) {
$context->registerSearchProvider(FilteringProvider::class);
Expand Down
36 changes: 0 additions & 36 deletions lib/Dashboard/ImportantMailWidgetV2.php

This file was deleted.

45 changes: 37 additions & 8 deletions lib/Dashboard/MailWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
use OCA\Mail\Service\AccountService;
use OCP\AppFramework\Services\IInitialState;
use OCP\Dashboard\IAPIWidget;
use OCP\Dashboard\IAPIWidgetV2;
use OCP\Dashboard\IButtonWidget;
use OCP\Dashboard\IIconWidget;
use OCP\Dashboard\IOptionWidget;
use OCP\Dashboard\Model\WidgetButton;
use OCP\Dashboard\Model\WidgetItem;
use OCP\Dashboard\Model\WidgetItems;
use OCP\Dashboard\Model\WidgetOptions;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Util;

abstract class MailWidget implements IAPIWidget, IIconWidget, IOptionWidget {
abstract class MailWidget implements IAPIWidget, IAPIWidgetV2, IIconWidget, IOptionWidget, IButtonWidget {
protected IURLGenerator $urlGenerator;
protected IUserManager $userManager;
protected AccountService $accountService;
Expand Down Expand Up @@ -85,12 +88,7 @@ public function getUrl(): ?string {
* @inheritDoc
*/
public function load(): void {
Util::addScript(Application::APP_ID, 'dashboard');

$this->initialState->provideInitialState(
'mail-accounts',
$this->accountService->findByUserId($this->userId)
);
// No assets need to be loaded anymore as the widget is rendered from the API
}

/**
Expand Down Expand Up @@ -154,10 +152,41 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
}, $emails);
}

/**
* @inheritDoc
*/
public function getItemsV2(string $userId, ?string $since = null, int $limit = 7): WidgetItems {
$items = $this->getItems($userId, $since, $limit);
return new WidgetItems(
$items,
empty($items) ? $this->l10n->t('No message found yet') : '',
);
}

/**
* @inheritDoc
*/
public function getWidgetOptions(): WidgetOptions {
return new WidgetOptions(true);
}

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

if ($this->userId !== null) {
$accounts = $this->accountService->findByUserId($this->userId);
if (empty($accounts)) {
$buttons[] = new WidgetButton(
WidgetButton::TYPE_SETUP,
$this->urlGenerator->linkToRouteAbsolute('mail.page.setup'),
$this->l10n->t('Set up an account'),
);
}
}

return $buttons;
}
}
59 changes: 0 additions & 59 deletions lib/Dashboard/MailWidgetV2.php

This file was deleted.

36 changes: 0 additions & 36 deletions lib/Dashboard/UnreadMailWidgetV2.php

This file was deleted.

150 changes: 0 additions & 150 deletions src/components/Dashboard.vue

This file was deleted.

Loading

0 comments on commit 590c49b

Please sign in to comment.