Skip to content

Commit

Permalink
fix: added widget star icon, run build/autoloaderchecker.sh, removed …
Browse files Browse the repository at this point in the history
…unwanted IWidget and usersession, renamed id, renamed class to FavoriteWidget, removed limit logic

Signed-off-by: yemkareems <yemkareems@gmail.com>
  • Loading branch information
yemkareems committed Dec 2, 2024
1 parent 341e377 commit 69ab81d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 47 deletions.
2 changes: 1 addition & 1 deletion apps/files/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'OCA\\Files\\Controller\\TemplateController' => $baseDir . '/../lib/Controller/TemplateController.php',
'OCA\\Files\\Controller\\TransferOwnershipController' => $baseDir . '/../lib/Controller/TransferOwnershipController.php',
'OCA\\Files\\Controller\\ViewController' => $baseDir . '/../lib/Controller/ViewController.php',
'OCA\\Files\\Dashboard\\FavouriteWidget' => $baseDir . '/../lib/Dashboard/FavouriteWidet.php',
'OCA\\Files\\Dashboard\\FavoriteWidget' => $baseDir . '/../lib/Dashboard/FavoriteWidget.php',
'OCA\\Files\\Db\\OpenLocalEditor' => $baseDir . '/../lib/Db/OpenLocalEditor.php',
'OCA\\Files\\Db\\OpenLocalEditorMapper' => $baseDir . '/../lib/Db/OpenLocalEditorMapper.php',
'OCA\\Files\\Db\\TransferOwnership' => $baseDir . '/../lib/Db/TransferOwnership.php',
Expand Down
7 changes: 4 additions & 3 deletions apps/files/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
class ComposerStaticInitFiles
{
public static $prefixLengthsPsr4 = array (
'O' =>
'O' =>
array (
'OCA\\Files\\' => 10,
),
);

public static $prefixDirsPsr4 = array (
'OCA\\Files\\' =>
'OCA\\Files\\' =>
array (
0 => __DIR__ . '/..' . '/../lib',
),
Expand Down Expand Up @@ -63,7 +63,8 @@ class ComposerStaticInitFiles
'OCA\\Files\\Controller\\TemplateController' => __DIR__ . '/..' . '/../lib/Controller/TemplateController.php',
'OCA\\Files\\Controller\\TransferOwnershipController' => __DIR__ . '/..' . '/../lib/Controller/TransferOwnershipController.php',
'OCA\\Files\\Controller\\ViewController' => __DIR__ . '/..' . '/../lib/Controller/ViewController.php',
'OCA\\Files\\Dashboard\\FavouriteWidget' => __DIR__ . '/..' . '/../lib/Dashboard/FavouriteWidget.php', 'OCA\\Files\\Db\\OpenLocalEditor' => __DIR__ . '/..' . '/../lib/Db/OpenLocalEditor.php',
'OCA\\Files\\Dashboard\\FavoriteWidget' => __DIR__ . '/..' . '/../lib/Dashboard/FavoriteWidget.php',
'OCA\\Files\\Db\\OpenLocalEditor' => __DIR__ . '/..' . '/../lib/Db/OpenLocalEditor.php',
'OCA\\Files\\Db\\OpenLocalEditorMapper' => __DIR__ . '/..' . '/../lib/Db/OpenLocalEditorMapper.php',
'OCA\\Files\\Db\\TransferOwnership' => __DIR__ . '/..' . '/../lib/Db/TransferOwnership.php',
'OCA\\Files\\Db\\TransferOwnershipMapper' => __DIR__ . '/..' . '/../lib/Db/TransferOwnershipMapper.php',
Expand Down
1 change: 1 addition & 0 deletions apps/files/img/app-favorite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use OCA\Files\Collaboration\Resources\Listener;
use OCA\Files\Collaboration\Resources\ResourceProvider;
use OCA\Files\Controller\ApiController;
use OCA\Files\Dashboard\FavouriteWidget;
use OCA\Files\Dashboard\FavoriteWidget;
use OCA\Files\DirectEditingCapabilities;
use OCA\Files\Event\LoadSearchPlugins;
use OCA\Files\Event\LoadSidebar;
Expand Down Expand Up @@ -121,7 +121,7 @@ public function register(IRegistrationContext $context): void {
$context->registerSearchProvider(FilesSearchProvider::class);

$context->registerNotifierService(Notifier::class);
$context->registerDashboardWidget(FavouriteWidget::class);
$context->registerDashboardWidget(FavoriteWidget::class);
}

public function boot(IBootContext $context): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use OCP\Dashboard\IAPIWidgetV2;
use OCP\Dashboard\IButtonWidget;
use OCP\Dashboard\IIconWidget;
use OCP\Dashboard\IWidget;
use OCP\Dashboard\Model\WidgetButton;
use OCP\Dashboard\Model\WidgetItem;
use OCP\Dashboard\Model\WidgetItems;
Expand All @@ -25,70 +24,48 @@
use OCP\ITagManager;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\IUserSession;

class FavouriteWidget implements IWidget, IIconWidget, IAPIWidget, IAPIWidgetV2, IButtonWidget {
private IUserSession $userSession;
private IL10N $l10n;
private IURLGenerator $urlGenerator;
private IMimeTypeDetector $mimeTypeDetector;
private IUserManager $userManager;
private ITagManager $tagManager;
private IRootFolder $rootFolder;
private IPreview $previewManager;
public const FAVORITE_LIMIT = 50;

class FavoriteWidget implements IIconWidget, IAPIWidget, IAPIWidgetV2, IButtonWidget {
public function __construct(
IUserSession $userSession,
IL10N $l10n,
IURLGenerator $urlGenerator,
IMimeTypeDetector $mimeTypeDetector,
IUserManager $userManager,
ITagManager $tagManager,
IRootFolder $rootFolder,
IPreview $previewManager,
private readonly IL10N $l10n,
private readonly IURLGenerator $urlGenerator,
private readonly IMimeTypeDetector $mimeTypeDetector,
private readonly IUserManager $userManager,
private readonly ITagManager $tagManager,
private readonly IRootFolder $rootFolder,
private readonly IPreview $previewManager,
) {
$this->userSession = $userSession;
$this->l10n = $l10n;
$this->urlGenerator = $urlGenerator;
$this->mimeTypeDetector = $mimeTypeDetector;
$this->userManager = $userManager;
$this->tagManager = $tagManager;
$this->rootFolder = $rootFolder;
$this->previewManager = $previewManager;

}

public function getId(): string {
return Application::APP_ID;
return Application::APP_ID.'-favorites';
}

public function getTitle(): string {
return $this->l10n->t('Favorites');
return $this->l10n->t('Favorite files');
}

public function getOrder(): int {
return 0;
}

public function getIconClass(): string {
return 'icon-files-dark';
return 'icon-star-dark';
}

public function getIconUrl(): string {
return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('files', 'app-dark.svg'));
return $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->imagePath('files', 'app-favorite.svg')
);
}

public function getUrl(): ?string {
return null;
return $this->urlGenerator->getAbsoluteURL('index.php/apps/files/favorites');
}

public function load(): void {
$user = $this->userSession->getUser();
if ($user === null) {
return;
}
return;
//Util::addScript(Application::APP_ID, 'recommendations-dashboard');
}

public function getItems(string $userId, ?string $since = null, int $limit = 7): array {
Expand All @@ -101,8 +78,6 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
$favorites = $tags->getFavorites();
if (empty($favorites)) {
return [];
} elseif (isset($favorites[self::FAVORITE_LIMIT])) {
return [];
}
$favoriteNodes = [];
$userFolder = $this->rootFolder->getUserFolder($userId);
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
'OC\\' => array($baseDir . '/lib/private'),
'OCP\\' => array($baseDir . '/lib/public'),
'NCU\\' => array($baseDir . '/lib/unstable'),
'Bamarni\\Composer\\Bin\\' => array($vendorDir . '/bamarni/composer-bin-plugin/src'),
'' => array($baseDir . '/lib/private/legacy'),
);
8 changes: 8 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
array (
'NCU\\' => 4,
),
'B' =>
array (
'Bamarni\\Composer\\Bin\\' => 21,
),
);

public static $prefixDirsPsr4 = array (
Expand All @@ -40,6 +44,10 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
array (
0 => __DIR__ . '/../../..' . '/lib/unstable',
),
'Bamarni\\Composer\\Bin\\' =>
array (
0 => __DIR__ . '/..' . '/bamarni/composer-bin-plugin/src',
),
);

public static $fallbackDirsPsr4 = array (
Expand Down

0 comments on commit 69ab81d

Please sign in to comment.