-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feature: added new FavouriteWidget to display favorite files in dashboard widget #49534
base: master
Are you sure you want to change the base?
feature: added new FavouriteWidget to display favorite files in dashboard widget #49534
Conversation
…d widget Signed-off-by: yemkareems <[email protected]>
09e1e7c
to
341e377
Compare
@@ -7,14 +7,14 @@ | |||
class ComposerStaticInitFiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue in this file, please run build/autoloaderchecker.sh
and commit the result without modifications
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; | ||
|
||
public function __construct( | ||
IUserSession $userSession, | ||
IL10N $l10n, | ||
IURLGenerator $urlGenerator, | ||
IMimeTypeDetector $mimeTypeDetector, | ||
IUserManager $userManager, | ||
ITagManager $tagManager, | ||
IRootFolder $rootFolder, | ||
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; | |
public function __construct( | |
IUserSession $userSession, | |
IL10N $l10n, | |
IURLGenerator $urlGenerator, | |
IMimeTypeDetector $mimeTypeDetector, | |
IUserManager $userManager, | |
ITagManager $tagManager, | |
IRootFolder $rootFolder, | |
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 __construct( | |
private IIUserSession $userSession, | |
private IIL10N $l10n, | |
private IIURLGenerator $urlGenerator, | |
private IIMimeTypeDetector $mimeTypeDetector, | |
private IIUserManager $userManager, | |
private IITagManager $tagManager, | |
private IIRootFolder $rootFolder, | |
private IIPreview $previewManager, | |
) { | |
} |
Use promoted properties on new classes.
use OCP\IUserManager; | ||
use OCP\IUserSession; | ||
|
||
class FavouriteWidget implements IWidget, IIconWidget, IAPIWidget, IAPIWidgetV2, IButtonWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all these interfaces required? IWidget is inherited anyway, and for apiwidget are both v1 and v2 needed? I never touched dashboard widgets before, asking to be sure.
} | ||
|
||
public function getId(): string { | ||
return Application::APP_ID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may have other files related widget later no?
return Application::APP_ID; | |
return Application::APP_ID.'-favourites'; |
} | ||
|
||
public function getTitle(): string { | ||
return $this->l10n->t('Favorites'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it Favorite
ou Favourite
? We should be consistent in code and UI and filenames.
} | ||
|
||
public function getUrl(): ?string { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should link to favorites view, no?
return; | ||
} | ||
return; | ||
//Util::addScript(Application::APP_ID, 'recommendations-dashboard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//Util::addScript(Application::APP_ID, 'recommendations-dashboard'); |
$user = $this->userSession->getUser(); | ||
if ($user === null) { | ||
return; | ||
} | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s not doing anything?
} elseif (isset($favorites[self::FAVORITE_LIMIT])) { | ||
return []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that returning an empty list?
Looping in @jancborchardt for
This seems unintuitive since "no favorites" implies Or I misunderstand the description @yemkareems 😄 |
Following Andy's comment, I would actually say we show the last xx updated favorites (like 20 🤷 ) |
feature: added new FavouriteWidget to display favorite files in dashboard widget
added a new widget to display favorite files in dashboard and to show a link to more favorites to apps/files/favorites. if max count of favorites of 50 is reached then also 'No favorites' is displayed
fixes: #23308
Summary
TODO
Checklist