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

enh(dashboard): add recent pages dashboard widget #898

Merged
merged 10 commits into from
Nov 7, 2023

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented Sep 21, 2023

Fixes: #113

Screenshot_20230929_115738

The implementation is not necessarily the most performant one… but using the services of Collectives that already are at hand.

@blizzz blizzz force-pushed the feat/noad/dashboard-widget branch 2 times, most recently from 4a9d5bd to 85412d1 Compare September 22, 2023 09:52
@blizzz blizzz marked this pull request as ready for review September 22, 2023 09:56
@blizzz blizzz requested a review from mejo- September 22, 2023 09:56
@mejo-
Copy link
Member

mejo- commented Sep 25, 2023

Super nice, thanks @blizzz!

We probably should think about more performant solutions to fetch the list of recent pages for all collectives. What do you think about a dedicated getRecentPagesForCollectives(array $collectiveIds) function that gets the most recent pages for a list of collectives from the oc_filecache table along with a JOIN on oc_collectives_pages?

Something along the lines of:

SELECT p.*, fc.mtime FROM oc_filecache fc LEFT JOIN oc_collectives_pages p ON fc.fileId = p.file_id WHERE (fc.path LIKE 'appdata_123/collectives/13/%' OR fc.path LIKE 'appdata_123/collectives/14/%') AND mimetype=14;

@mejo-
Copy link
Member

mejo- commented Sep 25, 2023

By the way, that's the corresponding issue that will be closed with this PR: #113

@blizzz
Copy link
Member Author

blizzz commented Sep 29, 2023

@mejo- please see the latest commit that targets your suggestions and our conversation in talk.

P.S.: What is also fixed is a Readme title that appeared before, and Collective emojis are also added. Screenshot ^ is updated.

@blizzz blizzz force-pushed the feat/noad/dashboard-widget branch from 32006bb to 41618ee Compare September 29, 2023 10:05
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @blizzz, looks really good overall. I have some minor comments though.

lib/Service/RecentPagesService.php Show resolved Hide resolved
lib/Service/RecentPagesService.php Outdated Show resolved Hide resolved
lib/Service/RecentPagesService.php Outdated Show resolved Hide resolved
lib/Model/RecentPage.php Show resolved Hide resolved
lib/Dashboard/RecentPagesWidget.php Outdated Show resolved Hide resolved
lib/Model/RecentPage.php Outdated Show resolved Hide resolved
lib/Service/RecentPagesService.php Outdated Show resolved Hide resolved
@blizzz blizzz force-pushed the feat/noad/dashboard-widget branch from 41618ee to f5a39f2 Compare October 4, 2023 18:49
@cypress
Copy link

cypress bot commented Oct 4, 2023

1 failed and 1 flaky tests on run #1242 ↗︎

1 252 0 0 Flakiness 1

Details:

enh(dashboard): add recent pages dashboard widget
Project: Collectives Commit: aa7febfe72
Status: Failed Duration: 15:00 💡
Started: Nov 7, 2023 7:43 PM Ended: Nov 7, 2023 7:58 PM
Failed  cypress/e2e/page-list.spec.js • 1 failed test • Nextcloud stable25

View
Output

Test Artifacts
Page list > Page trash > allows to trash and restore page with subpage and attachment Test Replay Screenshots
Flakiness  cypress/e2e/page-list.spec.js • 1 flaky test • Nextcloud stable27

View
Output

Test Artifacts
Page list > Page trash > allows to trash and restore page with subpage and attachment Test Replay Screenshots

Review all test suite changes for PR #898 ↗︎

@blizzz blizzz force-pushed the feat/noad/dashboard-widget branch from f5a39f2 to 48109ce Compare October 4, 2023 19:11
@juliusknorr juliusknorr force-pushed the feat/noad/dashboard-widget branch from 48109ce to c586066 Compare October 31, 2023 09:29
@blizzz blizzz force-pushed the feat/noad/dashboard-widget branch 2 times, most recently from 01f1ba5 to 828e953 Compare November 2, 2023 20:58
@blizzz
Copy link
Member Author

blizzz commented Nov 2, 2023

not sure why the cypress tests are failing, this is rather a frontend thing. Similar failures reported at #936

@blizzz blizzz force-pushed the feat/noad/dashboard-widget branch 2 times, most recently from 148a121 to f5aaa73 Compare November 3, 2023 11:26
@blizzz blizzz requested a review from mejo- November 3, 2023 11:26
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a small Cypress smoke test that tests whether the recent pages widget displays and lists a page would be good. @blizzz would you like to look into this yourself?

Given that I'd like to release Collectives latest tomorrow we can either postpone this or I'll see whether I find time to do it myself later.

@blizzz
Copy link
Member Author

blizzz commented Nov 7, 2023

I think a small Cypress smoke test that tests whether the recent pages widget displays and lists a page would be good. @blizzz would you like to look into this yourself?

Given that I'd like to release Collectives latest tomorrow we can either postpone this or I'll see whether I find time to do it myself later.

I cannot promise to accomplish this today.

@juliusknorr
Copy link
Member

Let's follow up on that then I'd say

Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nice, thanks again for the PR. Only two comments. I have both suggested code changes ready locally and could commit+push them to this PR to get the PR in quickly.

But also fine if you want to do the changes yourself.

} else {
$title = basename($internalPath);
}
$url = $this->urlGenerator->linkToRoute('collectives.start.indexPath', ['path' => implode('/', $pathParts)]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$url = $this->urlGenerator->linkToRoute('collectives.start.indexPath', ['path' => implode('/', $pathParts)]);
$fileIdSuffix = '?fileId=' . $row['file_id'];
$url = $this->urlGenerator->linkToRoute('collectives.start.indexPath', ['path' => implode('/', $pathParts)]) . $fileIdSuffix;

It would be nice to add the fileId query parameter to the URL, to make the URL more robust to title changes (e.g. when copying the URL somewhere else).

if ($row['filename'] !== 'Readme.md') {
$pathParts[] = basename($row['filename'], PageInfo::SUFFIX);
$title = basename($row['filename'], PageInfo::SUFFIX);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else {
} elseif ($internalPath === '' || $internalPath === '.') {
$title = $this->l10n->t('Landing page');
} else {

We have to special-treat landing pages here.

@mejo- mejo- force-pushed the feat/noad/dashboard-widget branch from f5aaa73 to abb2409 Compare November 7, 2023 15:29
@mejo-
Copy link
Member

mejo- commented Nov 7, 2023

I pushed a simple Cypress test.

Edit: the Cypress test depends on the fix for landing pages to succeed 🙈

@mejo- mejo- force-pushed the feat/noad/dashboard-widget branch 2 times, most recently from 55dc145 to ca3c11b Compare November 7, 2023 16:16
blizzz and others added 10 commits November 7, 2023 20:34
…tion

- adds a simplified RecentPage model to avoid incomplete PageInfo instances
- add RecentPageService with a method to fetch them for a specified user
- adapts and simplifies RecenPagesWidget

Signed-off-by: Arthur Schiwon <[email protected]>
- CollectiveHelper methods now return array with collective id as key
- by catch: make use of fluid setter at RecentPage

Signed-off-by: Arthur Schiwon <[email protected]>
- psalm issue: vimeo/psalm#8258

Signed-off-by: Arthur Schiwon <[email protected]>
@mejo- mejo- force-pushed the feat/noad/dashboard-widget branch from ca3c11b to aa7febf Compare November 7, 2023 19:34
@mejo- mejo- merged commit 8aacaf0 into main Nov 7, 2023
50 of 57 checks passed
@delete-merged-branch delete-merged-branch bot deleted the feat/noad/dashboard-widget branch November 7, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Dashboard Widget
3 participants