feat: add recently viewed activity dashboard widget#16837
Open
GermanJablo wants to merge 4 commits into
Open
Conversation
Introduces an "activity" dashboard widget that lists the documents the current user has recently viewed in the admin, most recent first. - Adds a per-user `recently-viewed` preference (identity + timestamp only) recorded server-side in renderDocument when a collection document opens. - The widget computes display fields (title, type pill / thumbnail, absolute timestamp) at render time under access control, so deleted or now-forbidden documents drop out automatically. - Collection filtering uses an `excludedCollections` exclusion list, so new collections appear by default. - Adds i18n keys + translations, registers the widget, and covers it with a unit test for the merge/dedup/cap helper and an e2e test. Deferred to follow-ups: per-row remove (X) and a "recently edited" tab.
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
…t configuration This commit introduces a new `RecentlyViewedCollectionsField` component that allows users to manage collections displayed in the activity widget. The field presents an inclusion filter with checkboxes for all collections, while storing the selections as an exclusion list. Additionally, it updates the dashboard widget configuration to use the new field and modifies the translations to remove the deprecated `widgetExcludedCollectionsLabel`. Comprehensive end-to-end tests are added to ensure functionality and user experience.
This commit introduces a new utility module `formatRelativeDate.ts` that provides functions for formatting ISO date strings as locale-aware relative time strings. The `getRelativeTimeFormat` function creates an `Intl.RelativeTimeFormat` instance for the specified language, falling back to English for unsupported locales. The `formatRelativeDate` function formats dates into human-readable relative time (e.g., "5m ago", "in 2d"). Additionally, the `CollectionQuery` and `RecentlyViewed` widgets are updated to utilize these new functions for rendering relative timestamps, enhancing localization support across the application.
The activity widget collections field passed getTranslation's string | Element return value to CheckboxInput's label prop, which only accepts StaticLabel, breaking build:types in CI. Resolve the label to a string before passing it. Also drop the unused getPreferences export from the rsc bundle (the widget imports it via relative path and the next package has its own implementation).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on top of #16812.
Adds an
activitydashboard widget that lists the documents the current user has recently viewed in the admin, most recent first.recently-viewedpreference storing only identity + timestamp (collectionSlug,id,viewedAt), recorded server-side inrenderDocumentwhen a collection document is opened (full-page and drawer). The write is wrapped in try/catch + logger so it can never break a document view.useAsTitle, a collection type pill or an upload thumbnail, and a relative timestamp) at render time, querying each collection under access control (overrideAccess: false). Deleted or now-forbidden documents drop out of the list automatically.formatRelativeDate/getRelativeTimeFormat) with thecollection-querywidget, so both render dates identically and locale-aware (e.g. "5m ago").excludedCollectionsexclusion list under the hood, surfaced to the user as an inclusion filter: every collection is checked by default and unchecking one adds it to the exclusions, so newly added collections show up automatically.en.ts+clientKeys.tsand translated across all locales.Test plan
recentlyViewed.spec.ts).Deferred to follow-ups
Known limitations