Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dashboard): remove obsolete js widget #9979

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading