Render the PDF report's row links for an administrator alone#13130
Render the PDF report's row links for an administrator alone#13130shervElmi wants to merge 13 commits into
Conversation
Add a required viewOnly flag to the shared PDF getData params, and pass the value the orchestrator already reads from useViewOnly into every widget's getData call. The per-widget commits that follow read the flag to decide whether to resolve a link.
With an empty href, PDFLink renders its text in the default color with no annotation. A widget then passes a row's link straight through, and a view-only export's empty link reads as plain text without the widget branching on its own.
Resolve the Search Console report link for each query only when the export is not view-only, and render the query through PDFLink. A view-only export leaves the link empty, so the query reads as plain text, matching the dashboard widget.
Link each title to the same All pages and screens report the dashboard widget opens for an administrator. The loader built the entity dashboard URL before. Keep the public URL on the URL line, and resolve neither link on a view-only export.
Build the Analytics report link for each page only when the export is not view-only, and render the title through PDFLink. A view-only export leaves the link empty, so the title reads as plain text.
Pass the loader a link resolver, which the card builder calls for each top content page path, since only the builder reads those rows. The resolver returns an empty link on a view-only export, so the tile renders the title as plain text.
These widgets render no row links, so their loaders take the new flag and leave it unread. The three that declare their own params interface add the field there. Each holds a comment saying the loader ignores it, so the shared pipeline typechecks.
🎭 Playwright reports for a71e4c0: 📚 Storybook for a71e4c0: 📦 Build files for a71e4c0:
|
There was a problem hiding this comment.
Thanks @shervElmi Nice work.
There are just few things we should polish and fix, before it is ready.
We also need to align with AC point "The links present in a generated PDF match those the same user sees on their dashboard." which current implementation misses in one case for view only users:
You can see above, view only users can click top content pages, and see them in entity dashboard, but in PDF they can't which is not matching the dashboard behaviour hence mismatch with the pointed AC. This is the PDF:
There is also a conflict with develop we should resolve
| * @since n.e.x.t Added the `viewContext` parameter. | ||
| * | ||
| * @param viewContext The dashboard view context to render under. | ||
| * @return The render result for the orchestrator. |
There was a problem hiding this comment.
Param and return should include {type}, you can check this for example:
site-kit-wp/assets/js/analytics-advanced-tracking.ts
Lines 26 to 34 in 87b004e
There was a problem hiding this comment.
Thanks @zutigrm! I don't think we add parameter types to JSDoc in TypeScript files.
There was a problem hiding this comment.
We still include them in TypeScript files as well, as stated in our doc:
site-kit-wp/docs/context/js/jsdoc.md
Line 124 in 7c18370
The JSDoc block stays (description,
\@since,\@param,\@return), and\@param/\@returnstill carry their{type}annotations as in JS — only\@typedef/\@propertyare dropped in favour of the TypeScript type.
There was a problem hiding this comment.
For clarification: the TS Types should be the “Source of truth” and the ones we’ll use going forward.
Eventually we’ll remove this ESLint rule from TypeScript files, but I just haven’t got around to it yet. 😅
For now: yes, we tend to "redundantly" document them twice, but treat the TS types as the main place for documentation, etc. 🙂
Updated the PDF data loader interfaces to use a unified parameter structure, improving clarity and maintainability. Introduced `PDFDataLoaderParams` and adjusted related functions accordingly. New tests added for the `getAllPagesReportURL` utility to ensure correct functionality.
zutigrm
left a comment
There was a problem hiding this comment.
Thanks @shervElmi , looks good now. Just one more merge conflict to be resolved, and left you one reply
| * @since n.e.x.t Added the `viewContext` parameter. | ||
| * | ||
| * @param viewContext The dashboard view context to render under. | ||
| * @return The render result for the orchestrator. |
There was a problem hiding this comment.
We still include them in TypeScript files as well, as stated in our doc:
site-kit-wp/docs/context/js/jsdoc.md
Line 124 in 7c18370
The JSDoc block stays (description,
\@since,\@param,\@return), and\@param/\@returnstill carry their{type}annotations as in JS — only\@typedef/\@propertyare dropped in favour of the TypeScript type.
…pdf-view-only-links
Updated parameter types and return types in various functions to improve documentation accuracy. This change ensures better understanding of the codebase for future developers and maintains consistency in JSDoc formatting.
Updated the parameter types in the getPageLinkMap and getPopularPageLinkMap functions to use a more concise Pick type for better readability and maintainability.
Summary
Addresses issue:
Relevant technical choices
shared-react-pdf-components/PDFLink.tsxhrefis empty, so a widget passes its URL straight through and never branches. The IB gave each widget that conditional, which repeated the same markup across the report.AudienceTilesWidget/getPDFData.tsandbuildPDFAudienceCard.tsDashboardAllTrafficWidgetGA4/getPDFData.ts,DashboardPageSpeedWidget/getPDFData.ts, andSearchFunnelWidgetGA4/getPDFData.tsGetPDFDataParams, so each neededviewOnlyto typecheck. A comment marks that the loader doesn't read it.AudienceTilesWidget/PDFYourVisitorGroupsTile.tsx6pxrow gap.PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist